Skip to content

crimson/os/alienstore: make CnLog::_flush non-blocking - #69838

Merged
ronen-fr merged 1 commit into
ceph:mainfrom
ronen-fr:wip-rf-322936
Jul 4, 2026
Merged

ronen-fr merged 1 commit into
ceph:mainfrom
ronen-fr:wip-rf-322936

Conversation

@ronen-fr

Copy link
Copy Markdown
Contributor

CnLog::_flush() calls alien::submit_to(...).wait(), which blocks the log flusher thread until the seastar reactor
finishes outputting the log entries. When the reactor writes to stderr and the pipe buffer is
full (e.g. two OSDs on the same host both dumping at debug level 20), the reactor itself blocks
on the write() syscall. Meanwhile BlueStore threads filling the log buffer past m_max_new block in
submit_entry() waiting for the flusher - which is waiting for the reactor - which is blocked on I/O.
The kv thread cannot fire commit callbacks while it is blocked on logging, so store transactions
(including osdmap persistence) hang indefinitely.

Fix by moving the entries into the lambda capture so _flush() can return immediately without waiting.

This is a corrected version of the approach in commit 511af83
("crimson/os/alienstore/alien_log: _flush concurrently", PR #55262), which was reverted in 4d52d1d
because its lambda captured the EntryVector by reference - the caller would clear/reuse the
vector before the lambda finished, causing a "pure virtual method called" crash
(https://tracker.ceph.com/issues/64140). The fix here avoids that by swapping the entries out of
the caller's vector and moving them into the lambda's capture, so the lambda owns them for their full lifetime.

Fixes: https://tracker.ceph.com/issues/77826
Fixes (failure of the 1st attempt): https://tracker.ceph.com/issues/64140

@ronen-fr
ronen-fr requested a review from a team as a code owner June 30, 2026 13:04
@ronen-fr
ronen-fr marked this pull request as draft June 30, 2026 18:10
Comment thread src/crimson/os/alienstore/alien_log.cc Resolved
@ronen-fr

ronen-fr commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Thank you, @tchaikov . Fixed.

@ronen-fr
ronen-fr requested review from Matan-B and tchaikov July 1, 2026 16:03
@ronen-fr
ronen-fr marked this pull request as ready for review July 1, 2026 16:03
@tchaikov

tchaikov commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

jenkins test make check

@tchaikov

tchaikov commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

jenkins test windows

CnLog::_flush() calls alien::submit_to(...).wait(), which blocks the
log flusher thread until the seastar reactor finishes outputting the
log entries. When the reactor writes to stderr and the pipe buffer is
full (e.g. two OSDs on the same host both dumping at debug level 20),
the reactor itself blocks on the write() syscall. Meanwhile BlueStore
threads filling the log buffer past m_max_new block in submit_entry()
waiting for the flusher - which is waiting for the reactor - which is
blocked on I/O. The kv thread cannot fire commit callbacks while it is
blocked on logging, so store transactions (including osdmap persistence)
hang indefinitely.

Fix by moving the entries into the lambda capture so _flush() can
return immediately without waiting.

This is a corrected version of the approach in commit 511af83
("crimson/os/alienstore/alien_log: _flush concurrently", PR ceph#55262),
which was reverted in 4d52d1d because its lambda captured the
EntryVector by reference - the caller would clear/reuse the vector
before the lambda finished, causing a "pure virtual method called"
crash (https://tracker.ceph.com/issues/64140). The fix here avoids
that by swapping the entries out of the caller's vector and moving
them into the lambda's capture, so the lambda owns them for their
full lifetime.

Fixes: https://tracker.ceph.com/issues/77826
Fixes (failure of the 1st attempt): https://tracker.ceph.com/issues/64140
Assisted-by: Claude <claude.ai>

Signed-off-by: Ronen Friedman <[email protected]>
@tchaikov

tchaikov commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@tchaikov

tchaikov commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

jenkins test windows

1 similar comment
@tchaikov

tchaikov commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

jenkins test windows

@perezjosibm perezjosibm left a comment

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.

LGTM, adding some comments from the LLM/copilot that look sensible to me, thanks

Here is a clear explanation of this change and its associated risks:


What the Change Does

This PR fixes a deadlock in Ceph's crimson object store. Specifically, it makes CnLog::_flush() non-blocking by removing the .wait() call on a seastar future.

The Deadlock Chain (Before the Fix)

The old code had this sequence that could deadlock:

CnLog::_flush()
  └─ alien::submit_to(...).wait()   ← blocks the log flusher thread
       └─ seastar reactor executes the lambda
            └─ writes log entries to stderr
                 └─ if the pipe buffer is full (e.g. two OSDs at log level 20)
                      └─ reactor blocks on write() syscall
                           └─ BlueStore threads pile up in submit_entry()
                                └─ kv thread can't fire commit callbacks
                                     └─ store transactions hang indefinitely

The Fix

Instead of .wait()-ing for the future, the entries are moved into the lambda's capture using std::move(q). This means _flush() returns immediately, and the lambda owns the entries for as long as it needs them:

// Before: blocks, then clears manually
seastar::alien::submit_to(inst, shard, [&q] { ... }).wait();
q.clear();

// After: non-blocking, lambda owns the data
std::ignore = seastar::alien::submit_to(inst, shard,
  [entries = std::move(q)] { ... });

Historical Context

This is a second attempt at a fix. A prior fix (PR #55262) was reverted because it captured q by reference — the caller would clear/reuse the vector before the lambda finished, causing a "pure virtual method called" crash (tracker issue #64140). This version avoids that by using std::move, transferring ownership to the lambda.


Potential Risks

Risk Severity Details
Log ordering Low–Medium Since _flush() no longer waits for the reactor to finish, log entries from consecutive flushes may be processed out of order on the seastar side. Under high load, log output may be interleaved or reordered. For debugging, this could be confusing.
Backpressure removal Medium The .wait() previously acted as implicit backpressure — it throttled the log flusher from queuing more work than the reactor could handle. Without it, a flood of log entries could queue up many pending futures on the reactor, potentially consuming significant memory.
std::ignore suppresses errors Low The returned future is explicitly discarded via std::ignore. Any exception thrown inside the lambda (e.g., from log()) will be silently dropped rather than propagated. The get_logger().log() path would need to be exception-safe for this to be truly safe.
Lambda lifetime and move semantics Low The fix correctly moves entries into the lambda. However, after _flush() returns, q (the caller's EntryVector) will be in a valid-but-empty moved-from state. Any caller code that assumes q is populated after _flush() would break — worth verifying no callers do this.
Crash scenario regression Medium The revert of PR #55262 was caused by a lifetime bug. This fix addresses that specific bug with std::move, but the non-blocking nature means failures in the lambda are now harder to observe — a regression to a crash would be more subtle to diagnose.

Recommended Scrutiny

  • Verify that no caller of _flush() reads from q after the call returns (since it's now moved-from).
  • Consider whether the lack of backpressure could be an issue under heavy debug logging scenarios (the exact scenario that triggers the original deadlock).
  • Consider adding a test or stress scenario that validates log entries are not lost when the reactor is under I/O pressure.

@tchaikov

tchaikov commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

jenkins test windows

@tchaikov tchaikov left a comment

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.

lgtm

@tchaikov tchaikov added this to Crimson Jul 3, 2026
@tchaikov tchaikov moved this to Needs QA in Crimson Jul 3, 2026
@ronen-fr

ronen-fr commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Merging based on my Teuthology tests.
Note - the same test that failed for the reason fixed here, was later failing for additional 3 reasons. I am working on fixes for those additional issues.

@ronen-fr
ronen-fr merged commit 40e8ea0 into ceph:main Jul 4, 2026
6 checks passed
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I found one or more Fixes: tags in the commit messages in

git log 40e8ea0c1bfb24a424f1e67144a689565252f50a^..40e8ea0c1bfb24a424f1e67144a689565252f50a

The referenced tickets are:

Those tickets do not reference this merged Pull Request. If this Pull Request merge resolves any of those tickets, please update the "Pull Request ID" field on each ticket. A future run of this script will appropriately update them.

Update Log: https://github.com/ceph/ceph/actions/runs/28704017789

@perezjosibm perezjosibm moved this from Needs QA to Merged (Main) in Crimson Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Merged (Main)

Development

Successfully merging this pull request may close these issues.

3 participants