Fix for _PushStatus Stuck 'running' when Count is Off (#4319)

* Fix for _PushStatus stuck 'running' if count is off

* use 'count' for batches

* push worker test fix
This commit is contained in:
Benjamin Wilson Friedman
2017-11-05 10:04:46 -08:00
committed by Florent Vilmart
parent 842343a1a9
commit c1a7347143
5 changed files with 276 additions and 9 deletions

View File

@@ -190,10 +190,18 @@ export function pushStatusHandler(config, existingObjectId) {
});
}
const setRunning = function(count) {
logger.verbose(`_PushStatus ${objectId}: sending push to %d installations`, count);
return handler.update({status:"pending", objectId: objectId},
{status: "running", count });
const setRunning = function(batches) {
logger.verbose(`_PushStatus ${objectId}: sending push to installations with %d batches`, batches);
return handler.update(
{
status:"pending",
objectId: objectId
},
{
status: "running",
count: batches
}
);
}
const trackSent = function(results, UTCOffset, cleanupInstallations = process.env.PARSE_SERVER_CLEANUP_INVALID_INSTALLATIONS) {
@@ -235,7 +243,6 @@ export function pushStatusHandler(config, existingObjectId) {
}
return memo;
}, update);
incrementOp(update, 'count', -results.length);
}
logger.verbose(`_PushStatus ${objectId}: sent push! %d success, %d failures`, update.numSent, update.numFailed);
@@ -259,6 +266,9 @@ export function pushStatusHandler(config, existingObjectId) {
});
}
// indicate this batch is complete
incrementOp(update, 'count', -1);
return handler.update({ objectId }, update).then((res) => {
if (res && res.count === 0) {
return this.complete();