Skip to content

os/bluestore: Fix hanging Collection::flush() - #70847

Open
aclamk wants to merge 2 commits into
ceph:mainfrom
aclamk:aclamk-bs-fix-collection-flush-hang
Open

aclamk wants to merge 2 commits into
ceph:mainfrom
aclamk:aclamk-bs-fix-collection-flush-hang

Conversation

@aclamk

@aclamk aclamk commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

The testing showed that sometimes BlueStore::OpSequencer::flush() hangs.

A script that replicates the problem (sometimes, patience needed).

\#!/bin/bash
\# best execute from /dev/shm
export CBIN=/home/akupczyk/ceph-2/build/

for ((t=0; t<20; t++))
do
  {
  for ((i=0; i<100; i++))
  do
    rm log$t.txt
    rm out$t.$i.txt
    ${CBIN}/bin/ceph_test_objectstore --gtest_filter=\*BlueStore\*Matrix\* \
      --bluestore_debug_enforce_settings=ssd --debug_rocksdb=0/0 --plugin_dir=${CBIN}/lib \
      --log_to_stderr=false --log_file=log$t.txt > out$t.$i.txt 2>&1 || exit
    echo THREAD $t ITERATION $i DONE
  done
  } &
done
wait
echo ALL DONE

The captures hangs show all transactions in sequencer in STATE_DONE, and a thread waiting on

  void flush() {
    ...
    qcond.wait(l);
    ...
  }

I was unable to find exact execution sequence that leads to the hang. The path I suspected was that flush() sleeps waiting on qcong for youngest transaction to progress further than STATE_KV_SUBMITTED, but that transaction was able to pass through execution without signalling qcond.

Actions:

  1. Added locks around qcond.notify_all().
  2. Moved to qcond.wait(.., predicate)

https://tracker.ceph.com/issues/72031

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.

@aclamk
aclamk requested a review from a team as a code owner August 5, 2026 11:17
@ifed01

ifed01 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Do you this this related/fixes https://tracker.ceph.com/issues/72031?
Or we need a standalone ticket?

@ifed01

ifed01 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

make check failures look relevant

@ifed01
ifed01 self-requested a review August 5, 2026 15:54
@aclamk
aclamk force-pushed the aclamk-bs-fix-collection-flush-hang branch 2 times, most recently from 4c7f87f to b48f79f Compare August 10, 2026 13:40
@aclamk

aclamk commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Do you this this related/fixes https://tracker.ceph.com/issues/72031? Or we need a standalone ticket?

It is very probable it does.
Adding tracker ticket.

@aclamk
aclamk force-pushed the aclamk-bs-fix-collection-flush-hang branch from b48f79f to 78a039a Compare August 13, 2026 15:40
std::lock_guard l(txc->osr->qlock);
txc->osr->qcond.notify_all();
if (sync_submit_transaction) {
// We already have the lock

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.

Oh no... this is very implicity and unreliable statement

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please elaborate more.
The comment is here to observe difference between taking and not taking an osr->qlock.
There are 2 paths invoking _txc_apply_kv:

  1. _kv_sync_thread, lock not held
  2. _txc_state_proc, that has ceph_assert(ceph_mutex_is_locked(txc->osr->qlock));

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.

Well - first of all the name of the parameter is pretty confusing. What does it determine - who called the function? But sounds like it's about synchronous vs. asynchronous execution... Well, originally this was apparently intended for tracing only hence it's not a big deal.
Now it becomes worse - new patch uses this unclear parameter to determine if it needs locking or not. Which makes the cost of an error (in the future code if any) much higher. At this point I'd like to have the parameter name indicating the proper (and primary) meaning - whether caller request for lock acquisition within the func or not...

@aclamk
aclamk force-pushed the aclamk-bs-fix-collection-flush-hang branch from 78a039a to 2b3cf0e Compare September 3, 2026 12:11
@aclamk

aclamk commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@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

The testing showed that sometimes BlueStore::OpSequencer::flush() hangs.

A script that replicates the problem (sometimes, patience needed).

<bash script begin>
\#!/bin/bash
\# best execute from /dev/shm
export CBIN=/home/akupczyk/ceph-2/build/

for ((t=0; t<20; t++))
do
  {
  for ((i=0; i<100; i++))
  do
    rm log$t.txt
    rm out$t.$i.txt
    ${CBIN}/bin/ceph_test_objectstore --gtest_filter=\*BlueStore\*Matrix\* \
      --bluestore_debug_enforce_settings=ssd --debug_rocksdb=0/0 --plugin_dir=${CBIN}/lib \
      --log_to_stderr=false --log_file=log$t.txt > out$t.$i.txt 2>&1 || exit
    echo THREAD $t ITERATION $i DONE
  done
  } &
done
wait
echo ALL DONE
<bash script ends>

The captures hangs show all transactions in sequencer in STATE_DONE,
and a thread waiting on
  void flush() {
    ...
    qcond.wait(l);
    ...
  }

I was unable to find exact execution sequence that leads to the hang.
The path I suspected was that flush() sleeps waiting on qcong for youngest
transaction to progress further than STATE_KV_SUBMITTED, but that
transaction was able to pass through execution without signalling qcond.

Actions:
1) Added locks around `qcond.notify_all()`.
2) Moved to `qcond.wait(.., predicate)`
3) Replaced `qcond.wait()` with `qcond.wait_for()`
4) If wait on qcond timed out, print message to dout(1)

Fixes: https://tracker.ceph.com/issues/72031

Signed-off-by: Adam Kupczyk <[email protected]>
Rename parameter sync_submit_transaction -> osr_lock_held.

This is to stress actual difference in _txc_apply_kv behaviour.

Signed-off-by: Adam Kupczyk <[email protected]>
@aclamk
aclamk force-pushed the aclamk-bs-fix-collection-flush-hang branch from 52158b1 to d8b6c41 Compare October 26, 2026 17:08
@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

@aclamk

aclamk commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

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