diff options
| author | tv <tv@krebsco.de> | 2026-12-01 13:34:08 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 13:34:08 +0000 |
| commit | 248917c32c536d67241d8445ab37f9f9af3142c8 (patch) | |
| tree | cf4d218a499f9626378722c6f57253a722c5d677 /pkgs/populate/src/run.rs | |
| parent | a658ecba09821b0306e287c1c6691dd4804d74db (diff) | |
populate: the lock's command takes the rest of the journal
Journal entries go to the target with the next command populate runs
there. A run that failed after noting an entry, but before another
command, e.g. at a source delivered on the deploying machine, like a
pipe source, lost it, so the next record could miss that the source
began to change. The command holding the lock appends the lines of its
input to the journal, and unlock gives it the entries no command took
yet, before ending its input. The record scenario checks that a run
failing at a pipe source leaves the source's begin in the journal.
Diffstat (limited to 'pkgs/populate/src/run.rs')
| -rw-r--r-- | pkgs/populate/src/run.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pkgs/populate/src/run.rs b/pkgs/populate/src/run.rs index bdff78f..9ef60f1 100644 --- a/pkgs/populate/src/run.rs +++ b/pkgs/populate/src/run.rs @@ -387,10 +387,20 @@ impl Context { } /// Releases the lock: the input of the command holding it ending ends - /// the command. + /// the command. Before, the command gets the journal's entries that no + /// command took to the target yet, e.g. of a run that failed, which it + /// appends to the journal. pub fn unlock(&self) { if let Some((mut child, _)) = self.lock.borrow_mut().take() { - drop(child.stdin.take()); + if let Some(mut stdin) = child.stdin.take() { + let (entries, flushed) = &mut *self.entries.borrow_mut(); + let lines: String = entries[*flushed..] + .iter() + .map(|entry| format!("{entry}\n")) + .collect(); + *flushed = entries.len(); + let _ = stdin.write_all(lines.as_bytes()); + } let _ = child.wait(); } } |
