Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont reissue manual syncs + separate manual sync timeout #3572

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion creator-node/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,17 @@ const config = convict({
default: 20
},
maxSyncMonitoringDurationInMs: {
doc: 'Max duration that primary will monitor secondary for syncRequest completion',
doc: 'Max duration that primary will monitor secondary for syncRequest completion for non-manual syncs',
format: 'nat',
env: 'maxSyncMonitoringDurationInMs',
default: 300000 // 5min (prod default)
},
maxManualSyncMonitoringDurationInMs: {
doc: 'Max duration that primary will monitor secondary for syncRequest completion for manual syncs',
format: 'nat',
env: 'maxManualSyncMonitoringDurationInMs',
default: 45000 // 45 sec (prod default)
},
syncRequestMaxUserFailureCountBeforeSkip: {
doc: '[on Secondary] Max number of failed syncs per user before skipping un-retrieved content, saving to db, and succeeding sync',
format: 'nat',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const secondaryUserSyncDailyFailureCountThreshold = config.get(
const maxSyncMonitoringDurationInMs = config.get(
'maxSyncMonitoringDurationInMs'
)
const maxManualSyncMonitoringDurationInMs = config.get(
'maxManualSyncMonitoringDurationInMs'
)
const mergePrimaryAndSecondaryEnabled = config.get(
'mergePrimaryAndSecondaryEnabled'
)
Expand Down Expand Up @@ -313,7 +316,11 @@ const _additionalSyncIsRequired = async (
const logMsgString = `additionalSyncIsRequired() (${syncType}): wallet ${userWallet} secondary ${secondaryUrl} primaryClock ${primaryClockValue}`

const startTimeMs = Date.now()
const maxMonitoringTimeMs = startTimeMs + maxSyncMonitoringDurationInMs
const maxMonitoringTimeMs =
startTimeMs +
(syncType === SyncType.MANUAL
? maxManualSyncMonitoringDurationInMs
: maxSyncMonitoringDurationInMs)

/**
* Poll secondary for sync completion, up to `maxMonitoringTimeMs`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,35 +140,9 @@ const issueSyncRequestsUntilSynced = async (
// If secondary is synced, return successfully
if (secondaryClockVal >= primaryClockVal) {
return

// Else, if a sync is not already in progress on the secondary, issue a new SyncRequest
} else if (!syncInProgress) {
const { duplicateSyncReq, syncReqToEnqueue } = getNewOrExistingSyncReq({
userWallet: wallet,
secondaryEndpoint: secondaryUrl,
primaryEndpoint: primaryUrl,
syncType: SyncType.Manual,
syncMode: SYNC_MODES.SyncSecondaryFromPrimary
})
if (!_.isEmpty(duplicateSyncReq)) {
// Log duplicate and return
logger.warn(`Duplicate sync request: ${duplicateSyncReq}`)
return
} else if (!_.isEmpty(syncReqToEnqueue)) {
await queue.add({
enqueuedBy: 'issueSyncRequestsUntilSynced retry',
...syncReqToEnqueue
})
} else {
// Log error that the sync request couldn't be created and return
logger.error(
`Failed to create manual sync request: ${duplicateSyncReq}`
)
return
}
}

// Give secondary some time to process ongoing or newly enqueued sync
// Give secondary some time to process ongoing sync
// NOTE - we might want to make this timeout longer
await Utils.timeout(500)
} catch (e) {
Expand Down