Skip to content

fix(journal): preserve archives when rolls share a timestamp - #521

Merged
singaraiona merged 1 commit into
RayforceDB:devfrom
belowzeroff:fix/journal-roll-archive-collision
Sep 13, 2026
Merged

singaraiona merged 1 commit into
RayforceDB:devfrom
belowzeroff:fix/journal-roll-archive-collision

Conversation

@belowzeroff

Copy link
Copy Markdown
Contributor

How it looks from the user's side

A service rolls its journal twice during the same UTC second.

Before - both rolls target the same base.YYYY.MM.DDTHH.MM.SSZ.log path, so the second roll replaces the first archive and its journal entries are lost.

After - the first archive keeps the timestamped name and subsequent collisions use unique names such as base.YYYY.MM.DDTHH.MM.SSZ.1.log, preserving every segment.

Root cause

ray_journal_roll generated archive names with second-level precision and passed them to rename(), which replaces an existing destination.

Fix

Probe the timestamped archive path before closing the journal. If it already exists, append an incrementing numeric suffix until an unused path is found.

Tests

  • ./rayforce.test --filter journal/roll_twice
  • make test with the repository's non-ASAN debug flags
  • Result: 3779 of 3780 passed, 1 skipped, 0 failed

@singaraiona
singaraiona merged commit 932e6e7 into RayforceDB:dev Sep 13, 2026
9 checks passed
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.

2 participants