mononoke: hg-sync-job: gracefully exit even without work

Summary:
Checking for our exit condition after pulling a new piece of work from the buffer is good because it means we exit without doing any of the work we buffered (i.e. we'll exit quickly)

However, that approach does means that a piece of work has to go through the stream all the way to the sync step before we decide to drop it and stop the stream.

If there is not work, this means we might take a while to exit! On paper, this is fine because if there is no work, then it's OK to just take our time to exit ... but it might be a little confusing from an operator perspective.

This patch fixes that problem by checking our exit condiiton after every no-op iteration as well.

 ---

It's worth noting that both checks are indeed required if we want to exit quickly regardless of whether we are very busy or completely idle.

Reviewed By: ikostia

Differential Revision: D15270517

fbshipit-source-id: 06c3b100ccbf69191ac67691a2991086596a15c0
This commit is contained in:
Thomas Orozco 2019-05-09 11:21:44 -07:00 committed by Facebook Github Bot
parent 2cf7a2aaf9
commit 25d48bbbd6

View File

@ -707,6 +707,4 @@ Test the job exits when the exit file is set
$ cd $TESTTMP
$ mononoke_hg_sync_loop repo-hg-3 8 --exit-file $TESTTMP/exit-file
* using repo "repo" repoid RepositoryId(0) (glob)
* preparing log entry #10 ... (glob)
* successful prepare of entry #10 (glob)
* path "$TESTTMP/exit-file" exists: exiting ... (glob)