Repository navigation
osd: Fix PrimaryLogPG::rep_repair_primary_object assert for Direct EC Read - #71910
Conversation
aainscow
left a comment
There was a problem hiding this comment.
I need @JonBailey1993 to verify whether the RadosIo.cc use-after-free is genuine.
| rop.sparse_read(sparseOp.offset[0] * block_size, | ||
| sparseOp.length[0] * block_size, | ||
| extents.get(), | ||
| &op_info->bufferlist[0], |
There was a problem hiding this comment.
Doesn't op_info get freed when it gets out of scope, so this pointer will point at freed memory?
There was a problem hiding this comment.
Yes, I believe it is a use-after-free - it seems not to be hit frequently as it appears it exists in Create, Write1/2/3, FailedWrite1/2/3 and Truncate1/2/3 too.
I think the fix is just to do what read does and have the sparse_read_cb lambda capture op_info so the shared_pointer will still be owned by something up until the callback finishes executing.
There was a problem hiding this comment.
Its only a bug in sparse-read - the write paths copy the bufferlist before it is freed. Will fix by adding op_info to the lambda to copy the read path.
| if (!is_primary() || pool.info.is_erasure()) { | ||
| // Must be a balanced/localized/EC direct read that has failed on a replica. | ||
| // Replicas cannot run recovery, so the request need to be | ||
| // failed with EAGAIN to the client which will then retry the |
There was a problem hiding this comment.
nit: Potential AI-misleading comment here. This comment implies that this only happens on non-primary OSDs, but this is not true for EC direct reads. Code is correct, comment is very slightly misleading.
There was a problem hiding this comment.
Fixed comment and log message below
3d13ed7 to
b6a86b8
Compare
1f4717e to
b14d37c
Compare
With the introduction of EC direct reads it is possible that an EC sparse reads encounters a medium error and ends up calling rep_repair_primary_object. Instead of asserting the direct read should be failed back to the client with -EAGAIN so that it can be resent to the primary which can then perform recovery. Fixes: https://tracker.ceph.com/issues/79319 Signed-off-by: Bill Scales <[email protected]>
This test shows how we can hit the ceph_assert(!pool.info.is_erasure()); on an ec pool Signed-off-by: Jon Bailey <[email protected]> Assisted-by: IBM Bob 2.0.2
Test injecting a medium error for an EC direct sparse read to a non-primary shard. EC Direct Reads allows clients to send requests to the shard that has the data rather than to the Primary which then has to forward the request. However if this direct read fails (e.g. because of a medium error) the request needs to be failed to the client with EAGAIN which will then resubmit the request to the Primary. This is required because only the Primary can perform recovery. Signed-off-by: Bill Scales <[email protected]>
b14d37c to
e13f94e
Compare
|
A few force pushes to tweak the set of ignored health warnings for the test - in particular the -EIO for the read that we are deliberately injecting is expected. Here's a teuthology run showing the new test passing: |
aainscow
left a comment
There was a problem hiding this comment.
LGTM
There is a quirk in the script which means the code to detect crashes wont work, but that doesn't matter for teuthology.
|
This PR has been added to wip-bharath10-testing-20260924.010810-main. |
…o the primary Builds on "osd: rep_repair_primary_object needs to handle direct reads" (PR ceph#71910), which makes rep_repair_primary_object() fail an EC read with -EAGAIN instead of asserting, so the sparse path (do_sparse_read) now bounces an EC direct read that hits -EIO or a full-object crc mismatch back to the client for a retry at the primary. An EC direct read only reads the local shard, so it cannot reconstruct around a medium error. The design (ec_stretch_cluster.rst 7.2 and direct_reads.rst) requires any such failure to send the client back to the primary, which can decode from the other shards (in a stretch pool, from remote-zone shards if need be). The non-sparse path (do_read, objects_read_local) still passed -EIO straight back to the client, failing the application's read. Call rep_repair_primary_object() from the non-sparse EC direct-read path on -EIO, as the replicated path does, so it takes the same -EAGAIN bounce, which the Objecter (and SplitOp) resubmits to the primary without the direct-read flags. -EAGAIN from do_osd_ops() means the reply has already been sent, so execute_ctx() just closes the context. Replicated pools and non-direct EC reads are unchanged. The unit harness does not reach PrimaryLogPG::do_osd_ops(); the next commit checks the backend half (objects_read_local() returning -EIO) only. Fixes: https://tracker.ceph.com/issues/81286 Assisted-by: Claude Code
…o the primary Builds on "osd: rep_repair_primary_object needs to handle direct reads" (PR ceph#71910), which makes rep_repair_primary_object() fail an EC read with -EAGAIN instead of asserting, so the sparse path (do_sparse_read) now bounces an EC direct read that hits -EIO or a full-object crc mismatch back to the client for a retry at the primary. An EC direct read only reads the local shard, so it cannot reconstruct around a medium error. The design (ec_stretch_cluster.rst 7.2 and direct_reads.rst) requires any such failure to send the client back to the primary, which can decode from the other shards (in a stretch pool, from remote-zone shards if need be). The non-sparse path (do_read, objects_read_local) still passed -EIO straight back to the client, failing the application's read. Call rep_repair_primary_object() from the non-sparse EC direct-read path on -EIO, as the replicated path does, so it takes the same -EAGAIN bounce, which the Objecter (and SplitOp) resubmits to the primary without the direct-read flags. -EAGAIN from do_osd_ops() means the reply has already been sent, so execute_ctx() just closes the context. Replicated pools and non-direct EC reads are unchanged. The unit harness does not reach PrimaryLogPG::do_osd_ops(); the next commit checks the backend half (objects_read_local() returning -EIO) only. Fixes: https://tracker.ceph.com/issues/81286 Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]>
…o the primary Builds on "osd: rep_repair_primary_object needs to handle direct reads" (PR ceph#71910), which makes rep_repair_primary_object() fail an EC read with -EAGAIN instead of asserting, so the sparse path (do_sparse_read) now bounces an EC direct read that hits -EIO or a full-object crc mismatch back to the client for a retry at the primary. An EC direct read only reads the local shard, so it cannot reconstruct around a medium error. The design (ec_stretch_cluster.rst 7.2 and direct_reads.rst) requires any such failure to send the client back to the primary, which can decode from the other shards (in a stretch pool, from remote-zone shards if need be). The non-sparse path (do_read, objects_read_local) still passed -EIO straight back to the client, failing the application's read. Call rep_repair_primary_object() from the non-sparse EC direct-read path on -EIO, as the replicated path does, so it takes the same -EAGAIN bounce, which the Objecter (and SplitOp) resubmits to the primary without the direct-read flags. -EAGAIN from do_osd_ops() means the reply has already been sent, so execute_ctx() just closes the context. Replicated pools and non-direct EC reads are unchanged. The next commit adds a standalone test that takes this path. Fixes: https://tracker.ceph.com/issues/81286 Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]>
…o the primary Builds on "osd: rep_repair_primary_object needs to handle direct reads" (PR ceph#71910), which makes rep_repair_primary_object() fail an EC read with -EAGAIN instead of asserting, so the sparse path (do_sparse_read) now bounces an EC direct read that hits -EIO or a full-object crc mismatch back to the client for a retry at the primary. An EC direct read only reads the local shard, so it cannot reconstruct around a medium error. The design (ec_stretch_cluster.rst 7.2 and direct_reads.rst) requires any such failure to send the client back to the primary, which can decode from the other shards (in a stretch pool, from remote-zone shards if need be). The non-sparse path (do_read, objects_read_local) still passed -EIO straight back to the client, failing the application's read. Call rep_repair_primary_object() from the non-sparse EC direct-read path on -EIO, as the replicated path does, so it takes the same -EAGAIN bounce, which the Objecter (and SplitOp) resubmits to the primary without the direct-read flags. -EAGAIN from do_osd_ops() means the reply has already been sent, so execute_ctx() just closes the context. Replicated pools and non-direct EC reads are unchanged. The next commit adds a standalone test that takes this path. Fixes: https://tracker.ceph.com/issues/81286 Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]>
Follows up Jon Bailey's review comment on ceph#72383 (ceph#72383 (comment)), which asked for every OpType to have a case so that a new op fails the build until this test considers it. ceph#71910 has since added OpType::SparseRead to main. With this PR rebased onto main, the make check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails: "enumeration value 'SparseRead' not handled in switch". A SparseRead reads the primary object, so check it like the other reads. No sequence issues one yet. To be squashed into "test/osd: demonstrate Seq15 reading while a copy or truncate is in flight" before merge. Assisted-by: Claude Code
Follows up Jon Bailey's review comment on ceph#72383 (ceph#72383 (comment)), which asked for every OpType to have a case so that a new op fails the build until this test considers it. ceph#71910 has since added OpType::SparseRead to main. With this PR rebased onto main, the make check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails: "enumeration value 'SparseRead' not handled in switch". A SparseRead reads the primary object, so check it like the other reads. No sequence issues one yet. To be squashed into "test/osd: demonstrate Seq15 reading while a copy or truncate is in flight" before merge. Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]>
…rier test Follows up Jon Bailey's review comment on ceph#72383 (ceph#72383 (comment)), which asked for every OpType to have a case so that a new op fails the build until this test considers it. ceph#71910 has since added OpType::SparseRead to main. With this PR rebased onto main, the make check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails: "enumeration value 'SparseRead' not handled in switch". A SparseRead reads the primary object, so check it like the other reads. No sequence issues one yet. To be squashed into "test/osd: demonstrate Seq15 reading while a copy or truncate is in flight" before merge. Assisted-by: Claude Code
…rier test Follows up Jon Bailey's review comment on ceph#72383 (ceph#72383 (comment)), which asked for every OpType to have a case so that a new op fails the build until this test considers it. ceph#71910 has since added OpType::SparseRead to main. With this PR rebased onto main, the make check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails: "enumeration value 'SparseRead' not handled in switch". A SparseRead reads the primary object, so check it like the other reads. No sequence issues one yet. To be squashed into "test/osd: demonstrate Seq15 reading while a copy or truncate is in flight" before merge. Assisted-by: Claude Code
…rier test Follows up Jon Bailey's review comment on ceph#72383 (ceph#72383 (comment)), which asked for every OpType to have a case so that a new op fails the build until this test considers it. ceph#71910 has since added OpType::SparseRead to main. With this PR rebased onto main, the make check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails: "enumeration value 'SparseRead' not handled in switch". A SparseRead reads the primary object, so check it like the other reads. No sequence issues one yet. To be squashed into "test/osd: demonstrate Seq15 reading while a copy or truncate is in flight" before merge. Assisted-by: Claude Code
…rier test Follows up Jon Bailey's review comment on ceph#72383 (ceph#72383 (comment)), which asked for every OpType to have a case so that a new op fails the build until this test considers it. ceph#71910 has since added OpType::SparseRead to main. With this PR rebased onto main, the make check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails: "enumeration value 'SparseRead' not handled in switch". A SparseRead reads the primary object, so check it like the other reads. No sequence issues one yet. To be squashed into "test/osd: demonstrate Seq15 reading while a copy or truncate is in flight" before merge. Assisted-by: Claude Code
…rier test Follows up Jon Bailey's review comment on ceph#72383 (ceph#72383 (comment)), which asked for every OpType to have a case so that a new op fails the build until this test considers it. ceph#71910 has since added OpType::SparseRead to main. With this PR rebased onto main, the make check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails: "enumeration value 'SparseRead' not handled in switch". A SparseRead reads the primary object, so check it like the other reads. No sequence issues one yet. To be squashed into "test/osd: demonstrate Seq15 reading while a copy or truncate is in flight" before merge. Assisted-by: Claude Code
…rier test Follows up Jon Bailey's review comment on ceph#72383 (ceph#72383 (comment)), which asked for every OpType to have a case so that a new op fails the build until this test considers it. ceph#71910 has since added OpType::SparseRead to main. With this PR rebased onto main, the make check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails: "enumeration value 'SparseRead' not handled in switch". A SparseRead reads the primary object, so check it like the other reads. No sequence issues one yet. To be squashed into "test/osd: demonstrate Seq15 reading while a copy or truncate is in flight" before merge. Assisted-by: Claude Code
…o the primary Builds on "osd: rep_repair_primary_object needs to handle direct reads" (PR ceph#71910), which makes rep_repair_primary_object() fail an EC read with -EAGAIN instead of asserting, so the sparse path (do_sparse_read) now bounces an EC direct read that hits -EIO or a full-object crc mismatch back to the client for a retry at the primary. An EC direct read only reads the local shard, so it cannot reconstruct around a medium error. The design (ec_stretch_cluster.rst 7.2 and direct_reads.rst) requires any such failure to send the client back to the primary, which can decode from the other shards (in a stretch pool, from remote-zone shards if need be). The non-sparse path (do_read, objects_read_local) still passed -EIO straight back to the client, failing the application's read. Call rep_repair_primary_object() from the non-sparse EC direct-read path on -EIO, as the replicated path does, so it takes the same -EAGAIN bounce, which the Objecter (and SplitOp) resubmits to the primary without the direct-read flags. -EAGAIN from do_osd_ops() means the reply has already been sent, so execute_ctx() just closes the context. Replicated pools and non-direct EC reads are unchanged. The next commit adds a standalone test that takes this path. Fixes: https://tracker.ceph.com/issues/81286 Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]> (cherry picked from commit 0f17b4c)
A sparse read sent as a direct EC read to a non-primary shard which then fails with a medium error hits an assert in rep_repair_primary_object. This is another case where the request should be failed with EAGAIN and resent to the primary which can then perform recovery.
Fixes: https://tracker.ceph.com/issues/79319
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 DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.