os/bluestore: Fix race in BlueFS truncate / remove#62588
Conversation
| if (string(GetParam()) != "bluestore") | ||
| GTEST_SKIP(); | ||
|
|
||
| BlueStore* bstore = dynamic_cast<BlueStore*> (store.get()); |
There was a problem hiding this comment.
Hmm, this suggests there might a better, already BlueStore-specific test to accommodate this testcase.
There was a problem hiding this comment.
True, but we do not have ceph-test-bluestore.
But with the amount of BlueStore specific tests in ceph-test-objectstore there are, maybe we should have.
src/os/bluestore/BlueFS.cc
Outdated
| ceph_abort_msg("truncate up not supported"); | ||
| } | ||
|
|
||
| usleep(1000); |
There was a problem hiding this comment.
It looks there is a need for instrumentation infrastructure in BlueStore.
I can imagine something like a dedicated build of libos.a for tests carrying an extra compile-time flag supplemented with dynamic hooks to allow specific test cases to injecting some code (like sleep) along the paths.
#ifdef BLUESTORE_INSTRUMENTED
if (g_bluefs_truncate_hook) {
*g_bluefs_truncate_hook();
}
#endifThere was a problem hiding this comment.
/THINKING LOUDLY
Perhaps we want randomized-delays-in-strategic-places also in debug builds to let race conditions like the replicated one to pop-up in our Teuthology testing.
There was a problem hiding this comment.
There is already something that could be used: debug_point_t
https://github.com/ceph/ceph/blob/main/src/os/bluestore/BlueFS.h#L219-L244
There was a problem hiding this comment.
I don't think random delays will be very useful.
But I have in (short) backlog a Synthetic tests that actually kills BlueStore mid-flight.
We will have much better testing of recovery this way.
Created test that exposes race between BlueFS::truncate and BlueFS::unlink. Test requires injection of 1ms sleep to BlueFS::truncate. Therefore, in this form, it is unsuitable for merge. Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
3335907 to
7abf99d
Compare
src/os/bluestore/BlueFS.cc
Outdated
| logger->set(l_bluefs_num_files, nodes.file_map.size()); | ||
| file->deleted = true; | ||
|
|
||
| { |
There was a problem hiding this comment.
funaction name to get _F substr in the name here and there?
There was a problem hiding this comment.
It should and it will.
b4b33bd to
80c9e3b
Compare
|
Approved by https://tracker.ceph.com/issues/70787. |
It was possible for unlink() to interrupt ongoing truncate(). As the result, unlink() finishes properly, but truncate() is not aware of it and does: 1) updates file that is already removed 2) releases same allocations again Now fixed by checking if file is deleted under FILE lock. https://tracker.ceph.com/issues/70747 Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
80c9e3b to
e5f8892
Compare
|
jenkins test make check arm64 |
|
jenkins test make check |
|
jenkins test make check arm64 |
Commit 2:
Fixes race between BlueFS::truncate and BlueFS::unlink.
Fixes: https://tracker.ceph.com/issues/70747
Commit 1:
Created test that exposes race between BlueFS::truncate and BlueFS::unlink.
Test requires injection of 1ms sleep to BlueFS::truncate.
Therefore, in this form, it is unsuitable for merge.
Running:
It will assert.
Observe results:
But if we skip checking allocations:
And look at BlueFS log produced:
We can see "op_file_remove 27" and then resurrection in "op_file_update file(ino 27...) "
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job Definition