From 01bb3a30f2162313f714061f81489953d1dd03d8 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Wed, 8 Mar 2017 11:27:29 -0800 Subject: [PATCH] Fix handling around size of batches of mapreduce entities to process ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=149562105 --- java/google/registry/batch/MapreduceEntityCleanupAction.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/google/registry/batch/MapreduceEntityCleanupAction.java b/java/google/registry/batch/MapreduceEntityCleanupAction.java index df71c7ad4..7cbbc258d 100644 --- a/java/google/registry/batch/MapreduceEntityCleanupAction.java +++ b/java/google/registry/batch/MapreduceEntityCleanupAction.java @@ -172,9 +172,12 @@ public class MapreduceEntityCleanupAction implements Runnable { DateTime cutoffDate = clock.nowUtc().minusDays(defaultedDaysOld); Optional cursor = Optional.absent(); do { + Optional numJobsToRequest = + Optional.fromNullable( + numJobsToDelete.isPresent() ? numJobsToDelete.get() - numJobsProcessed : null); EligibleJobResults batch = mapreduceEntityCleanupUtil.findEligibleJobsByJobName( - jobName.orNull(), cutoffDate, numJobsToDelete, force.or(false), cursor); + jobName.orNull(), cutoffDate, numJobsToRequest, force.or(false), cursor); cursor = batch.cursor(); // Individual batches can come back empty if none of the returned jobs meet the requirements // or if all jobs have been exhausted.