diff options
author | Alistair Coles <alistairncoles@gmail.com> | 2023-02-16 18:39:36 +0000 |
---|---|---|
committer | Clay Gerrard <clay.gerrard@gmail.com> | 2023-02-27 07:27:32 -0600 |
commit | 2fe18b24cd7e709c8712fcda7369b0715a21fb89 (patch) | |
tree | 49eb524239b64d2281a974bc97f39e1f825f0d87 /swift/obj | |
parent | 8778b2c1328226cbcb67cd38fbb9e0771e2162fc (diff) | |
download | swift-2fe18b24cd7e709c8712fcda7369b0715a21fb89.tar.gz |
ssync: fix decoding of ts_meta when ts_data has offset
The SsyncSender encodes object file timestamps in a compact form and
the SsyncReceiver decodes the timestamps and compares them to its
object file set.
The encoding represents the meta file timestamp as a delta from the
data file timestamp, NOT INCLUDING the data file timestamp offset.
Previously, the decoding was erroneously calculating the meta file
timestamp as the sum of the delta plus the data file timestamp
INCLUDING the offset.
For example, if the SssyncSender has object file timestamps:
ts_data = t0_1.data
ts_meta = t1.data
then the receiver would erroneously perceive that the sender has:
ts_data = t0_1.data
ts_meta = t1_1.data
As described in the referenced bug report, this erroneous decoding
could cause the SsyncReceiver to request that the SsyncSender sync an
object that is already in sync, which results in a 409 Conflict at the
receiver. The 409 causes the ssync session to terminate, and the same
process repeats on the next attempt.
Closes-Bug: #2007643
Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Change-Id: I74a0aac0ac29577026743f87f4b654d85e8fcc80
Diffstat (limited to 'swift/obj')
-rw-r--r-- | swift/obj/ssync_receiver.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/swift/obj/ssync_receiver.py b/swift/obj/ssync_receiver.py index b1e2ab072..87fb8b102 100644 --- a/swift/obj/ssync_receiver.py +++ b/swift/obj/ssync_receiver.py @@ -45,8 +45,8 @@ def decode_missing(line): parts = line.decode('ascii').split() result['object_hash'] = urllib.parse.unquote(parts[0]) t_data = urllib.parse.unquote(parts[1]) - result['ts_data'] = Timestamp(t_data) - result['ts_meta'] = result['ts_ctype'] = result['ts_data'] + result['ts_data'] = ts_data = Timestamp(t_data) + result['ts_meta'] = result['ts_ctype'] = ts_data result['durable'] = True # default to True in case this key isn't sent if len(parts) > 2: # allow for a comma separated list of k:v pairs to future-proof @@ -54,9 +54,13 @@ def decode_missing(line): for item in [subpart for subpart in subparts if ':' in subpart]: k, v = item.split(':') if k == 'm': - result['ts_meta'] = Timestamp(t_data, delta=int(v, 16)) + # ignore ts_data offset when calculating ts_meta + result['ts_meta'] = Timestamp(ts_data.normal, + delta=int(v, 16)) elif k == 't': - result['ts_ctype'] = Timestamp(t_data, delta=int(v, 16)) + # ignore ts_data offset when calculating ts_ctype + result['ts_ctype'] = Timestamp(ts_data.normal, + delta=int(v, 16)) elif k == 'durable': result['durable'] = utils.config_true_value(v) return result |