Skip to content

qa/tasks/mgr/dashboard: fix race in test_copy disk_usage check - #68904

Closed
tchaikov wants to merge 1 commit into
ceph:mainfrom
tchaikov:dashboard-test-copy
Closed

tchaikov wants to merge 1 commit into
ceph:mainfrom
tchaikov:dashboard-test-copy

Conversation

@tchaikov

@tchaikov tchaikov commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

This change intends to fix following test failure:

  FAIL: test_copy (tasks.mgr.dashboard.test_rbd.RbdTest.test_copy)
  Traceback (most recent call last):
    self._validate_image(img_copy, features_name=['exclusive-lock',
    self.assertEqual(img[k], v)
  AssertionError: 0 != 67108864

by polling with wait_until_true(timeout=30) until disk_usage matches before asserting.

A hypothesis is:

_rbd_disk_usage computes disk_usage via diff_iterate(whole_object=True), which reads the object_map. librbd's copy() updates the object_map via cls_rbd::object_map_update as each object is written. DiffIterate:: diff_iterate() (api/DiffIterate.cc) calls try_acquire_lock() as an optimization to load the in-memory object_map for the fast path. This lock attempt can race with the copy's close() releasing the same lock, such that the in-memory object_map is loaded before all cls_rbd::object_map_update ops from the copy are visible on the OSD, leaving disk_usage as 0.

But we cannot verify it, as the test failure is not reproduciable.

See-also: https://tracker.ceph.com/issues/68544

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.

This change intends to fix following test failure:

```
  FAIL: test_copy (tasks.mgr.dashboard.test_rbd.RbdTest.test_copy)
  Traceback (most recent call last):
    self._validate_image(img_copy, features_name=['exclusive-lock',
    self.assertEqual(img[k], v)
  AssertionError: 0 != 67108864
```

by polling with wait_until_true(timeout=30) until disk_usage matches
before asserting.

A hypothesis is:

_rbd_disk_usage computes disk_usage via diff_iterate(whole_object=True),
which reads the object_map.  librbd's copy() updates the object_map via
cls_rbd::object_map_update as each object is written.  DiffIterate::
diff_iterate() (api/DiffIterate.cc) calls try_acquire_lock() as an
optimization to load the in-memory object_map for the fast path.  This
lock attempt can race with the copy's close() releasing the same lock,
such that the in-memory object_map is loaded before all
cls_rbd::object_map_update ops from the copy are visible on the OSD,
leaving disk_usage as 0.

But we cannot verify it, as the test failure is not reproduciable.

See-also: https://tracker.ceph.com/issues/68544
Signed-off-by: Kefu Chai <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Jul 13, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Aug 12, 2026
@github-project-automation github-project-automation Bot moved this from New to Done in Ceph-Dashboard Aug 12, 2026
@djgalloway djgalloway reopened this Oct 21, 2026
@djgalloway djgalloway closed this Oct 21, 2026
djgalloway added a commit to djgalloway/ceph that referenced this pull request Oct 22, 2026
test_copy writes 5M into an image with `rbd bench`, copies it, and
expects the copy's disk_usage to equal the source's.  It fails now and
then with

  AssertionError: 0 != 67108864

because rbd bench fills its single write buffer with one byte chosen by
rand() & 0xff (seeded from the clock), so in about 1 run of 256 every
byte written is 0x00.  The source image still accounts the written
objects, but librbd's copy skips all-zero extents, so the copy is
correctly sparse and reports a disk_usage of 0.  It is not a timing
race: waiting for the copy's usage to catch up (as tried in
ceph#68904) would only turn the failure
into a timeout.

Pass --pattern-byte 1 so the data written is never all zeros.

Fixes: https://tracker.ceph.com/issues/68544
Assisted-by: Claude Opus 5.5
Signed-off-by: David Galloway <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants