platform: use F_FULLSYNC on macOS for SyncFile data durability, fixes #9383#9385
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9385 +/- ##
==========================================
- Coverage 76.44% 76.43% -0.01%
==========================================
Files 85 85
Lines 14799 14800 +1
Branches 2212 2212
==========================================
Hits 11313 11313
- Misses 2808 2809 +1
Partials 678 678 ☔ View full report in Codecov by Sentry. |
|
For performance reasons, we don't do macOS tests for PRs, so we have to check this when it is merged. Also a backport to 1.4-maint is likely needed. |
sure and shall I prepare the backport PR for 1.4-maint now or after this is merged to master? |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 1.4-maint
git worktree add -d .worktree/backport-9385-to-1.4-maint origin/1.4-maint
cd .worktree/backport-9385-to-1.4-maint
git switch --create backport-9385-to-1.4-maint
git cherry-pick -x 0354697c56e4ea047b4ca6550622fab5e5e505f4 |
|
Wait until the macOS tests there are finished and successful: |
SyncFile.sync()callsplatform.fdatasync(self.fd), which resolves toos.fdatasyncoros.fsync- On macOS,fsync()only flushes data to the drive's write cache, not to persistent storagefcntl(fd, F_FULLFSYNC)— without it, a power loss could lose data thatSyncFilebelieved was safely persistedsrc/borg/platform/base.py:154:TODO: Use F_FULLSYNC on macOS.Fixes platform: use F_FULLSYNC on macOS for SyncFile data durability #9383
Changes
src/borg/platform/darwin.pyxfdatasync()usingfcntl F_FULLFSYNCwithos.fsync()fallback; addsync_dir()using the samesrc/borg/platform/__init__.pyfdatasync,sync_dirfrom.darwinin the darwin blocksrc/borg/platform/base.pysrc/borg/testsuite/platform/darwin_test.pyChecklist
master