Repository navigation
crimson/os/alienstore: make CnLog::_flush non-blocking - #69838
Conversation
|
Thank you, @tchaikov . Fixed. |
|
jenkins test make check |
|
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]>
|
jenkins test make check arm64 |
|
jenkins test windows |
1 similar comment
|
jenkins test windows |
perezjosibm
left a comment
There was a problem hiding this comment.
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 fromqafter 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.
|
jenkins test windows |
|
Merging based on my Teuthology tests. |
|
This is an automated message by src/script/redmine-upkeep.py. I found one or more
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. |
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