mirror of
https://github.com/ceph/ceph
synced 2026-08-02 07:03:18 +00:00
tools/cephfs-mirror: report epoch time in last snap sync time
Store sync completion time (last_synced_snap.sync_time_stamp) as utime_t (Unix epoch) instead of coarse monotonic time so the metric is meaningful to operators. Fixes: https://tracker.ceph.com/issues/76506 Signed-off-by: Kotresh HR <khiremat@redhat.com>
This commit is contained in:
parent
a5590d99c3
commit
0bb27c7de1
@ -660,7 +660,7 @@ command parameter is of format ``filesystem-name@filesystem-id peer-uuid``::
|
||||
"crawl_duration": "2s",
|
||||
"datasync_queue_wait_duration": "1s",
|
||||
"sync_duration": "33s",
|
||||
"sync_time_stamp": "274900.558797s",
|
||||
"sync_time_stamp": "1784150400.558797s",
|
||||
"sync_bytes": "149.94 MiB",
|
||||
"sync_files": 5000
|
||||
},
|
||||
@ -752,9 +752,8 @@ Timestamp
|
||||
|
||||
Field: ``sync_time_stamp``.
|
||||
|
||||
Monotonic clock time in seconds (since daemon startup) when the snapshot sync finished,
|
||||
printed with sub-second precision and an ``s`` suffix (for example, ``274900.558797s``). This
|
||||
is not a wall-clock or epoch timestamp.
|
||||
Unix epoch time in seconds when the snapshot sync finished, printed with
|
||||
sub-second precision and an ``s`` suffix (for example, ``1784150400.558797s``).
|
||||
|
||||
``snaps_synced``, ``snaps_deleted``, and ``snaps_renamed`` are
|
||||
:ref:`per-session counters<cephfs_mirroring_sync_metric_fields>`: they count
|
||||
@ -923,7 +922,7 @@ E.g., adding a regular file for synchronization would result in failed status::
|
||||
"crawl_duration": "2s",
|
||||
"datasync_queue_wait_duration": "1s",
|
||||
"sync_duration": "44s",
|
||||
"sync_time_stamp": "500900.600797s",
|
||||
"sync_time_stamp": "1784150733.600797s",
|
||||
"sync_bytes": "149.94 MiB",
|
||||
"sync_files": 5000
|
||||
},
|
||||
@ -972,7 +971,7 @@ In the remote filesystem::
|
||||
"crawl_duration": "2s",
|
||||
"datasync_queue_wait_duration": "1s",
|
||||
"sync_duration": "33s",
|
||||
"sync_time_stamp": "274900.558797s",
|
||||
"sync_time_stamp": "1784150400.558797s",
|
||||
"sync_bytes": "149.94 MiB",
|
||||
"sync_files": 5000
|
||||
},
|
||||
@ -1227,7 +1226,7 @@ Counters are not updated on every file read or write. Behavior differs by field
|
||||
- Durations in seconds; bytes are raw counts
|
||||
* - ``last_sync_timestamp``
|
||||
- ``last_synced_snap.sync_time_stamp``
|
||||
- ``utime_t`` (seconds since epoch), not the monotonic string shown in admin JSON
|
||||
- ``utime_t`` (seconds since epoch); same wall-clock value as admin JSON
|
||||
* - ``snaps_synced`` / ``snaps_deleted`` / ``snaps_renamed``
|
||||
- Same field names at directory level
|
||||
- Reset on daemon restart or directory reassignment (same as admin socket)
|
||||
|
||||
@ -444,7 +444,7 @@ status. Commands of this kind take the form ``filesystem-name@filesystem-id peer
|
||||
"crawl_duration": "2s",
|
||||
"datasync_queue_wait_duration": "1s",
|
||||
"sync_duration": "33s",
|
||||
"sync_time_stamp": "274900.558797s",
|
||||
"sync_time_stamp": "1784150400.558797s",
|
||||
"sync_bytes": "149.94 MiB",
|
||||
"sync_files": 5000
|
||||
},
|
||||
@ -548,7 +548,7 @@ status:
|
||||
"crawl_duration": "2s",
|
||||
"datasync_queue_wait_duration": "1s",
|
||||
"sync_duration": "33s",
|
||||
"sync_time_stamp": "274900.558797s",
|
||||
"sync_time_stamp": "1784150400.558797s",
|
||||
"sync_bytes": "149.94 MiB",
|
||||
"sync_files": 5000
|
||||
},
|
||||
|
||||
@ -122,15 +122,6 @@ bool get_json_value(const json_spirit::mObject& obj,
|
||||
return false;
|
||||
}
|
||||
|
||||
double monotime_to_double(monotime t) {
|
||||
return sec_duration(t.time_since_epoch()).count();
|
||||
}
|
||||
|
||||
monotime monotime_from_double(double seconds) {
|
||||
auto d = std::chrono::duration_cast<clock::duration>(sec_duration(seconds));
|
||||
return monotime(d);
|
||||
}
|
||||
|
||||
struct C_PersistSyncStatAio : Context {
|
||||
std::string dir_root;
|
||||
|
||||
@ -543,13 +534,7 @@ void PeerReplayer::update_directory_last_sync_perf_counters(
|
||||
sync_stat.last_sync_duration ?
|
||||
static_cast<uint64_t>(*sync_stat.last_sync_duration) : 0);
|
||||
|
||||
utime_t t;
|
||||
if (!clock::is_zero(sync_stat.last_synced)) {
|
||||
t.set_from_double(monotime_to_double(sync_stat.last_synced));
|
||||
} else {
|
||||
t = utime_t();
|
||||
}
|
||||
perf->tset(l_cephfs_mirror_directory_last_sync_timestamp, t);
|
||||
perf->tset(l_cephfs_mirror_directory_last_sync_timestamp, sync_stat.last_synced);
|
||||
|
||||
perf->set(l_cephfs_mirror_directory_last_sync_bytes,
|
||||
sync_stat.last_sync_bytes ? *sync_stat.last_sync_bytes : 0);
|
||||
@ -837,7 +822,7 @@ void PeerReplayer::apply_persisted_dir_sync_stat(SnapSyncStat &sync_stat,
|
||||
sync_stat.last_sync_duration = v.get_real();
|
||||
}
|
||||
if (get_json_value(last_synced_snap, "sync_time_stamp", &v)) {
|
||||
sync_stat.last_synced = monotime_from_double(v.get_real());
|
||||
sync_stat.last_synced.set_from_double(v.get_real());
|
||||
}
|
||||
if (get_json_value(last_synced_snap, "sync_bytes", &v)) {
|
||||
sync_stat.last_sync_bytes = v.get_uint64();
|
||||
@ -1082,9 +1067,9 @@ void PeerReplayer::add_last_sync_metrics_to_persist(json_spirit::mObject &obj,
|
||||
if (sync_stat.last_sync_duration) {
|
||||
snap["sync_duration"] = json_spirit::mValue(*sync_stat.last_sync_duration);
|
||||
}
|
||||
if (!clock::is_zero(sync_stat.last_synced)) {
|
||||
if (!sync_stat.last_synced.is_zero()) {
|
||||
snap["sync_time_stamp"] =
|
||||
json_spirit::mValue(monotime_to_double(sync_stat.last_synced));
|
||||
json_spirit::mValue(static_cast<double>(sync_stat.last_synced));
|
||||
}
|
||||
if (sync_stat.last_sync_bytes) {
|
||||
snap["sync_bytes"] =
|
||||
@ -3829,7 +3814,12 @@ void PeerReplayer::dump_sync_stat(Formatter *f, const SnapSyncStat &sync_stat) {
|
||||
}
|
||||
if (sync_stat.last_sync_duration) {
|
||||
f->dump_string("sync_duration", format_time(*sync_stat.last_sync_duration));
|
||||
f->dump_stream("sync_time_stamp") << sync_stat.last_synced;
|
||||
}
|
||||
if (!sync_stat.last_synced.is_zero()) {
|
||||
std::ostringstream os;
|
||||
os << std::fixed << std::setprecision(6)
|
||||
<< static_cast<double>(sync_stat.last_synced);
|
||||
f->dump_string("sync_time_stamp", os.str() + "s");
|
||||
}
|
||||
if (sync_stat.last_sync_bytes) {
|
||||
f->dump_string("sync_bytes", format_bytes(*sync_stat.last_sync_bytes));
|
||||
|
||||
@ -4,8 +4,10 @@
|
||||
#ifndef CEPHFS_MIRROR_PEER_REPLAYER_H
|
||||
#define CEPHFS_MIRROR_PEER_REPLAYER_H
|
||||
|
||||
#include "common/Clock.h"
|
||||
#include "common/Formatter.h"
|
||||
#include "common/Thread.h"
|
||||
#include "include/utime.h"
|
||||
#include "mds/FSMap.h"
|
||||
#include "ServiceDaemon.h"
|
||||
#include "Types.h"
|
||||
@ -410,7 +412,7 @@ private:
|
||||
uint64_t synced_snap_count = 0;
|
||||
uint64_t deleted_snap_count = 0;
|
||||
uint64_t renamed_snap_count = 0;
|
||||
monotime last_synced = clock::zero();
|
||||
utime_t last_synced;
|
||||
boost::optional<double> last_sync_duration;
|
||||
boost::optional<double> last_sync_crawl_duration;
|
||||
boost::optional<double> last_sync_datasync_queue_wait_duration;
|
||||
@ -469,7 +471,7 @@ private:
|
||||
|
||||
void _reset_last_synced_snap_stat(const std::string &dir_root) {
|
||||
auto &sync_stat = m_snap_sync_stats.at(dir_root);
|
||||
sync_stat.last_synced = clock::zero();
|
||||
sync_stat.last_synced = utime_t();
|
||||
sync_stat.last_sync_duration.reset();
|
||||
sync_stat.last_sync_crawl_duration.reset();
|
||||
sync_stat.last_sync_datasync_queue_wait_duration.reset();
|
||||
@ -563,7 +565,7 @@ private:
|
||||
std::scoped_lock locker(m_lock);
|
||||
_set_last_synced_snap(dir_root, snap_id, snap_name);
|
||||
auto &sync_stat = m_snap_sync_stats.at(dir_root);
|
||||
sync_stat.last_synced = clock::now();
|
||||
sync_stat.last_synced = ceph_clock_now();
|
||||
sync_stat.last_sync_duration = duration;
|
||||
sync_stat.last_sync_crawl_duration = sync_stat.crawl_duration;
|
||||
//For empty snapshot sync, datasync_queue_wait_duration is 0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user