Repository navigation
fix(store): one O_APPEND write per append (closes #23) - #25
Merged
Merged
Conversation
…ger lose rows appendLog was read-modify-write with an await between read and write: 20 concurrent appends to one file left 2 rows on disk (issue #23 probe). node:fs/promises appendFile uses the 'a' flag (O_APPEND|O_CREAT), atomic for small writes on local POSIX filesystems — covering both interleaved async tasks in the service and the viewer as a second writer. Note for the future: do NOT convert this back to Bun.write with an options object — on Bun 1.4.3 the append option silently truncates.
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.
Closes #23. Regression test (
store rows cannot be forged through contentintest/logfmt.test.ts): 50 concurrentappendLogcalls must all survive. Onmainthe same storm leaves ~2 rows (review probe: 20 attempted → 2 survived); the newconcurrent appends lose nothingtest fails there and passes here.One behavioral note baked into the comment: the fix deliberately uses
node:fs/promises.appendFilerather thanBun.write(file, line, { append: true })— measured on Bun 1.4.3, the Bun option silently truncates instead of appending (verified: "A" then append "B" leaves "B").appendFile'saflag is O_APPEND|O_CREAT — atomic small writes on local POSIX filesystems, so the viewer process and the service can both append the same day file.Full gate on this branch: 195 tests / 0 fail,
tsc --noEmitclean.