Skip to content

Clean up stale .sync-state.json.tmp files left by a crashed writer #51

Description

@khaliqgant

Problem

#44 gave each sync-state writer a uniquely-named temp file (pid + process-local counter) so concurrent saves cannot interleave:

.sync-state.json.tmp.<pid>.<n>

save_sync_state removes the temp file when a save fails, but a process that is killed between the write and the rename leaves one behind. Because the names are unique, these accumulate rather than being overwritten — one file per crash, forever, in the database directory.

Low severity (small files, no correctness impact) but it is an unbounded leak, and the shared-name version it replaced did not have it.

Proposal

On startup or before saving, sweep .sync-state.json.tmp.* in the state directory and remove entries whose owning pid is no longer alive (or that are older than some threshold). Cheap: the directory holds a handful of files.

Related: #44

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions