Fix scenario where sync worker is re-assigned the same account before fully releasing it

This commit is contained in:
Ben Gotow 2016-07-12 18:31:55 -07:00
parent 3e8623d383
commit e89975456b
2 changed files with 3 additions and 1 deletions

View file

@ -194,13 +194,14 @@ class SyncProcessManager {
const dst = ACCOUNTS_UNCLAIMED;
return PubsubConnector.broadcastClient().lremAsync(src, 1, accountId).then((didRemove) => {
this._workers[accountId] = null;
if (didRemove) {
PubsubConnector.broadcastClient().rpushAsync(dst, accountId)
} else {
this._logger.error("Wanted to return item to pool, but didn't have claim on it.")
return
}
this._workers[accountId] = null;
});
}
}

View file

@ -225,6 +225,7 @@ class SyncWorker {
this._account.lastSyncCompletions = lastSyncCompletions
this._account.save()
this._logger.info('Syncworker: Completed sync cycle')
if (afterSync === 'idle') {