diff --git a/src/discovery/Discovery.ts b/src/discovery/Discovery.ts index 138dc1163a..37bc416f61 100644 --- a/src/discovery/Discovery.ts +++ b/src/discovery/Discovery.ts @@ -441,7 +441,6 @@ class Discovery { gestaltKey: GestaltKey, ): Promise { await this.db.withTransactionF(async (tran) => { - await tran.lock(gestaltKey); const valueIterator = tran.iterator( this.discoveryQueueDbPath, { valueAsBuffer: false }, diff --git a/src/notifications/NotificationsManager.ts b/src/notifications/NotificationsManager.ts index e2569d4eaf..8e6e0f5412 100644 --- a/src/notifications/NotificationsManager.ts +++ b/src/notifications/NotificationsManager.ts @@ -210,7 +210,7 @@ class NotificationsManager { // Only keep the message if the sending node has the correct permissions if (Object.keys(nodePerms.gestalt).includes('notify')) { // If the number stored in notificationsDb >= 10000 - let numMessages = await tran.get(messageCountPath); + let numMessages = await tran.getForUpdate(messageCountPath); if (numMessages === undefined) { numMessages = 0; await tran.put(messageCountPath, 0); @@ -315,7 +315,7 @@ class NotificationsManager { await tran.lock(messageCountPath.toString()); const notificationIds = await this.getNotificationIds('all', tran); - const numMessages = await tran.get(messageCountPath); + const numMessages = await tran.getForUpdate(messageCountPath); if (numMessages !== undefined) { for (const id of notificationIds) { await this.removeNotification(id, tran); @@ -399,7 +399,11 @@ class NotificationsManager { messageId: NotificationId, tran: DBTransaction, ): Promise { - const numMessages = await tran.get([ + await tran.lock([ + ...this.notificationsDbPath, + MESSAGE_COUNT_KEY, + ].toString()); + const numMessages = await tran.getForUpdate([ ...this.notificationsDbPath, MESSAGE_COUNT_KEY, ]);