Store v2: Wait for fsyncs submitted by other operations before completing a sync #107

Open
koolkhel wants to merge 1 commits from koolkhel/vitastor:v2-chaos-105267292 into master
Contributor

Description

do_sync() returned at once when nothing was left unsynced, but these counters are reset when an fsync is submitted, not when it completes. So a stabilize or rollback whose metadata block was written before another operation submitted its fsync completed before that fsync did, and a power outage could undo it: test_blockstore_chaos --seed 105267292 sees a rolled back version come back.

Wait until everything completed is fsynced instead. A waiting sync still counts as unfinished, so that the next one doesn't overtake it and have its pending fsyncs reset.

Tested:

  • test_blockstore: new test_rollback_waits_for_inflight_fsync (fails on master, the rollback completes while the fsync is held)
  • test_blockstore_chaos --seed 105267292 passes
  • test_blockstore_chaos: the default 200-seed sweep, and earlier 1200 seeds (--seeds 1-48 --random 1152), all pass

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description `do_sync()` returned at once when nothing was left unsynced, but these counters are reset when an fsync is submitted, not when it completes. So a stabilize or rollback whose metadata block was written before another operation submitted its fsync completed before that fsync did, and a power outage could undo it: `test_blockstore_chaos --seed 105267292` sees a rolled back version come back. Wait until everything completed is fsynced instead. A waiting sync still counts as unfinished, so that the next one doesn't overtake it and have its pending fsyncs reset. Tested: - `test_blockstore`: new `test_rollback_waits_for_inflight_fsync` (fails on master, the rollback completes while the fsync is held) - `test_blockstore_chaos --seed 105267292` passes - `test_blockstore_chaos`: the default 200-seed sweep, and earlier 1200 seeds (`--seeds 1-48 --random 1152`), all pass ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-10-26 21:02:34 +03:00
do_sync() returned at once when nothing was left unsynced, but these
counters are reset when an fsync is submitted, not when it completes. So
a stabilize or rollback whose metadata block was written before another
operation submitted its fsync completed before that fsync did, and a
power outage could undo it: test_blockstore_chaos --seed 105267292 sees
a rolled back version come back.

Wait until everything completed is fsynced instead. A waiting sync still
counts as unfinished, so that the next one doesn't overtake it and have
its pending fsyncs reset.
vitalif reviewed 2026-10-27 00:30:40 +03:00
@@ -107,6 +107,16 @@ int blockstore_impl_t::do_sync(blockstore_op_t *op, int base_state)
}
if (!has_unsynced())
{
if ((!dsk.disable_meta_fsync || !dsk.disable_journal_fsync) &&
Owner

тут точно обе правки нужны? выглядит как будто то ли два разных кейса поправлено, то ли один, но двумя способами. верхней правки не хватит ли?

тут точно обе правки нужны? выглядит как будто то ли два разных кейса поправлено, то ли один, но двумя способами. верхней правки не хватит ли?
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u v2-chaos-105267292:koolkhel-v2-chaos-105267292
git checkout koolkhel-v2-chaos-105267292
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#107
No description provided.