Skip to content

os/bluestore: Revival no.2 of _deferred_replay fix - #69961

Merged
ifed01 merged 9 commits into
ceph:mainfrom
aclamk:wip-aclamk-more-deferred-overwrite-fix-redo
Nov 3, 2026
Merged

ifed01 merged 9 commits into
ceph:mainfrom
aclamk:wip-aclamk-more-deferred-overwrite-fix-redo

Conversation

@aclamk

@aclamk aclamk commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

This PR is a revival of #62412
The difference is that previously elusive problem with RocksDB data revival is now solved.

Fixes known problems with deferred write replay.
Based on unittest for deferred writes #60732
Fixes: https://tracker.ceph.com/issues/68060

Includes observation from https://tracker.ceph.com/issues/70581

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Comment thread src/os/bluestore/BlueStore.cc Resolved
@aclamk
aclamk force-pushed the wip-aclamk-more-deferred-overwrite-fix-redo branch from 3b9a42d to 0e9468d Compare July 7, 2026 08:41
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Added debug hooks for:
- init_alloc
- deferred start/stop/operation

This created framework for specific unit tests.
These functions are as name suggests debug level, only for unittests.

Signed-off-by: Adam Kupczyk <[email protected]>
Two possible cases of deferred write related corruption are replicated.
1. The case when L entries remain.
2. The case when deferred overwrites newly created BlueFS files

Provides unittest for:
https://tracker.ceph.com/issues/68060

Signed-off-by: Adam Kupczyk <[email protected]>
Modify _deferred_replay to execute it directly, without involving
BlueStore state machine.
In result, kv-sync thread is not necessary.
RocksDB L entries (deferred writes) are removed directly.

Fixes: https://tracker.ceph.com/issues/68060,
  part responsible for stale L entries.

Signed-off-by: Adam Kupczyk <[email protected]>
Modify _deferred_replay to separate:
- applying IO to the disk
- DB transaction to remove keys

Changed _open_db_and_around. It now calls _deferred_replay.
Adapted callers, including fsck.

Fixed: https://tracker.ceph.com/issues/68060, original report.

Signed-off-by: Adam Kupczyk <[email protected]>
Add code to print times; this is for make check arm64.

Signed-off-by: Adam Kupczyk <[email protected]>
This fixes wierd key revalval after deletion.

Signed-off-by: Adam Kupczyk <[email protected]>
@aclamk
aclamk force-pushed the wip-aclamk-more-deferred-overwrite-fix-redo branch from 0e9468d to 3b489c0 Compare September 11, 2026 10:10
Comment thread src/os/bluestore/BlueStore.cc Outdated
_post_init_alloc();
}

if (remove_deferred && !keys_to_remove.empty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO check for remove_deferred is redundant here

Comment thread src/os/bluestore/BlueStore.cc Outdated
// This is the place where we can apply deferred writes
// without risk of some interaction with RocksDB allocating.
if (apply_deferred) {
_deferred_replay(remove_deferred ? &keys_to_remove : nullptr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One can collect keys_to_remove directly into DB transaction here. No need in intermediated vector.

}
dout(1) << __func__ << " opened " << kv_backend
<< " path " << kv_dir_fn << " options " << options << dendl;
KeyValueDB::Iterator it = db->get_iterator(PREFIX_DEFERRED);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO all this enumerating/printing stuff worth putting under if (cct->_conf->subsys.should_gather<ceph_subsys_bluestore, 10>())

Comment thread src/os/bluestore/BlueStore.cc Resolved
@aclamk

aclamk commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

@ifed01

  1. Simplified params to _open_db_and_around()
  2. Added replaying deferred to mount_readonly

Also considered adding replaying deferred to fsck(read-only), but dropped it.

Changes:
- For mount_readonly perform replay of deferred writes, no L keys
  deletion. This is to make sure ceph-objectstore-tool pg-export
  returns proper object data.
- mount_readonly() / umount_readonly() no longer init/close kv_sync_thread.
- Simplify _open_db_and_around().
  Two arguments apply_deferred, remove_deferred -> single replay_deferred.

Signed-off-by: Adam Kupczyk <[email protected]>
@aclamk
aclamk force-pushed the wip-aclamk-more-deferred-overwrite-fix-redo branch from 434c69b to 75f5654 Compare September 25, 2026 13:35
dcasier added a commit to dcasier/ceph that referenced this pull request Oct 24, 2026
_deferred_replay() drops the parts of a deferred transaction that overlap
BlueFS (_eliminate_outdated_deferred). When all of them are dropped, the
record's key stays in the DB and is evaluated again at every mount. Once
BlueFS has released that space and BlueStore has allocated it to an
object, the stale record is replayed over object data (bad crc32c,
read_error on deep-scrub).

Remove the keys of fully dropped records once the replay IO has drained.
Their data is stale: BlueFS only takes free space.

This is a fallback for PR ceph#69961, which replays deferred writes before
the DB is opened read-write and makes this change unnecessary: revert it
if that PR lands. Not covered: BlueFS allocations during the replay, and
records left by earlier mounts.

Refs: https://tracker.ceph.com/issues/68060
Refs: ceph#69961
Signed-off-by: David Casier <[email protected]>
Assisted-by: Claude Code
dcasier added a commit to dcasier/ceph that referenced this pull request Oct 24, 2026
_deferred_replay() drops the parts of a deferred transaction that overlap
BlueFS (_eliminate_outdated_deferred). When all of them are dropped, the
record's key stays in the DB and is evaluated again at every mount. Once
BlueFS has released that space and BlueStore has allocated it to an
object, the stale record is replayed over object data (bad crc32c,
read_error on deep-scrub).

Remove the keys of fully dropped records once the replay IO has drained.
Their data is stale: BlueFS only takes free space.

This is a fallback for PR ceph#69961, which replays deferred writes before
the DB is opened read-write and makes this change unnecessary: revert it
if that PR lands. Not covered: BlueFS allocations during the replay, and
records left by earlier mounts.

Fixes: https://tracker.ceph.com/issues/68060
Fixes: 2afb951
Signed-off-by: David Casier <[email protected]>
Assisted-by: Claude Code
dcasier added a commit to dcasier/ceph that referenced this pull request Oct 24, 2026
_deferred_replay() drops the parts of a deferred transaction that
overlap BlueFS (_eliminate_outdated_deferred). When all of them are
dropped, the record's key stays in the DB and is evaluated again at
every mount. Once BlueFS has released that space and BlueStore has
allocated it to an object, the stale record is replayed over object data
(bad crc32c, read_error on deep-scrub).

Remove the keys of fully dropped records once the replay IO has drained.
Their data is stale: BlueFS only takes free space.

Use rmkey(), not rm_single_key(): deferred_seq restarts at 0 on each
start, so a key that survived earlier mounts may have been set again,
and rm_single_key() is undefined on a key set more than once.

This is a fallback for PR ceph#69961, which replays deferred writes before
the DB is opened read-write and makes this change unnecessary: revert it
if that PR lands. Not covered: BlueFS allocations during the replay, and
records left by earlier mounts.

Fixes: https://tracker.ceph.com/issues/68060
Fixes: 2afb951
Signed-off-by: David Casier <[email protected]>
Assisted-by: Claude Code
@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

This PR has been added to wip-jaya-bs-testing-10-27-2026.

@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants