Skip to content

Commit 90c89be

Browse files
Remove non-idempotent transactions (#2771)
1 parent 9200feb commit 90c89be

17 files changed

+402
-526
lines changed

packages/firestore/src/local/indexeddb_persistence.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export class IndexedDbPersistence implements Persistence {
325325
this.scheduleClientMetadataAndPrimaryLeaseRefreshes();
326326

327327
return this.simpleDb.runTransaction(
328-
'readonly-idempotent',
328+
'readonly',
329329
[DbTargetGlobal.store],
330330
txn => getHighestListenSequenceNumber(txn)
331331
);
@@ -388,7 +388,7 @@ export class IndexedDbPersistence implements Persistence {
388388
*/
389389
private updateClientMetadataAndTryBecomePrimary(): Promise<void> {
390390
return this.simpleDb
391-
.runTransaction('readwrite-idempotent', ALL_STORES, txn => {
391+
.runTransaction('readwrite', ALL_STORES, txn => {
392392
const metadataStore = clientMetadataStore(txn);
393393
return metadataStore
394394
.put(
@@ -474,7 +474,7 @@ export class IndexedDbPersistence implements Persistence {
474474

475475
const inactiveClients = await this.runTransaction(
476476
'maybeGarbageCollectMultiClientState',
477-
'readwrite-primary-idempotent',
477+
'readwrite-primary',
478478
txn => {
479479
const metadataStore = IndexedDbPersistence.getStore<
480480
DbClientMetadataKey,
@@ -658,7 +658,7 @@ export class IndexedDbPersistence implements Persistence {
658658
this.detachVisibilityHandler();
659659
this.detachWindowUnloadHook();
660660
await this.simpleDb.runTransaction(
661-
'readwrite-idempotent',
661+
'readwrite',
662662
[DbPrimaryClient.store, DbClientMetadata.store],
663663
txn => {
664664
return this.releasePrimaryLeaseIfHeld(txn).next(() =>
@@ -690,7 +690,7 @@ export class IndexedDbPersistence implements Persistence {
690690

691691
getActiveClients(): Promise<ClientId[]> {
692692
return this.simpleDb.runTransaction(
693-
'readonly-idempotent',
693+
'readonly',
694694
[DbClientMetadata.store],
695695
txn => {
696696
return clientMetadataStore(txn)
@@ -762,16 +762,7 @@ export class IndexedDbPersistence implements Persistence {
762762
): Promise<T> {
763763
log.debug(LOG_TAG, 'Starting transaction:', action);
764764

765-
// TODO(schmidt-sebastian): Simplify once all transactions are idempotent.
766-
const idempotent = mode.endsWith('idempotent');
767-
const readonly = mode.startsWith('readonly');
768-
const simpleDbMode = readonly
769-
? idempotent
770-
? 'readonly-idempotent'
771-
: 'readonly'
772-
: idempotent
773-
? 'readwrite-idempotent'
774-
: 'readwrite';
765+
const simpleDbMode = mode === 'readonly' ? 'readonly' : 'readwrite';
775766

776767
let persistenceTransaction: PersistenceTransaction;
777768

@@ -784,10 +775,7 @@ export class IndexedDbPersistence implements Persistence {
784775
this.listenSequence.next()
785776
);
786777

787-
if (
788-
mode === 'readwrite-primary' ||
789-
mode === 'readwrite-primary-idempotent'
790-
) {
778+
if (mode === 'readwrite-primary') {
791779
// While we merely verify that we have (or can acquire) the lease
792780
// immediately, we wait to extend the primary lease until after
793781
// executing transactionOperation(). This ensures that even if the

0 commit comments

Comments
 (0)