Skip to content

Commit

Permalink
Also delete records on secondary on fkey constraint error (#1638)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmanjunath committed Jul 12, 2021
1 parent 14eded5 commit 852e682
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions creator-node/src/services/sync/processSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,12 @@ async function processSync (serviceRegistry, walletPublicKeys, creatorNodeEndpoi

await SyncHistoryAggregator.recordSyncSuccess()
} catch (e) {
// two conditions where we wipe the state on the secondary
// if the clock values somehow becomes corrupted, wipe the records before future re-syncs
if (e.message.includes('Can only insert contiguous clock values')) {
// if the secondary gets into a weird state with constraints, wipe the records before future re-syncs
if (e.message.includes('Can only insert contiguous clock values') || e.message.includes('SequelizeForeignKeyConstraintError')) {
for (let wallet of walletPublicKeys) {
logger.error(`Sync error for ${wallet} - "Can only insert contiguous clock values". Clearing db state for wallet.`)
logger.error(`Sync error for ${wallet} - "${e.message}". Clearing db state for wallet.`)
await DBManager.deleteAllCNodeUserDataFromDB({ lookupWallet: wallet })
}
}
Expand Down

0 comments on commit 852e682

Please sign in to comment.