-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
50265: kvserver: prevent follower reads while a range is subsumed r=nvanbenschoten,andreimatei a=aayushshah15 Before this commit, during a merge, the RHS leaseholder’s store could continue broadcasting (actionable) closed timestamp updates even after it had been subsumed. This allowed the followers to be able to serve follower reads past the subsumption time of RHS. Additionally, after the merge, if the LHS had a lower closed timestamp than the RHS, it could allow writes to the keyspan owned by RHS at timestamps lower than the RHS’s max closed timestamp. This commit fixes this bug by requiring that the followers catch up to a LeaseAppliedIndex that belongs to the entry succeeding the Subsume request. Fixes #44878 Release note (bug fix): Fixed a rare bug that could cause actionable closed timestamps to effectively regress over a given keyspan. This could in turn lead to a serializability violation when using follower reads. This was due to ill-defined interactions between range merges and the closed timestamp subsystem. 52241: backupccl: direct spans after split and scatter r=pbardea a=pbardea The AdminScatter request sent in the SplitAndScatterProcessor returns the lease information of the range after the scatter requst has completed. The SplitAndScatterProcessor now looks at this field to properly direct the spans to the appropriate RestoreData processor. Release note: None. 52263: cli: change label on printed build revision r=dt a=dbist Fixes #52249 Release note (cli change): update label used for commit ID in printed version info Co-authored-by: Aayush Shah <[email protected]> Co-authored-by: Paul Bardea <[email protected]> Co-authored-by: Artem Ervits <[email protected]>
- Loading branch information
Showing
26 changed files
with
1,008 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package batcheval | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/spanset" | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/storage/enginepb" | ||
"github.com/cockroachdb/cockroach/pkg/util/hlc" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/uuid" | ||
) | ||
|
||
// TestRequestsSerializeWithSubsume ensures that no request can be evaluated | ||
// concurrently with a Subsume request. For more details, refer to the big | ||
// comment block at the end of Subsume() in cmd_subsume.go. | ||
// | ||
// NB: This test is broader than it really needs to be. A more precise statement | ||
// of the condition necessary to uphold the invariant mentioned in Subsume() is: | ||
// No request that bumps the lease applied index of a range can be evaluated | ||
// concurrently with a Subsume request. | ||
func TestRequestsSerializeWithSubsume(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
var subsumeLatchSpans, subsumeLockSpans, otherLatchSpans, otherLockSpans spanset.SpanSet | ||
startKey := []byte(`a`) | ||
endKey := []byte(`b`) | ||
desc := &roachpb.RangeDescriptor{ | ||
RangeID: 0, | ||
StartKey: startKey, | ||
EndKey: endKey, | ||
} | ||
testTxn := &roachpb.Transaction{ | ||
TxnMeta: enginepb.TxnMeta{ | ||
ID: uuid.FastMakeV4(), | ||
Key: startKey, | ||
WriteTimestamp: hlc.Timestamp{WallTime: 1}, | ||
}, | ||
Name: "test txn", | ||
} | ||
header := roachpb.Header{Txn: testTxn} | ||
subsumeRequest := &roachpb.SubsumeRequest{RightDesc: *desc} | ||
declareKeysSubsume(desc, header, subsumeRequest, &subsumeLatchSpans, &subsumeLockSpans) | ||
for method, command := range cmds { | ||
t.Run(method.String(), func(t *testing.T) { | ||
otherRequest := roachpb.CreateRequest(method) | ||
if queryTxnReq, ok := otherRequest.(*roachpb.QueryTxnRequest); ok { | ||
// QueryTxnRequest declares read-only access over the txn record of the txn | ||
// it is supposed to query and not the txn that sent it. We fill this Txn | ||
// field in here to prevent it from being nil and leading to the txn key | ||
// falling outside our test range's keyspace. | ||
queryTxnReq.Txn = testTxn.TxnMeta | ||
} | ||
|
||
otherRequest.SetHeader(roachpb.RequestHeader{ | ||
Key: startKey, | ||
EndKey: endKey, | ||
Sequence: 0, | ||
}) | ||
|
||
command.DeclareKeys(desc, header, otherRequest, &otherLatchSpans, &otherLockSpans) | ||
if !subsumeLatchSpans.Intersects(&otherLatchSpans) { | ||
t.Errorf("%s does not serialize with Subsume", method) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.