Skip to content

Close the active segment before compaction removes source segments - #6

Open
mclueppers wants to merge 1 commit into
attermann:masterfrom
dobrevit:fix/close-active-segment-before-compaction
Open

Close the active segment before compaction removes source segments#6
mclueppers wants to merge 1 commit into
attermann:masterfrom
dobrevit:fix/close-active-segment-before-compaction

Conversation

@mclueppers

Copy link
Copy Markdown

compact() deletes every source segment, including the one currently open for appends. LittleFS and FatFS refuse to unlink an open file, so on those filesystems the active segment survived compaction ("Failed to unlink ... Has open FD") and on POSIX-like filesystems the handle silently kept writing into an unlinked inode.

Close the active file before phase 1 and reopen a segment on both exit paths: seg0 after a successful compaction (the internal callers then move on to seg1 as before), current_segment after a failed one, so a direct compact() call never leaves the store without a writable segment.

Adds test_file_store_compact_keeps_store_writable, which fails on master (the record written after compact() is lost on reload) and passes here.

compact() deletes every source segment, including the one currently open
for appends. LittleFS and FatFS refuse to unlink an open file, so on those
filesystems the active segment survived compaction ("Failed to unlink ...
Has open FD") and on POSIX-like filesystems the handle silently kept
writing into an unlinked inode.

Close the active file before phase 1 and reopen a segment on both exit
paths: seg0 after a successful compaction (the internal callers then move
on to seg1 as before), current_segment after a failed one, so a direct
compact() call never leaves the store without a writable segment.

Adds test_file_store_compact_keeps_store_writable, which fails on master
(the record written after compact() is lost on reload) and passes here.
mclueppers added a commit to dobrevit/RetiMesh_Node that referenced this pull request Aug 26, 2026
The upstream fixes are now PRs (attermann/microReticulum#82 and #85,
attermann/microStore#6) and live on our forks, so the default build pulls
dobrevit/microReticulum#retimesh/combined and
dobrevit/microStore#fix/close-active-segment-before-compaction from git
and relies on the new APIs unconditionally:

- Reticulum::jobs_interval(1.0f) replaces the manual Transport::jobs()
  call in the RNS task,
- the packet-carrying AnnounceHandler callback replaces the firmware's
  own announce parser/verifier (RetiTransportServer::noteAnnounce), which
  is removed; the SD-card announce log line moves to the handler.

RETIMESH_UPSTREAM_FIXES and [env:t3s3-upstream] are gone; [env:t3s3-local]
builds against sibling checkouts for library development.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant