fix(journal): propagate purge close errors - #527
Merged
singaraiona merged 1 commit intoSep 14, 2026
Merged
Conversation
belowzeroff
force-pushed
the
fix/journal-purge-close-errors
branch
from
September 13, 2026 17:34
25ddd57 to
78c1713
Compare
singaraiona
approved these changes
Sep 13, 2026
singaraiona
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed against dev. The change is correct and I'd merge it.
.log.purgeused to callfflushandfcloseon the active journal, ignore both results, and then delete every journal file. A buffered write failing on the final flush (sayENOSPC) was silently dropped and the only copy of that data unlinked.- Delegating to
ray_journal_closefixes that in the right place: it already checks both results, maps a failure toRAY_ERR_IO, and nullsg_journal.fpeven on failure. Purge now returns before touching any file. Because the pointer is nulled either way, a retried purge cannot double-close, andg_journal.basesurvives the close, so a later purge still knows what to delete. Success-path behaviour is unchanged.
One thing to fix in the description before merging: "Fixes #60" points at a closed, unrelated segfault report (issue 60 is "SIGSEGV on try block"). Please drop that line or point it at the right issue, otherwise the merge annotates the wrong one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is wrong
.log.purgecloses the active journal before removing the journal footprint, but the old code discards both return values:If the final flush fails, for example because the filesystem reports
ENOSPCor another I/O error while buffered journal data is being written,ray_journal_purge()continues anyway. The active.log, snapshot, and rolled archives can then be deleted even though the last journal writes were never confirmed as durable.This is especially dangerous because purge is destructive: after it returns, the journal files may be gone and the failed buffered data may have been the only recoverable copy.
What changes
ray_journal_purge()now delegates closing toray_journal_close(), which already checks bothfflush()andfclose()and maps either failure toRAY_ERR_IO. On an error, purge returns immediately and leaves the journal files untouched. On success, it keeps the existing purge behavior and removes the complete journal footprint.Validation
./rayforce.test --filter journal/purge_: 3/3 passedmake test: compilation succeeded; 3647/3780 tests passed before the run was stopped after environment-dependent local-socket failures