From 8d2536e3084f411a28961372c6d4de8a7682005f Mon Sep 17 00:00:00 2001 From: Ehsan Nasiri Date: Wed, 11 May 2022 12:28:47 -0500 Subject: [PATCH 1/4] wip. --- .../local/indexeddb_document_overlay_cache.ts | 2 + .../src/local/indexeddb_mutation_queue.ts | 13 ++- .../src/local/indexeddb_persistence.ts | 1 + .../firestore/src/local/indexeddb_schema.ts | 3 +- .../src/local/indexeddb_schema_converter.ts | 106 +++++++----------- .../src/local/local_documents_view.ts | 14 +++ .../unit/local/indexeddb_persistence.test.ts | 21 +--- 7 files changed, 73 insertions(+), 87 deletions(-) diff --git a/packages/firestore/src/local/indexeddb_document_overlay_cache.ts b/packages/firestore/src/local/indexeddb_document_overlay_cache.ts index 0bea0f9bf84..43e6b599a4e 100644 --- a/packages/firestore/src/local/indexeddb_document_overlay_cache.ts +++ b/packages/firestore/src/local/indexeddb_document_overlay_cache.ts @@ -104,6 +104,7 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache { largestBatchId: number, overlays: MutationMap ): PersistencePromise { + console.log("in saveOverlays"); const promises: Array> = []; overlays.forEach((_, mutation) => { const overlay = new Overlay(largestBatchId, mutation); @@ -212,6 +213,7 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache { transaction: PersistenceTransaction, overlay: Overlay ): PersistencePromise { + console.log("in saveOverlay"); return documentOverlayStore(transaction).put( toDbDocumentOverlay(this.serializer, this.userId, overlay) ); diff --git a/packages/firestore/src/local/indexeddb_mutation_queue.ts b/packages/firestore/src/local/indexeddb_mutation_queue.ts index 0aedf650769..1d2d5a806ee 100644 --- a/packages/firestore/src/local/indexeddb_mutation_queue.ts +++ b/packages/firestore/src/local/indexeddb_mutation_queue.ts @@ -356,6 +356,7 @@ export class IndexedDbMutationQueue implements MutationQueue { transaction: PersistenceTransaction, documentKeys: SortedMap ): PersistencePromise { + console.log("in getAllMutationBatchesAffectingDocumentKeys"); let uniqueBatchIDs = new SortedSet(primitiveComparator); const promises: Array> = []; @@ -371,6 +372,9 @@ export class IndexedDbMutationQueue implements MutationQueue { (indexKey, _, control) => { const [userID, encodedPath, batchID] = indexKey; + console.log("\t iterating documentMutationStore"); + console.log(`\t batchId=${batchID}`); + // Only consider rows matching exactly the specific key of // interest. Note that because we order by path first, and we // order terminators before path separators, we'll encounter all @@ -391,8 +395,10 @@ export class IndexedDbMutationQueue implements MutationQueue { promises.push(promise); }); - return PersistencePromise.waitFor(promises).next(() => - this.lookupMutationBatches(transaction, uniqueBatchIDs) + return PersistencePromise.waitFor(promises).next(() => { + console.log(`uniqueBatchIDs.size=${uniqueBatchIDs.size}`); + return this.lookupMutationBatches(transaction, uniqueBatchIDs) + } ); } @@ -458,6 +464,8 @@ export class IndexedDbMutationQueue implements MutationQueue { transaction: PersistenceTransaction, batchIDs: SortedSet ): PersistencePromise { + console.log("in lookupMutationBatches"); + console.log(`\t batchIDs.size=${batchIDs.size}`); const results: MutationBatch[] = []; const promises: Array> = []; // TODO(rockwood): Implement this using iterate. @@ -477,6 +485,7 @@ export class IndexedDbMutationQueue implements MutationQueue { mutation.userId === this.userId, `Unexpected user '${mutation.userId}' for mutation batch ${batchId}` ); + console.log(`\t found mutation in mutationStore`); results.push(fromDbMutationBatch(this.serializer, mutation)); }) ); diff --git a/packages/firestore/src/local/indexeddb_persistence.ts b/packages/firestore/src/local/indexeddb_persistence.ts index 9e1857dde83..6aef2196471 100644 --- a/packages/firestore/src/local/indexeddb_persistence.ts +++ b/packages/firestore/src/local/indexeddb_persistence.ts @@ -217,6 +217,7 @@ export class IndexedDbPersistence implements Persistence { private readonly forceOwningTab: boolean, private readonly schemaVersion = SCHEMA_VERSION ) { + console.log(`SCHEMA_VERSION=${schemaVersion}`); if (!IndexedDbPersistence.isAvailable()) { throw new FirestoreError( Code.UNIMPLEMENTED, diff --git a/packages/firestore/src/local/indexeddb_schema.ts b/packages/firestore/src/local/indexeddb_schema.ts index 0e01dfef9e7..9a07ef3ada9 100644 --- a/packages/firestore/src/local/indexeddb_schema.ts +++ b/packages/firestore/src/local/indexeddb_schema.ts @@ -54,7 +54,8 @@ export const INDEXING_SCHEMA_VERSION = 15; * 12. Add document overlays. * 13. Rewrite the keys of the remote document cache to allow for efficient * document lookup via `getAll()`. - * 14. Add indexing support. + * 14. Add overlays. + * 15. Add indexing support. */ export const SCHEMA_VERSION = INDEXING_ENABLED ? INDEXING_SCHEMA_VERSION : 14; diff --git a/packages/firestore/src/local/indexeddb_schema_converter.ts b/packages/firestore/src/local/indexeddb_schema_converter.ts index 873060ab858..c6486deb911 100644 --- a/packages/firestore/src/local/indexeddb_schema_converter.ts +++ b/packages/firestore/src/local/indexeddb_schema_converter.ts @@ -18,7 +18,7 @@ import { User } from '../auth/user'; import { ListenSequence } from '../core/listen_sequence'; import { SnapshotVersion } from '../core/snapshot_version'; -import { documentKeySet } from '../model/collections'; +import { DocumentKeySet, documentKeySet } from '../model/collections'; import { DocumentKey } from '../model/document_key'; import { ResourcePath } from '../model/path'; import { debugAssert, fail, hardAssert } from '../util/assert'; @@ -143,6 +143,7 @@ export class SchemaConverter implements SimpleDbSchemaConverter { fromVersion: number, toVersion: number ): PersistencePromise { + console.log(`in createOrUpgrade from ${fromVersion} to ${toVersion}`); debugAssert( fromVersion < toVersion && fromVersion >= 0 && @@ -249,6 +250,7 @@ export class SchemaConverter implements SimpleDbSchemaConverter { } if (fromVersion < 14 && toVersion >= 14) { + console.log("about to runOverlayMigration"); p = p.next(() => this.runOverlayMigration(db, simpleDbTransaction)); } @@ -471,9 +473,7 @@ export class SchemaConverter implements SimpleDbSchemaConverter { db: IDBDatabase, transaction: SimpleDbTransaction ): PersistencePromise { - const queuesStore = transaction.store( - DbMutationQueueStore - ); + console.log("in runOverlayMigration"); const mutationsStore = transaction.store< DbMutationBatchKey, DbMutationBatch @@ -482,78 +482,56 @@ export class SchemaConverter implements SimpleDbSchemaConverter { const remoteDocumentCache = newIndexedDbRemoteDocumentCache( this.serializer ); + const memoryPersistence = new MemoryPersistence( + MemoryEagerDelegate.factory, + this.serializer.remoteSerializer + ); const promises: Array> = []; - let userIds = new Set(); + let userToDocumentSet = new Map(); - return queuesStore + return mutationsStore .loadAll() - .next(queues => { - for (const queue of queues) { - const userId = queue.userId; - if (userIds.has(userId)) { - // We have already processed this user. - continue; - } - userIds = userIds.add(userId); + .next(dbBatches => { + dbBatches.forEach(dbBatch => { + let documentSet = + userToDocumentSet.get(dbBatch.userId) ?? documentKeySet(); + const batch = fromDbMutationBatch(this.serializer, dbBatch); + batch.keys().forEach(key => (documentSet = documentSet.add(key))); + userToDocumentSet.set(dbBatch.userId, documentSet); + }); + }) + .next(() => { + userToDocumentSet.forEach((allDocumentKeysForUser, userId) => { const user = new User(userId); const documentOverlayCache = IndexedDbDocumentOverlayCache.forUser( this.serializer, user ); - let allDocumentKeysForUser = documentKeySet(); - const range = IDBKeyRange.bound( - [userId, BATCHID_UNKNOWN], - [userId, Number.POSITIVE_INFINITY] + // NOTE: The index manager and the reference delegate are + // irrelevant for the purpose of recalculating and saving + // overlays. We can therefore simply use the memory + // implementation. + const indexManager = memoryPersistence.getIndexManager(user); + const mutationQueue = IndexedDbMutationQueue.forUser( + user, + this.serializer, + indexManager, + memoryPersistence.referenceDelegate + ); + const localDocumentsView = new LocalDocumentsView( + remoteDocumentCache, + mutationQueue, + documentOverlayCache, + indexManager ); promises.push( - mutationsStore - .loadAll(DbMutationBatchUserMutationsIndex, range) - .next(dbBatches => { - dbBatches.forEach(dbBatch => { - hardAssert( - dbBatch.userId === userId, - `Cannot process batch ${dbBatch.batchId} from unexpected user` - ); - const batch = fromDbMutationBatch(this.serializer, dbBatch); - batch - .keys() - .forEach( - key => - (allDocumentKeysForUser = - allDocumentKeysForUser.add(key)) - ); - }); - }) - .next(() => { - // NOTE: The index manager and the reference delegate are - // irrelevant for the purpose of recalculating and saving - // overlays. We can therefore simply use the memory - // implementation. - const memoryPersistence = new MemoryPersistence( - MemoryEagerDelegate.factory, - this.serializer.remoteSerializer - ); - const indexManager = memoryPersistence.getIndexManager(user); - const mutationQueue = IndexedDbMutationQueue.forUser( - user, - this.serializer, - indexManager, - memoryPersistence.referenceDelegate - ); - const localDocumentsView = new LocalDocumentsView( - remoteDocumentCache, - mutationQueue, - documentOverlayCache, - indexManager - ); - return localDocumentsView.recalculateAndSaveOverlaysForDocumentKeys( - new IndexedDbTransaction(transaction, ListenSequence.INVALID), - allDocumentKeysForUser - ); - }) + localDocumentsView.recalculateAndSaveOverlaysForDocumentKeys( + new IndexedDbTransaction(transaction, ListenSequence.INVALID), + allDocumentKeysForUser + ) ); - } + }); }) .next(() => PersistencePromise.waitFor(promises)); } diff --git a/packages/firestore/src/local/local_documents_view.ts b/packages/firestore/src/local/local_documents_view.ts index 8281344de2b..cfbd5db0dde 100644 --- a/packages/firestore/src/local/local_documents_view.ts +++ b/packages/firestore/src/local/local_documents_view.ts @@ -215,6 +215,7 @@ export class LocalDocumentsView { transaction: PersistenceTransaction, docs: MutableDocumentMap ): PersistencePromise { + console.log("in recalculateAndSaveOverlays") const masks = newDocumentKeyMap(); // A reverse lookup map from batch id to the documents within that batch. let documentsByBatchId = new SortedMap( @@ -224,9 +225,13 @@ export class LocalDocumentsView { return this.mutationQueue .getAllMutationBatchesAffectingDocumentKeys(transaction, docs) .next(batches => { + console.log("back in recalculateAndSaveOverlays"); + console.log(`got ${batches.length} batches`); for (const batch of batches) { batch.keys().forEach(key => { + console.log(`\t key=${key.toString()}`); const baseDoc = docs.get(key); + console.log(`\t baseDoc=${baseDoc ? baseDoc.toString() : "null"}`); if (baseDoc === null) { return; } @@ -244,14 +249,21 @@ export class LocalDocumentsView { } }) .next(() => { + console.log("documentsByBatchId="); + console.log(documentsByBatchId); + console.log("masks="); + console.log(masks); const promises: Array> = []; // Iterate in descending order of batch IDs, and skip documents that are // already saved. const iter = documentsByBatchId.getReverseIterator(); while (iter.hasNext()) { + console.log(`reverse iteration over documentsByBatchId`); const entry = iter.getNext(); const batchId = entry.key; const keys = entry.value; + console.log(`\t batchId=${batchId}`); + console.log(`\t keys=${keys}`); const overlays = newMutationMap(); keys.forEach(key => { if (!processed.has(key)) { @@ -259,6 +271,7 @@ export class LocalDocumentsView { docs.get(key)!, masks.get(key)! ); + console.log(`calculateOverlayMigration resulted in ${overlayMutation ? overlayMutation?.type.toString() : "null"}`); if (overlayMutation !== null) { overlays.set(key, overlayMutation); } @@ -285,6 +298,7 @@ export class LocalDocumentsView { transaction: PersistenceTransaction, documentKeys: DocumentKeySet ): PersistencePromise { + console.log("in recalculateAndSaveOverlaysForDocumentKeys"); return this.remoteDocumentCache .getEntries(transaction, documentKeys) .next(docs => this.recalculateAndSaveOverlays(transaction, docs)); diff --git a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts index 2528e8121ca..ffdb9b87402 100644 --- a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts +++ b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts @@ -1066,7 +1066,7 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => { }); }); - it('can upgrade from schema version 13 to 14 (overlay migration)', function (this: Context) { + it.only('can upgrade from schema version 13 to 14 (overlay migration)', function (this: Context) { // This test creates a database with schema version 13 that has three users, // two of whom have local mutations. const testWriteFoo = { @@ -1163,25 +1163,6 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => { ); }); } - ).next(() => - // Populate the mutation queues' metadata - PersistencePromise.waitFor([ - mutationQueuesStore.put({ - userId: 'user1', - lastAcknowledgedBatchId: -1, - lastStreamToken: '' - }), - mutationQueuesStore.put({ - userId: 'user2', - lastAcknowledgedBatchId: -1, - lastStreamToken: '' - }), - mutationQueuesStore.put({ - userId: 'user3', - lastAcknowledgedBatchId: -1, - lastStreamToken: '' - }) - ]) ); } ); From 2575fccabd76bc49722d1cb7657aa50bf3a4dffa Mon Sep 17 00:00:00 2001 From: Ehsan Nasiri Date: Wed, 11 May 2022 12:33:38 -0500 Subject: [PATCH 2/4] remove console.log. --- .../src/local/indexeddb_document_overlay_cache.ts | 2 -- .../src/local/indexeddb_mutation_queue.ts | 13 ++----------- .../firestore/src/local/indexeddb_persistence.ts | 1 - .../src/local/indexeddb_schema_converter.ts | 3 --- .../firestore/src/local/local_documents_view.ts | 14 -------------- 5 files changed, 2 insertions(+), 31 deletions(-) diff --git a/packages/firestore/src/local/indexeddb_document_overlay_cache.ts b/packages/firestore/src/local/indexeddb_document_overlay_cache.ts index 43e6b599a4e..0bea0f9bf84 100644 --- a/packages/firestore/src/local/indexeddb_document_overlay_cache.ts +++ b/packages/firestore/src/local/indexeddb_document_overlay_cache.ts @@ -104,7 +104,6 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache { largestBatchId: number, overlays: MutationMap ): PersistencePromise { - console.log("in saveOverlays"); const promises: Array> = []; overlays.forEach((_, mutation) => { const overlay = new Overlay(largestBatchId, mutation); @@ -213,7 +212,6 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache { transaction: PersistenceTransaction, overlay: Overlay ): PersistencePromise { - console.log("in saveOverlay"); return documentOverlayStore(transaction).put( toDbDocumentOverlay(this.serializer, this.userId, overlay) ); diff --git a/packages/firestore/src/local/indexeddb_mutation_queue.ts b/packages/firestore/src/local/indexeddb_mutation_queue.ts index 1d2d5a806ee..0aedf650769 100644 --- a/packages/firestore/src/local/indexeddb_mutation_queue.ts +++ b/packages/firestore/src/local/indexeddb_mutation_queue.ts @@ -356,7 +356,6 @@ export class IndexedDbMutationQueue implements MutationQueue { transaction: PersistenceTransaction, documentKeys: SortedMap ): PersistencePromise { - console.log("in getAllMutationBatchesAffectingDocumentKeys"); let uniqueBatchIDs = new SortedSet(primitiveComparator); const promises: Array> = []; @@ -372,9 +371,6 @@ export class IndexedDbMutationQueue implements MutationQueue { (indexKey, _, control) => { const [userID, encodedPath, batchID] = indexKey; - console.log("\t iterating documentMutationStore"); - console.log(`\t batchId=${batchID}`); - // Only consider rows matching exactly the specific key of // interest. Note that because we order by path first, and we // order terminators before path separators, we'll encounter all @@ -395,10 +391,8 @@ export class IndexedDbMutationQueue implements MutationQueue { promises.push(promise); }); - return PersistencePromise.waitFor(promises).next(() => { - console.log(`uniqueBatchIDs.size=${uniqueBatchIDs.size}`); - return this.lookupMutationBatches(transaction, uniqueBatchIDs) - } + return PersistencePromise.waitFor(promises).next(() => + this.lookupMutationBatches(transaction, uniqueBatchIDs) ); } @@ -464,8 +458,6 @@ export class IndexedDbMutationQueue implements MutationQueue { transaction: PersistenceTransaction, batchIDs: SortedSet ): PersistencePromise { - console.log("in lookupMutationBatches"); - console.log(`\t batchIDs.size=${batchIDs.size}`); const results: MutationBatch[] = []; const promises: Array> = []; // TODO(rockwood): Implement this using iterate. @@ -485,7 +477,6 @@ export class IndexedDbMutationQueue implements MutationQueue { mutation.userId === this.userId, `Unexpected user '${mutation.userId}' for mutation batch ${batchId}` ); - console.log(`\t found mutation in mutationStore`); results.push(fromDbMutationBatch(this.serializer, mutation)); }) ); diff --git a/packages/firestore/src/local/indexeddb_persistence.ts b/packages/firestore/src/local/indexeddb_persistence.ts index 6aef2196471..9e1857dde83 100644 --- a/packages/firestore/src/local/indexeddb_persistence.ts +++ b/packages/firestore/src/local/indexeddb_persistence.ts @@ -217,7 +217,6 @@ export class IndexedDbPersistence implements Persistence { private readonly forceOwningTab: boolean, private readonly schemaVersion = SCHEMA_VERSION ) { - console.log(`SCHEMA_VERSION=${schemaVersion}`); if (!IndexedDbPersistence.isAvailable()) { throw new FirestoreError( Code.UNIMPLEMENTED, diff --git a/packages/firestore/src/local/indexeddb_schema_converter.ts b/packages/firestore/src/local/indexeddb_schema_converter.ts index c6486deb911..0f681d55ecd 100644 --- a/packages/firestore/src/local/indexeddb_schema_converter.ts +++ b/packages/firestore/src/local/indexeddb_schema_converter.ts @@ -143,7 +143,6 @@ export class SchemaConverter implements SimpleDbSchemaConverter { fromVersion: number, toVersion: number ): PersistencePromise { - console.log(`in createOrUpgrade from ${fromVersion} to ${toVersion}`); debugAssert( fromVersion < toVersion && fromVersion >= 0 && @@ -250,7 +249,6 @@ export class SchemaConverter implements SimpleDbSchemaConverter { } if (fromVersion < 14 && toVersion >= 14) { - console.log("about to runOverlayMigration"); p = p.next(() => this.runOverlayMigration(db, simpleDbTransaction)); } @@ -473,7 +471,6 @@ export class SchemaConverter implements SimpleDbSchemaConverter { db: IDBDatabase, transaction: SimpleDbTransaction ): PersistencePromise { - console.log("in runOverlayMigration"); const mutationsStore = transaction.store< DbMutationBatchKey, DbMutationBatch diff --git a/packages/firestore/src/local/local_documents_view.ts b/packages/firestore/src/local/local_documents_view.ts index cfbd5db0dde..8281344de2b 100644 --- a/packages/firestore/src/local/local_documents_view.ts +++ b/packages/firestore/src/local/local_documents_view.ts @@ -215,7 +215,6 @@ export class LocalDocumentsView { transaction: PersistenceTransaction, docs: MutableDocumentMap ): PersistencePromise { - console.log("in recalculateAndSaveOverlays") const masks = newDocumentKeyMap(); // A reverse lookup map from batch id to the documents within that batch. let documentsByBatchId = new SortedMap( @@ -225,13 +224,9 @@ export class LocalDocumentsView { return this.mutationQueue .getAllMutationBatchesAffectingDocumentKeys(transaction, docs) .next(batches => { - console.log("back in recalculateAndSaveOverlays"); - console.log(`got ${batches.length} batches`); for (const batch of batches) { batch.keys().forEach(key => { - console.log(`\t key=${key.toString()}`); const baseDoc = docs.get(key); - console.log(`\t baseDoc=${baseDoc ? baseDoc.toString() : "null"}`); if (baseDoc === null) { return; } @@ -249,21 +244,14 @@ export class LocalDocumentsView { } }) .next(() => { - console.log("documentsByBatchId="); - console.log(documentsByBatchId); - console.log("masks="); - console.log(masks); const promises: Array> = []; // Iterate in descending order of batch IDs, and skip documents that are // already saved. const iter = documentsByBatchId.getReverseIterator(); while (iter.hasNext()) { - console.log(`reverse iteration over documentsByBatchId`); const entry = iter.getNext(); const batchId = entry.key; const keys = entry.value; - console.log(`\t batchId=${batchId}`); - console.log(`\t keys=${keys}`); const overlays = newMutationMap(); keys.forEach(key => { if (!processed.has(key)) { @@ -271,7 +259,6 @@ export class LocalDocumentsView { docs.get(key)!, masks.get(key)! ); - console.log(`calculateOverlayMigration resulted in ${overlayMutation ? overlayMutation?.type.toString() : "null"}`); if (overlayMutation !== null) { overlays.set(key, overlayMutation); } @@ -298,7 +285,6 @@ export class LocalDocumentsView { transaction: PersistenceTransaction, documentKeys: DocumentKeySet ): PersistencePromise { - console.log("in recalculateAndSaveOverlaysForDocumentKeys"); return this.remoteDocumentCache .getEntries(transaction, documentKeys) .next(docs => this.recalculateAndSaveOverlays(transaction, docs)); From a6a4a5d9eed281aaa264bf49dfc3226976d1b747 Mon Sep 17 00:00:00 2001 From: Ehsan Nasiri Date: Wed, 11 May 2022 14:18:54 -0500 Subject: [PATCH 3/4] remove .only for test. --- .../firestore/test/unit/local/indexeddb_persistence.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts index ffdb9b87402..91af40b6f96 100644 --- a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts +++ b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts @@ -1066,7 +1066,7 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => { }); }); - it.only('can upgrade from schema version 13 to 14 (overlay migration)', function (this: Context) { + it('can upgrade from schema version 13 to 14 (overlay migration)', function (this: Context) { // This test creates a database with schema version 13 that has three users, // two of whom have local mutations. const testWriteFoo = { From 2cf4c72fede98c843c15f7b43c3ceda88d566c74 Mon Sep 17 00:00:00 2001 From: Ehsan Nasiri Date: Wed, 11 May 2022 14:43:08 -0500 Subject: [PATCH 4/4] lint fixes. --- packages/firestore/src/local/indexeddb_schema_converter.ts | 2 +- .../test/unit/local/indexeddb_persistence.test.ts | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/firestore/src/local/indexeddb_schema_converter.ts b/packages/firestore/src/local/indexeddb_schema_converter.ts index 0f681d55ecd..700d12de32c 100644 --- a/packages/firestore/src/local/indexeddb_schema_converter.ts +++ b/packages/firestore/src/local/indexeddb_schema_converter.ts @@ -485,7 +485,7 @@ export class SchemaConverter implements SimpleDbSchemaConverter { ); const promises: Array> = []; - let userToDocumentSet = new Map(); + const userToDocumentSet = new Map(); return mutationsStore .loadAll() diff --git a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts index 91af40b6f96..02b35d125aa 100644 --- a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts +++ b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts @@ -1138,11 +1138,7 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => { DbDocumentMutationKey, DbDocumentMutation >(DbDocumentMutationStore); - const mutationQueuesStore = txn.store< - DbMutationQueueKey, - DbMutationQueue - >(DbMutationQueueStore); - // Manually populate the mutation queue and create all indicies. + // Manually populate the mutations. return PersistencePromise.forEach( testMutations, (testMutation: DbMutationBatch) => { @@ -1183,7 +1179,6 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => { // We should have a total of 4 overlays: // For user1: testWriteFoo // For user2: testWriteBar, testWriteBaz, and testWritePending - // For user3: NO OVERLAYS! let p = documentOverlayStore.count().next(count => { expect(count).to.equal(4); });