This is an archive of the discontinued Mercurial Phabricator instance.

remotefilelog: add a developer option to wait for background processes
ClosedPublic

Authored by marmoute on Dec 9 2019, 8:02 AM.

Details

Summary

In order to block the main command on the subprocess exiting, we ensure the
repo's ui object will call the subprocess.wait() method to ensure the top-level
hg process doesn't exit until all background processes have also done so.

Currently, in the tests, most operation spawning background process as followed
by commands waiting for these operations to complete. However this waiting is
racy. First because it seems like we can start waiting before the background
operation actually start, in which case it is prematurely detected as "done".
Second, because some commands may spawn multiple background operation for the
same operation (eg: rebase can apparently trigger multiple prefetch). The
current approach could be updated to maybe handle the first issue, but the
second one will never be properly handled.

In most case, we do not care that the bg process keep running after the command
end. (Since we explicitly wait for them to end before doing anything else). So
we add an option to wait on the background process before exiting the command.
We'll put it in use in the next changeset.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

marmoute created this revision.Dec 9 2019, 8:02 AM

target is the stable-branch

durin42 added inline comments.
hgext/remotefilelog/shallowrepo.py
237

It took me some very careful reasoning to figure this out. Could you amend the log message to include something like the following?

In order to block on the subprocess exiting, we ensure the repo's ui object will call the subprocess.wait() method to ensure the top-level hg process doesn't exit until all background processes have also done so.

Maybe it's just I didn't have tea this morning, but this cost me a pretty decent chunk of review time.

marmoute edited the summary of this revision. (Show Details)Dec 9 2019, 10:51 AM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.