Skip to content

Commit

Permalink
Randomize order of orphaned data recovery (#3917)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoilie committed Sep 22, 2022
1 parent 56ab786 commit 64b1889
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Expand Up @@ -236,7 +236,7 @@ const _batchIssueReqsToRecoverOrphanedData = async (
i < numWalletsWithOrphanedData;
i += ORPHANED_DATA_NUM_USERS_TO_RECOVER_PER_BATCH
) {
const walletsWithOrphanedData = await redisClient.spop(
const walletsWithOrphanedData = await redisClient.srandmember(
WALLETS_ORPHANED_KEY,
ORPHANED_DATA_NUM_USERS_TO_RECOVER_PER_BATCH
)
Expand All @@ -262,6 +262,7 @@ const _batchIssueReqsToRecoverOrphanedData = async (
}
})
requestsIssued++
await redisClient.srem(WALLETS_ORPHANED_KEY, wallet)
} catch (e: any) {
logger.error(
`Error issuing request to recover orphaned data: ${e.message}`
Expand All @@ -271,9 +272,7 @@ const _batchIssueReqsToRecoverOrphanedData = async (

const elapsedMs = Date.now() - start
logger.info(
`Issued /merge_primary_and_secondary requests for ${
i + numWalletsWithOrphanedData
}/${numWalletsWithOrphanedData} wallets.
`Issued /merge_primary_and_secondary requests for ${requestsIssued}/${numWalletsWithOrphanedData} wallets.
Time elapsed: ${elapsedMs}/${MAX_MS_TO_ISSUE_RECOVER_ORPHANED_DATA_REQUESTS}`
)
if (elapsedMs >= MAX_MS_TO_ISSUE_RECOVER_ORPHANED_DATA_REQUESTS) {
Expand Down
4 changes: 2 additions & 2 deletions creator-node/test/recoverOrphanedData.jobProcessor.test.ts
Expand Up @@ -107,7 +107,7 @@ describe('test recoverOrphanedData job processor', function () {
}
}

orphanedUsers.forEach((orphanedUser) => {
for (const orphanedUser of orphanedUsers) {
// Mock fetching the primary endpoint for each orphaned user
nock(DISCOVERY_NODE_ENDPOINT)
.get('/users')
Expand All @@ -129,7 +129,7 @@ describe('test recoverOrphanedData job processor', function () {
forceWipe: true
})
.reply(200)
})
}

return proxyquire(
'../src/services/stateMachineManager/stateReconciliation/recoverOrphanedData.jobProcessor.ts',
Expand Down

0 comments on commit 64b1889

Please sign in to comment.