Skip to content

librbd/cache/pwl: arm periodic stats timer only after init succeeds - #69898

Merged
idryomov merged 1 commit into
ceph:mainfrom
sunyuechi:fix-pwl-writelog-dtor-deadlock
Aug 23, 2026
Merged

idryomov merged 1 commit into
ceph:mainfrom
sunyuechi:fix-pwl-writelog-dtor-deadlock

Conversation

@sunyuechi

@sunyuechi sunyuechi commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

If an init step fails after pwl_init() armed the stats timer,
InitRequest deletes the image cache without shut_down(), so the
self-rearming timer callback keeps firing on the freed object.

Arm the timer after write_image_cache_state() completes instead: on
failure paths it is never armed, and any later teardown goes through
shut_down(), which cancels it.

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

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)

@sunyuechi
sunyuechi requested a review from a team as a code owner July 2, 2026 05:31
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@github-actions github-actions Bot added the rbd label Jul 2, 2026
@sunyuechi
sunyuechi force-pushed the fix-pwl-writelog-dtor-deadlock branch from 7ed962b to 2022a4a Compare July 2, 2026 05:33
@sunyuechi

Copy link
Copy Markdown
Contributor Author

This deadlock only showed up once in dozens of CI runs. To reproduce it, add the following to AbstractWriteLog<I>::~AbstractWriteLog:

m_work_queue.queue(new LambdaContext([this](int r) {
  usleep(500000);
  std::lock_guard l(m_lock);
}), 0);
usleep(100000);

@tchaikov

tchaikov commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

ok to test

@sunyuechi

Copy link
Copy Markdown
Contributor Author

@idryomov

Copy link
Copy Markdown
Contributor

A CI run that hit a deadlock before this PR's fix: https://github.com/sunyuechi/ceph-ci/actions/runs/31400188685/job/93492938467

@sunyuechi Just curious, how do you trace

/root/.cache/act/9482f96af00066f3/act/workflow/__run_2.sh: line 2: 592577 Killed                  ./scripts/openruyi/run-spec-build.sh
Error:   ❌  Failure - Main Validate openRuyi spec (rpmbuild + ctest) in openRuyi container
Error: exit status 137

back to this deadlock?

@sunyuechi

Copy link
Copy Markdown
Contributor Author

@idryomov

CI hung. One ctest job produced no output for over an hour and all 200+ threads
of unittest_librbd were in S state. I ssh'd into the box while it was still hung
and attached gdb, the kill you see there was me afterwards.

gdb -p (thread apply all bt) showed the main thread in ~AbstractWriteLog joining
tp_pwl, and a tp_pwl worker blocked on m_lock in dispatch_deferred_writes. The
mutex's __data.__owner was the joining thread.

@sunyuechi
sunyuechi force-pushed the fix-pwl-writelog-dtor-deadlock branch from 2022a4a to e459411 Compare August 17, 2026 05:52
@sunyuechi sunyuechi changed the title librbd/cache/pwl: fix deadlock and lifetime bugs in AbstractWriteLog teardown librbd/cache/pwl: cancel periodic stats timer in destructor Aug 17, 2026
@sunyuechi
sunyuechi force-pushed the fix-pwl-writelog-dtor-deadlock branch from e459411 to 34efb6e Compare August 17, 2026 13:57
@sunyuechi sunyuechi changed the title librbd/cache/pwl: cancel periodic stats timer in destructor librbd/cache/pwl: arm periodic stats timer only after init succeeds Aug 17, 2026
@sunyuechi
sunyuechi force-pushed the fix-pwl-writelog-dtor-deadlock branch from 34efb6e to ccc4e7e Compare August 17, 2026 14:03
If an init step fails after pwl_init() armed the stats timer,
InitRequest deletes the image cache without shut_down(), so the
self-rearming timer callback keeps firing on the freed object.

Arm the timer after write_image_cache_state() completes instead: on
failure paths it is never armed, and any later teardown goes through
shut_down(), which cancels it.

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

Signed-off-by: Sun Yuechi <[email protected]>
@sunyuechi
sunyuechi force-pushed the fix-pwl-writelog-dtor-deadlock branch from ccc4e7e to 21149c1 Compare August 18, 2026 12:44
@idryomov
idryomov merged commit 2c57b1d into ceph:main Aug 23, 2026
7 checks passed
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.

4 participants