Repository navigation
crimson/os/seastore/omap: check only live log keys in the trim walk - #72668
Conversation
|
jenkins test make check |
2048db7 to
adffed6
Compare
|
jenkins test make check |
|
jenkins test windows |
adffed6 to
2b7aca9
Compare
perezjosibm
left a comment
There was a problem hiding this comment.
LGTM, the following suggested items may be part of a follow-up (if strictly required):
- add/expand targeted coverage for the restart scenario where in-memory pglog bounds diverge from on-disk state, followed by a primary
pg_query_t::LOGsince X request. Specifically validate we no longer hit the dup-building/assert path regression. - In the trim-walk key filtering path, please make the “live log keys only” behavior explicit in tests (including a negative case for non-live/tombstoned keys).
Many thanks
2b7aca9 to
b1856f2
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
remove_kvs() walks the log chain from the tail and uses two checks to skip work: log_has_larger_than() skips a node whose first log key is after the range, and log_less_than() stops the walk at a node whose log keys are all before the range. Both read removed entries too. On crimson, PGLog::merge_log rewrites the whole pg log: it removes all log keys and appends the live entries to the tail again. The tail then starts with removed log keys that are newer than the live copies after them. A later trim skips the tail because of the removed keys, and the trimmed keys stay. When the OSD starts again, it reads them back and reports a log bound mismatch, and a peer that asks for the log hits the assert in _handle_dups. Make both checks read only the live entries. The live log keys of a node are in order, so log_less_than() still reads only the last entry when that entry is a live log key, and scans the node otherwise. Read the keys as string_view, and use a constant for the length of a pg log key in is_log_key() and is_pg_log_key(), so that the scans do not allocate. Fixes: https://tracker.ceph.com/issues/76287 Signed-off-by: Shraddha Agrawal <[email protected]>
get_live_bitmap() reads the bitmap of the latest REMOVE delta when the node is mutation pending, and the committed bitmap otherwise. When the node is mutation pending but has no REMOVE delta yet, for example after a log write in the same transaction, it returns an empty bitmap. Then all entries look live, also the entries that earlier transactions removed. SeaStore merges the queued transactions of a collection into one, so a pg log trim can find the newest LogNode already changed by a log write. for_each_live_entry() then reads the removed log keys again, and the trim walk skips the node as before the previous commit. Reads in the same transaction, get_value() and list(), return removed entries too. Start from the committed bitmap, as get_cur_bitmap() does. A REMOVE delta holds the full bitmap, so it still replaces the committed one. get_cur_bitmap() is then the same as get_live_bitmap(), so remove it and use get_live_bitmap() in its place. Fixes: https://tracker.ceph.com/issues/76287 Signed-off-by: Shraddha Agrawal <[email protected]>
On crimson, PGLog::merge_log rewrites the whole pg log: it removes all log keys and writes the log entries again in the same transaction. The removed copies stay in their LogNode, so the newest LogNode can start with removed log keys that are newer than the live copies appended after them. trim_after_log_rewrite makes the log (first - 3, first + 1], where first is the oldest log entry of the newest LogNode, rewrites it, then trims first - 2 and first - 1. Those keys must be gone after a replay. live_checks_after_log_rewrite also removes first and first + 1 after the rewrite, so the newest LogNode starts and ends with removed log keys. log_has_larger_than() and log_less_than() must answer for the live first - 2 and first - 1 only. trim_after_log_rewrite_in_merged_txn writes a log entry and trims in one transaction, as SeaStore does when it merges queued transactions. The newest LogNode is then mutation pending with no removal yet, and the trim must still see the committed removals. Each test checks that the rewrite keeps the newest LogNode, because the test reads that LogNode. Signed-off-by: Shraddha Agrawal <[email protected]>
b1856f2 to
5cead5a
Compare
The assert was just a symptom. The actual cause, the divergence of pglog in heap and on disk, is tested properly in the two unit tests added:
The unit test added |
Problem
Primary OSD asks for a replica's
pg_query_t::LOGsince X. While building the dup list from the replica's pglog entries older than X, the OSD aborts. It asserts as the oldest pglog entry version is less than what is expected by the OSD's pglog. And so it asserts withceph_assert(i->version > other.tail).Why is there a mismatch between what the OSD expects the pglog to be and what it really is?
When a client write comes along with a trim to a replica, the OSD trims the pglog in the memory heap and requests the same from seastore. Due to a bug in seastore's
remove_kvs, it does not mark those entries as removed on disk. A divergence is created between the in memory pglog and the one on disk.The problem only becomes noticeable when the OSD is restarted and the pglog is loaded from disk and doesn't match what the OSD expects. Initially it only results in a
log bound mismatchlog but ultimately results in an assert when the primary requests forpg_query_t::LOGsince pglog version X.Full RCA for https://pulpito.ceph.com/xuxuehan-2026-04-27_04:29:46-crimson-rados:thrash-wip-new-128-distro-debug-trial/179259/
There is a peering request for PG 3.a from primary OSD.0 to OSD.1 asking for
pg_query_t::LOGsince50'0:In the replica OSD.1,
PeeringState::fulfill_logis triggered to build the reply:Notice the
pg[3.a( v 50'80 (46'71,50'80]and(log bound mismatch, actual=[34'38,50'80]). This means OSD.1 expects the pglog to start from beyond the tail46'71, but we see that the actual pglog is[34'38,50'80], ie it starts way before the expected46'71.PeeringState::fulfill_loginvokescopy_after, which is responsible for building the reply with log entries since50'0and dups (pg's complete dup list + pg log entries that are less than50'0also get added as dups).In the reply, the only pglog entry greater than
50'0is50'80, which gets added. Then_handle_dupsis invoked to build the dup list for reply.First, all the dups in PG 3.a get copied over. We see dups being copied from
22'1to46'71:Now, from the PG 3.a's pglog (which the OSD expects to start from beyond
46'71but in reality starts from34'38), pglog entries before50'0need to be added as dups. It starts iterating from the oldest entry,34'38, finds it to be smaller than expected46'71and asserts:So the problem is the badly formed pglog of the replica OSD.1 for PG 3.a. Why does it have entries starting from
34'38instead of46'71?This is a thrasher test so OSDs are restarted many times. The first
log bound mismatchhappens after the 4th restart when pg log is loaded from disk.The restart before the above, the 3rd one, was clean. No
log bound mismatchlogged after pglog is loaded from disk:This means something goes wrong between the third and fourth restart which leaves the pglog on disk corrupt.
Investigating further, on OSD 1, PG 3.a receives a replicate client operation with a trim operation.
The pglog at this state from the logs above is
(34'37,38'43]and it is proposing to trim the tail to34'40. We see 3 pglog entries,34'38,34'39and34'40are trimmed in the heap:Now, the same trim needs to be committed on the ondisk structure in seastore. This is where the problem happens.
We see that
remove_kvsis invoked to remove contiguous entries from34'38to34'40.But no keys are actually removed. This is where the mismatch happens between the in memory heap pglog and the ondisk pglog.
Root Cause
When
remove_kvsneeds to remove contiguous entries, it performs 2 checks without checking if the keys are live or removed:The above two conditions work when all log keys are in order, first log key is the oldest and the last log key is the newest. This breaks when pglog is rewritten and all older keys were marked removed. The same LogNode can start with newer but removed log entries, followed by an older but live log entries.
Fix
If the 2 check are performed on live entires then we will not run into this error and the keys will be removed properly. The same problem exists in
has_betweenandremove_entries, which will be handled in a separate followup PR.Apart from fixing the above, I also added a succinct unit test to ensure we will catch this problem in a unit test in the future.
Prexisiting bug:
get_live_bitmap, responsible for fetching the current state of the bitmap in both cases committed and mutation pending state, had an issue when the LogNode is mutation pending but with no remove delta. In this case, an empty bitmap is returned instead of the committed one. This means all keys looked live instead of their actual state. This is fixed by simply starting from the committed bit map and incase the remove delta is present, bitmap is replaced.This prexisiting bug is relevant for this PR as without this fix we would not be able to correctly check for live log entries in the LogNode at the time of removal.
Testing
The unit test added is passing in CI.
QA:
Fixes: https://tracker.ceph.com/issues/76287
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.