Skip to content

fix: make durability fsync portable on Windows - #222

Merged
khaira777 merged 1 commit into
mainfrom
fix/windows-fsync
Aug 9, 2026
Merged

khaira777 merged 1 commit into
mainfrom
fix/windows-fsync

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Problem

The post-merge Full Cross-Platform Matrix failed only on Windows during the smoke test. fs.fsyncSync() was called on a read-only (r) file descriptor and Windows returned EPERM while creating the pre-migration backup.

Fix

Open application-owned database, journal, and backup files with r+ before fsync. This preserves the fail-closed durability check and avoids weakening recovery guarantees.

Verification

  • npm run build
  • npm run test:backup
  • npm run test:recovery-cloud
  • tests/smoke-test.test.ts
  • GitHub Windows matrix validation pending

This is a follow-up to merged PR #217 and should be reviewed independently. It addresses the Windows CI failure at run https://github.com/FreeOpenSourcePOS/FloCafe/actions/runs/31290095061.

Windows rejects fsync on read-only database and journal handles with EPERM. Open application-owned durability targets read-write before flushing them so pre-migration backups and replacement journals work on Windows without weakening the fail-closed durability check.
@khaira777
khaira777 requested a review from itsbkm as a code owner August 9, 2026 02:42
@khaira777

Copy link
Copy Markdown
Contributor Author

Manual full cross-platform validation completed: workflow run 31291071323 passed on Windows, Ubuntu, macOS x64, and macOS arm64. The original post-merge failure was Windows-only fsyncSync() on a read-only handle (EPERM). No redundant retry commits were added; this PR contains the single targeted writable-handle fix.

@khaira777

Copy link
Copy Markdown
Contributor Author

Final validation

Confirmed locally on 1beaa8d:

  • npm run build
  • npm run test:backup
  • npm run test:recovery-cloud
  • Electron smoke test

Online PR checks are all green. The manually dispatched full cross-platform matrix (run 31291071323) also passed on Windows, Ubuntu, macOS x64, and macOS ARM64. The original failure was Windows EPERM from fsyncing a read-only handle; this PR contains the single targeted r+ handle fix.

@khaira777
khaira777 merged commit e341d44 into main Aug 9, 2026
9 checks passed
@khaira777
khaira777 deleted the fix/windows-fsync branch August 9, 2026 03:09
khaira777 added a commit that referenced this pull request Aug 9, 2026
Make the database maintenance concurrency regression test deterministic across platforms.

The Windows full cross-platform matrix exposed a race where the test relied on a 1ms delay to assume a maintenance lock had started. The request could arrive before the lock became active and incorrectly receive 200 instead of 503.

This test-only change waits for the existing maintenance-start listener signal before issuing the concurrent request, then unregisters the listener during cleanup.

Verification:
- npm run build
- maintenance-lock test passed
- 20 repeated maintenance-lock runs passed
- All PR checks passed

This restores deterministic full-suite behavior after the Windows follow-up in PR #222.
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