From 0846fcc05d5ac43fdeddfb6baff2ba4462aed4a5 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 27 Sep 2021 16:34:12 +0200 Subject: [PATCH] add more logging during gap filling --- src/matrix/room/timeline/persistence/GapWriter.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/matrix/room/timeline/persistence/GapWriter.js b/src/matrix/room/timeline/persistence/GapWriter.js index d769cbb5..8d81288c 100644 --- a/src/matrix/room/timeline/persistence/GapWriter.js +++ b/src/matrix/room/timeline/persistence/GapWriter.js @@ -27,14 +27,18 @@ export class GapWriter { this._relationWriter = relationWriter; } - async _findOverlappingEvents(fragmentEntry, events, txn) { + async _findOverlappingEvents(fragmentEntry, events, txn, log) { const eventIds = events.map(e => e.event_id); const existingEventKeyMap = await txn.timelineEvents.getEventKeysForIds(this._roomId, eventIds); + log.set("existingEvents", existingEventKeyMap.size); const nonOverlappingEvents = events.filter(e => !existingEventKeyMap.has(e.event_id)); + log.set("nonOverlappingEvents", nonOverlappingEvents.length); let neighbourFragmentEntry; if (fragmentEntry.hasLinkedFragment) { + log.set("linkedFragmentId", fragmentEntry.linkedFragmentId); for (const eventKey of existingEventKeyMap.values()) { if (eventKey.fragmentId === fragmentEntry.linkedFragmentId) { + log.set("foundLinkedFragment", true); const neighbourFragment = await txn.timelineFragments.get(this._roomId, fragmentEntry.linkedFragmentId); neighbourFragmentEntry = fragmentEntry.createNeighbourEntry(neighbourFragment); break; @@ -183,11 +187,12 @@ export class GapWriter { // find last event in fragment so we get the eventIndex to begin creating keys at let lastKey = await this._findFragmentEdgeEventKey(fragmentEntry, txn); + log.set("lastKey", lastKey.toString()); // find out if any event in chunk is already present using findFirstOrLastOccurringEventId const { nonOverlappingEvents, neighbourFragmentEntry - } = await this._findOverlappingEvents(fragmentEntry, chunk, txn); + } = await this._findOverlappingEvents(fragmentEntry, chunk, txn, log); // create entries for all events in chunk, add them to entries const {entries, updatedEntries} = await this._storeEvents(nonOverlappingEvents, lastKey, direction, state, txn, log); const fragments = await this._updateFragments(fragmentEntry, neighbourFragmentEntry, end, entries, txn, log);