forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
86565: roachpb: add gc hint replica state field and let delete range set it r=tbg,erikgrinaker a=aliher1911 This commit adds a test that peforms range split and merge during cluster upgrade. This is covering test cases where raft state gets additional information in new versions and we must ensure that replicas don't diverge in the process of upgrade. Release justification: Commit adds extra tests only. Release note: None ---- When cmd_delete_range deletes the whole range it can give a GC hint so that mvcc gc could optimize large number ranges that would be collected using gc clear range requests. Processing those requests together in a quick succession would reduce compaction load on pebble. Release justification: This change is safe as it adds handling for the new type of request that doesn't interact with any existing functionality. Release note: None ---- This commit adds a version gate GCHintInReplicaState for GC Hint. This is needed to avoid divergence of replicas when older followers don't yet update state with a new field value. Release justification: This commit adds a version gate for a new feature Release note: None ---- This commit adds a gc hint field to replica state that is backed by a replicated range local key. This field could be set explicitly by client to indicate that all data in the range is ripe for deletion at hint timestamp. MVCC GC could use this information to optimize clear range requests. Release justification: this commit is safe because it adds a new request type and a new status field that doesn't interfere with existing functionality. Release note: None Co-authored-by: Oleg Afanasyev <[email protected]>
- Loading branch information
Showing
28 changed files
with
525 additions
and
24 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,81 @@ | ||
// Copyright 2022 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_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/base" | ||
"github.com/cockroachdb/cockroach/pkg/kv" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver" | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/server" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDeleteRangeTombstoneSetsGCHint(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
ctx := context.Background() | ||
serv, _, _ := serverutils.StartServer(t, base.TestServerArgs{ | ||
Knobs: base.TestingKnobs{ | ||
Store: &kvserver.StoreTestingKnobs{ | ||
DisableMergeQueue: true, | ||
DisableSplitQueue: true, | ||
}, | ||
}, | ||
}) | ||
s := serv.(*server.TestServer) | ||
defer s.Stopper().Stop(ctx) | ||
|
||
store, err := s.Stores().GetStore(s.GetFirstStoreID()) | ||
require.NoError(t, err) | ||
|
||
key := roachpb.Key("b") | ||
content := []byte("test") | ||
|
||
repl := store.LookupReplica(roachpb.RKey(key)) | ||
gcHint := repl.GetGCHint() | ||
require.True(t, gcHint.LatestRangeDeleteTimestamp.IsEmpty(), "gc hint should be empty by default") | ||
|
||
pArgs := &roachpb.PutRequest{ | ||
RequestHeader: roachpb.RequestHeader{ | ||
Key: key, | ||
}, | ||
Value: roachpb.MakeValueFromBytes(content), | ||
} | ||
if _, pErr := kv.SendWrapped(ctx, s.DistSender(), pArgs); pErr != nil { | ||
t.Fatal(pErr) | ||
} | ||
|
||
r, err := s.LookupRange(key) | ||
require.NoError(t, err, "failed to lookup range") | ||
|
||
drArgs := &roachpb.DeleteRangeRequest{ | ||
UpdateRangeDeleteGCHint: true, | ||
UseRangeTombstone: true, | ||
RequestHeader: roachpb.RequestHeader{ | ||
Key: r.StartKey.AsRawKey(), | ||
EndKey: r.EndKey.AsRawKey(), | ||
}, | ||
} | ||
if _, pErr := kv.SendWrapped(ctx, s.DistSender(), drArgs); pErr != nil { | ||
t.Fatal(pErr) | ||
} | ||
|
||
gcHint = repl.GetGCHint() | ||
require.True(t, !gcHint.LatestRangeDeleteTimestamp.IsEmpty(), "gc hint was not set by delete range") | ||
} |
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.