Skip to content

Commit 37c1522

Browse files
committed
rgw/sync: track last_update timestamp per-shard instead of per-entry
this way, store_entry() always uses the latest value from the remote instead of the value from when we fetched the given datalog entry since this last_update timestamp only applies to data incremental sync, all related logic was moved out of the base class into RGWDataSyncShardMarkerTrack Signed-off-by: Casey Bodley <[email protected]>
1 parent 2a8d84e commit 37c1522

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

src/rgw/driver/rados/rgw_data_sync.cc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,9 @@ class RGWDataSyncShardMarkerTrack : public RGWSyncShardMarkerTrack<string, strin
11161116
RGWObjVersionTracker& objv;
11171117
sync_deltas::SyncDeltaCountersManager sync_delta_counters_manager;
11181118

1119+
// timestamp of remote's most recent log entry. initialized only for data sync
1120+
ceph::real_time last_updated;
1121+
11191122
public:
11201123
RGWDataSyncShardMarkerTrack(RGWDataSyncCtx *_sc,
11211124
const string& _marker_oid,
@@ -1138,7 +1141,14 @@ class RGWDataSyncShardMarkerTrack : public RGWSyncShardMarkerTrack<string, strin
11381141
{"shard_id", std::to_string(shard_id)}});
11391142
}
11401143

1141-
RGWCoroutine* store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp, const real_time& last_update) override {
1144+
bool start(const std::string& pos, int index_pos, const real_time& timestamp, const real_time& last_update = {}) {
1145+
if (last_updated < last_update) {
1146+
last_updated = last_update;
1147+
}
1148+
return RGWSyncShardMarkerTrack::start(pos, index_pos, timestamp);
1149+
}
1150+
1151+
RGWCoroutine* store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp) override {
11421152
sync_marker.marker = new_marker;
11431153
sync_marker.pos = index_pos;
11441154
sync_marker.timestamp = timestamp;
@@ -1147,8 +1157,8 @@ class RGWDataSyncShardMarkerTrack : public RGWSyncShardMarkerTrack<string, strin
11471157
// last_update is only modified during incremental sync we only want to
11481158
// report deltas for incremental sync
11491159
real_time zero_time;
1150-
if (last_update != zero_time) {
1151-
auto delta = last_update - timestamp;
1160+
if (last_updated != zero_time) {
1161+
auto delta = last_updated - timestamp;
11521162
sync_delta_counters_manager.tset(sync_deltas::l_rgw_datalog_sync_delta, delta);
11531163
}
11541164

@@ -2128,7 +2138,7 @@ class RGWDataIncSyncShardCR : public RGWDataBaseSyncShardCR {
21282138
tn->log(1, SSTR("failed to parse bucket shard: "
21292139
<< log_iter->entry.key));
21302140
marker_tracker->try_update_high_marker(log_iter->log_id, 0,
2131-
log_iter->log_timestamp, last_update);
2141+
log_iter->log_timestamp);
21322142
continue;
21332143
}
21342144
if (!marker_tracker->start(log_iter->log_id, 0,
@@ -4252,7 +4262,7 @@ class RGWBucketFullSyncMarkerTrack : public RGWSyncShardMarkerTrack<rgw_obj_key,
42524262
{}
42534263

42544264

4255-
RGWCoroutine *store_marker(const rgw_obj_key& new_marker, uint64_t index_pos, const real_time& timestamp, const real_time& last_update) override {
4265+
RGWCoroutine *store_marker(const rgw_obj_key& new_marker, uint64_t index_pos, const real_time& timestamp) override {
42564266
sync_status.full.position = new_marker;
42574267
sync_status.full.count = index_pos;
42584268

@@ -4353,7 +4363,7 @@ class RGWBucketIncSyncShardMarkerTrack : public RGWSyncShardMarkerTrack<string,
43534363

43544364
const rgw_raw_obj& get_obj() const { return obj; }
43554365

4356-
RGWCoroutine* store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp, const real_time& last_update) override {
4366+
RGWCoroutine* store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp) override {
43574367
sync_marker.position = new_marker;
43584368
sync_marker.timestamp = timestamp;
43594369

src/rgw/driver/rados/rgw_sync.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ class RGWMetaSyncShardMarkerTrack : public RGWSyncShardMarkerTrack<string, strin
12561256
sync_marker(_marker),
12571257
tn(_tn){}
12581258

1259-
RGWCoroutine *store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp, const real_time& last_update) override {
1259+
RGWCoroutine *store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp) override {
12601260
sync_marker.marker = new_marker;
12611261
if (index_pos > 0) {
12621262
sync_marker.pos = index_pos;

src/rgw/driver/rados/rgw_sync.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,9 @@ class RGWSyncShardMarkerTrack {
343343
struct marker_entry {
344344
uint64_t pos;
345345
real_time timestamp;
346-
real_time last_update;
347346

348347
marker_entry() : pos(0) {}
349-
marker_entry(uint64_t _p, const real_time& _ts, const real_time& _lu = {}) : pos(_p), timestamp(_ts), last_update(_lu) {}
348+
marker_entry(uint64_t _p, const real_time& _ts) : pos(_p), timestamp(_ts) {}
350349
};
351350
typename std::map<T, marker_entry> pending;
352351

@@ -360,7 +359,7 @@ class RGWSyncShardMarkerTrack {
360359
protected:
361360
typename std::set<K> need_retry_set;
362361

363-
virtual RGWCoroutine *store_marker(const T& new_marker, uint64_t index_pos, const real_time& timestamp, const real_time& last_update) = 0;
362+
virtual RGWCoroutine *store_marker(const T& new_marker, uint64_t index_pos, const real_time& timestamp) = 0;
364363
virtual RGWOrderCallCR *allocate_order_control_cr() = 0;
365364
virtual void handle_finish(const T& marker) { }
366365

@@ -372,16 +371,16 @@ class RGWSyncShardMarkerTrack {
372371
}
373372
}
374373

375-
bool start(const T& pos, int index_pos, const real_time& timestamp, const real_time& last_update = {}) {
374+
bool start(const T& pos, int index_pos, const real_time& timestamp) {
376375
if (pending.find(pos) != pending.end()) {
377376
return false;
378377
}
379-
pending[pos] = marker_entry(index_pos, timestamp, last_update);
378+
pending[pos] = marker_entry(index_pos, timestamp);
380379
return true;
381380
}
382381

383-
void try_update_high_marker(const T& pos, int index_pos, const real_time& timestamp, const real_time& last_update = {}) {
384-
finish_markers[pos] = marker_entry(index_pos, timestamp, last_update);
382+
void try_update_high_marker(const T& pos, int index_pos, const real_time& timestamp) {
383+
finish_markers[pos] = marker_entry(index_pos, timestamp);
385384
}
386385

387386
RGWCoroutine *finish(const T& pos) {
@@ -437,7 +436,7 @@ class RGWSyncShardMarkerTrack {
437436
--i;
438437
const T& high_marker = i->first;
439438
marker_entry& high_entry = i->second;
440-
RGWCoroutine *cr = order(store_marker(high_marker, high_entry.pos, high_entry.timestamp, high_entry.last_update));
439+
RGWCoroutine *cr = order(store_marker(high_marker, high_entry.pos, high_entry.timestamp));
441440
finish_markers.erase(finish_markers.begin(), last);
442441
return cr;
443442
}

0 commit comments

Comments
 (0)