Repository navigation
tools/cephfs_mirror: Fix crash loading persisted sync stats on restart - #70752
Conversation
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
There was a problem hiding this comment.
Pull request overview
Prevents cephfs-mirror crashes when restoring malformed persisted synchronization statistics.
Changes:
- Adds type-safe JSON field helpers.
- Safely copies nested JSON objects and catches parsing exceptions.
- Adds an integration test covering corrupted persisted statistics.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/tools/cephfs_mirror/Utils.h |
Declares typed JSON helpers. |
src/tools/cephfs_mirror/Utils.cc |
Implements validated JSON extraction. |
src/tools/cephfs_mirror/PeerReplayer.cc |
Safely restores persisted sync statistics. |
qa/tasks/cephfs/test_mirroring.py |
Tests recovery from malformed statistics. |
|
Test run looks good - https://pulpito-ng.ceph.com/runs/khiremat-2026-08-01_04:13:42-fs-wip-khiremat-70752-mirror-crash-01072026-distro-default-trial |
karthik-us1
left a comment
There was a problem hiding this comment.
Minor nits, along with the copilot requested changes.
PeerReplayer::apply_persisted_dir_sync_stat() took a reference into a json_spirit::mValue for last_synced_snap, then reused that same mValue for nested field lookups. The get_json_value() overwrote the parent value and left a dangling Object reference, which could abort the daemon when directories were re-acquired after a mirror daemon restart or a mgr failover. The fix is to Copy last_synced_snap before reading nested fields, add typed JSON helpers (moved to Utils) that check types before get_* calls, and catch std::exception so unexpected parse failures are logged instead of taking down cephfs-mirror. Fixes: https://tracker.ceph.com/issues/78932 Signed-off-by: Kotresh HR <[email protected]>
Verify cephfs-mirror stays up and continues syncing after loading intentionally corrupted last_synced_snap fields from omap. Fixes: https://tracker.ceph.com/issues/78932 Signed-off-by: Kotresh HR <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/tools/cephfs_mirror/PeerReplayer.cc:820
- Numeric duration values are still accepted without range checks. A corrupt value such as
-1or1e100is restored here and is immediately converted touint64_tduring initialization (update_directory_last_sync_perf_counters, lines 520-528); it also reachesstd::llroundinformat_time(lines 3618-3620). Those out-of-range conversions are not protected by thistry/catch. Validate all three persisted durations as finite, non-negative, and representable byint64_tbefore storing them, and extend the corruption test with a numeric out-of-range duration.
if (get_json_real(last_synced_snap, "crawl_duration", &value)) {
sync_stat.last_sync_crawl_duration = value;
}
if (get_json_real(last_synced_snap, "datasync_queue_wait_duration", &value)) {
sync_stat.last_sync_datasync_queue_wait_duration = value;
|
jenkins test windows |
|
This PR has been added to main integration testing by khiremat started 2026-08-04-09:36. |
PeerReplayer::apply_persisted_dir_sync_stat() took a reference into
a json_spirit::mValue for last_synced_snap, then reused that same
mValue for nested field lookups. The get_json_value() overwrote the
parent value and left a dangling Object reference, which could abort
the daemon when directories were re-acquired after a mirror daemon
restart or a mgr failover.
The fix is to Copy last_synced_snap before reading nested fields,
add typed JSON helpers (moved to Utils) that check types before
get_* calls, and catch std::exception so unexpected parse failures
are logged instead of taking down cephfs-mirror.
Fixes: https://tracker.ceph.com/issues/78932
Signed-off-by: Kotresh HR [email protected]
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.