Skip to content

Commit

Permalink
Merge #117304
Browse files Browse the repository at this point in the history
117304: kv: bump ReplicaChecksumVersion, disable cross v23.2/v24.1 consistency checks r=nvanbenschoten a=nvanbenschoten

Informs #101938.
Fixes #117302.

This commit bumps the ReplicaChecksumVersion to disable replica consistency checks between v23.2 and v24.1 nodes when in a mixed-version cluster. This avoids the backwards incompatibility discussed in #117302.

While here and permitted to change the replica consistency check logic, we unset the Synthetic flag from RangeAppliedState.RaftClosedTimestamp during stats-only consistency checks. This form of consistency check is rarely used, but this prevents it from causing trouble with #101938.

While here and allowed to change the consistency check hash computation, we also switch from using the LegacyTimestamp encoding to the Timestamp encoding for the hash contribution of MVCCKeys.

Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Jan 8, 2024
2 parents b39e708 + 63ca265 commit 5bd4ca0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_compute_checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func declareKeysComputeChecksum(

// ReplicaChecksumVersion versions the checksum computation. Requests silently no-op
// unless the versions between the requesting and requested replica are compatible.
const ReplicaChecksumVersion = 4
const ReplicaChecksumVersion = 5

// ComputeChecksum starts the process of computing a checksum on the replica at
// a particular snapshot. The checksum is later verified through a
Expand Down
16 changes: 9 additions & 7 deletions pkg/kv/kvserver/replica_consistency.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func CalcReplicaDigest(

// Iterate over all the data in the range.
var intBuf [8]byte
var legacyTimestamp hlc.LegacyTimestamp
var timestamp hlc.Timestamp
var timestampBuf []byte
var uuidBuf [uuid.Size]byte
hasher := sha512.New()
Expand Down Expand Up @@ -556,13 +556,13 @@ func CalcReplicaDigest(
if _, err := hasher.Write(unsafeKey.Key); err != nil {
return err
}
legacyTimestamp = unsafeKey.Timestamp.ToLegacyTimestamp()
if size := legacyTimestamp.Size(); size > cap(timestampBuf) {
timestamp = unsafeKey.Timestamp
if size := timestamp.Size(); size > cap(timestampBuf) {
timestampBuf = make([]byte, size)
} else {
timestampBuf = timestampBuf[:size]
}
if _, err := protoutil.MarshalToSizedBuffer(&legacyTimestamp, timestampBuf); err != nil {
if _, err := protoutil.MarshalToSizedBuffer(&timestamp, timestampBuf); err != nil {
return err
}
if _, err := hasher.Write(timestampBuf); err != nil {
Expand Down Expand Up @@ -600,13 +600,13 @@ func CalcReplicaDigest(
if _, err := hasher.Write(rangeKV.RangeKey.EndKey); err != nil {
return err
}
legacyTimestamp = rangeKV.RangeKey.Timestamp.ToLegacyTimestamp()
if size := legacyTimestamp.Size(); size > cap(timestampBuf) {
timestamp = rangeKV.RangeKey.Timestamp
if size := timestamp.Size(); size > cap(timestampBuf) {
timestampBuf = make([]byte, size)
} else {
timestampBuf = timestampBuf[:size]
}
if _, err := protoutil.MarshalToSizedBuffer(&legacyTimestamp, timestampBuf); err != nil {
if _, err := protoutil.MarshalToSizedBuffer(&timestamp, timestampBuf); err != nil {
return err
}
if _, err := hasher.Write(timestampBuf); err != nil {
Expand Down Expand Up @@ -680,6 +680,8 @@ func CalcReplicaDigest(
result.PersistedMS = rangeAppliedState.RangeStats.ToStats()

if statsOnly {
// Unset the synthetic flag, to ease the migration of deleting this field.
rangeAppliedState.RaftClosedTimestamp.Synthetic = false
b, err := protoutil.Marshal(rangeAppliedState)
if err != nil {
return nil, err
Expand Down
18 changes: 9 additions & 9 deletions pkg/kv/kvserver/testdata/replica_consistency_sha512
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
echo
----
checksum0: cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
checksum1: 67ba8f144d3c44d3ed82a5ec3758750642315af4de193c08a52a385e1027945cdd1c4c6a8f54112be2dd71d476924505fbe23fad8d40061df74c596dc583fd5f
checksum2: fc2a7a023637caa80bb923075f7d39451a328a3fe1357c08353e594810a0c22c56cad1b494662d02dcf3187e0ce44780e5b4b039ddcf5dee6ba974a542a4ffb3
checksum3: 05186bceae59a178713407959a26110715a1e299e6a9f1b37fc3e0f8d5a0c66bedbff8378a5f7b2e3d31c929a3b985088c7b714019b9eeacc50b17924925320a
checksum4: 4f5cc8176d559bfab8e52b74851b103fd73b9e713ce12aa380a16fe177ca6e21db75e3e85a58341ab437a5a766a071a2fe6e1f03841d334da7be2295794eb813
checksum5: 3c5d5856a626aa29913e9790033b9c23b6dc5e42bdf2e665f7b60f58bec495adc246bf4e5f5bf1acbfc78c713f2ec7820b4ba7202897bb9f824a0b7b9e9cc98d
checksum6: ebe7fd3f41a68c2608a8b10dcc9db3b39bdb6c097d3fd99411e89d75419bb58dd80faf9846aa5e47d8cabc9dcfc894c6ea58f7e035eaaa3ee55c31faed2c8000
checksum1: 83ae68fc9e2b083f5991c0a74bdaa712f3e794dc78b0bcf3467d8a7f7bba41c933f9834a05a98136a92dbabf1ea5662fa618fdadd9f8478357d28be0a53714e8
checksum2: 066a27ad115e2db378ef62071b0f1d1ebc01b43acdf7a52a596cc94ee243b2077fe83ffb9645bfb76c0bd34d3cfe884387ffe4aa9642d22e27c4cace4cce2ce9
checksum3: 49bb7da05ce4ae4a4f46037be263f99b2b2c25237c9f0d7af65f992f50c3adba7fe2dd8493bfab107d709b69119671357aeecfb065782ef3a84ea227d3f05cb6
checksum1: e5c540b13310b16f3c95ab9b034ec8cb1063e1835da926d121afde68ba6565a74cc0ddaa4e93c24def48257dcd26c23eaf2de9b0914e0d2b5d7cbb3e9e76306b
checksum2: 87a0299eb64cdd024e57bfc4d5e7cd8cb44ed50c67210cd0bdfb7ce2c51af5c7246cf6c98c99e3f3da529756215ff429bc0e44ce42550d329ac8973d1b48e043
checksum3: b4e3f966cd54697e2ead5ccf7882cf2786bbdfcb3d24179a255f824ca7cbec2292b6be489d6483a955cd089338c8b24594a89888a39e23e1d22d3a4f244cf3cb
checksum4: 81debb54eab57520c58f5170711ca981313cea58660a61d7d95f3ed20318229174ed23db02022c7517f6d746dccdb138fc13c8f25d5ad8770836a330b882298a
checksum5: 9c1597c841593465e3439b36c5074ebd21c20425f0cc67f978013687a56e3baec5a76cfe80973127068f5d9fef842c716c7d00dc169e1a0d346f643b89b49bdd
checksum6: fef4ce9680239f201ba941b2640da6efd19a39fc1276d25f60393bec2a09041a5317bbc6fdd980bfd33e61dd9edec98c3a187f3e477fa68e0c4b3fcd63826317
checksum1: a9bb377cbe705a7fa4611007a0186868884bf3ab3609831752e29c69421116652e8ddda6f95c1e8a9319aeda5338c3729edd389798e7c36960f4eb84e6899031
checksum2: dd3f0c52cf0db6a9fd72d2f000fd492fd71b48ae9f272f018a7014860ce57111c6441a6057ee26a956d48494c1fcb2b371b16e44163e99104fec33f82d35eeaf
checksum3: d9eb862476f34e9d589a7c1a4a47f0c3f6e110e07c6adea29a22517600f37e44f2a2b5b5391342bbd7999c904099257daae77b4025a15fe77841c65371d314f5
stats: {
"liveBytes": "53",
"liveCount": "2",
Expand Down

0 comments on commit 5bd4ca0

Please sign in to comment.