Flush state data for a target before printing meta('do') for it.

Extremely rarely, if that target had not yet previously been added to
the redo database, redo-log would manage to run before the database got
flushed, and then it would complain that the file is "not known to
redo" and abort.

I had to run "git clean -fdx; redo -j11 test" in a loop several hundred
times before this race condition triggered, but it did trigger eventually.
This commit is contained in:
Avery Pennarun 2018-11-21 19:21:02 -05:00
commit 637f63423a

View file

@ -200,7 +200,6 @@ class BuildJob:
# make sure to create the logfile *before* writing the log about it.
# that way redo-log won't trace into an obsolete logfile.
if vars.LOG: open(state.logname(self.sf.id), 'w')
meta('do', state.target_relpath(t))
self.dodir = dodir
self.basename = basename
self.ext = ext
@ -211,6 +210,7 @@ class BuildJob:
dof.set_static()
dof.save()
state.commit()
meta('do', state.target_relpath(t))
jwack.start_job(t, self._do_subproc, self._after)
def _start_unlocked(self, dirty):