Skip to content

Commit

Permalink
kv: rename MaxIntentsPerWriteIntentError to MaxIntentsPerLockConflict…
Browse files Browse the repository at this point in the history
…Error

Rename and update comments.

Epic: None
Release note: None
  • Loading branch information
nvanbenschoten committed Aug 22, 2023
1 parent 45fd366 commit d80a271
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_add_sstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func EvalAddSSTable(
}

var statsDelta enginepb.MVCCStats
maxIntents := storage.MaxIntentsPerWriteIntentError.Get(&cArgs.EvalCtx.ClusterSettings().SV)
maxIntents := storage.MaxIntentsPerLockConflictError.Get(&cArgs.EvalCtx.ClusterSettings().SV)
checkConflicts := args.DisallowConflicts || args.DisallowShadowing ||
!args.DisallowShadowingBelow.IsEmpty()
if checkConflicts {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_clear_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func ClearRange(
// txns. Otherwise, txn recovery would fail to find these intents and
// consider the txn incomplete, uncommitting it and its writes (even those
// outside of the cleared range).
maxIntents := storage.MaxIntentsPerWriteIntentError.Get(&cArgs.EvalCtx.ClusterSettings().SV)
maxIntents := storage.MaxIntentsPerLockConflictError.Get(&cArgs.EvalCtx.ClusterSettings().SV)
intents, err := storage.ScanIntents(ctx, readWriter, from, to, maxIntents, 0)
if err != nil {
return result.Result{}, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_delete_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func DeleteRange(

leftPeekBound, rightPeekBound := rangeTombstonePeekBounds(
args.Key, args.EndKey, desc.StartKey.AsRawKey(), desc.EndKey.AsRawKey())
maxIntents := storage.MaxIntentsPerWriteIntentError.Get(&cArgs.EvalCtx.ClusterSettings().SV)
maxIntents := storage.MaxIntentsPerLockConflictError.Get(&cArgs.EvalCtx.ClusterSettings().SV)

// If no predicate parameters are passed, use the fast path. If we're
// deleting the entire Raft range, use an even faster path that avoids a
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func evalExport(
}

var maxIntents uint64
if m := storage.MaxIntentsPerWriteIntentError.Get(&cArgs.EvalCtx.ClusterSettings().SV); m > 0 {
if m := storage.MaxIntentsPerLockConflictError.Get(&cArgs.EvalCtx.ClusterSettings().SV); m > 0 {
maxIntents = uint64(m)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_reverse_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ReverseScan(
ScanStats: cArgs.ScanStats,
Uncertainty: cArgs.Uncertainty,
MaxKeys: h.MaxSpanRequestKeys,
MaxIntents: storage.MaxIntentsPerWriteIntentError.Get(&cArgs.EvalCtx.ClusterSettings().SV),
MaxIntents: storage.MaxIntentsPerLockConflictError.Get(&cArgs.EvalCtx.ClusterSettings().SV),
TargetBytes: h.TargetBytes,
AllowEmpty: h.AllowEmpty,
WholeRowsOfSize: h.WholeRowsOfSize,
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Scan(
ScanStats: cArgs.ScanStats,
Uncertainty: cArgs.Uncertainty,
MaxKeys: h.MaxSpanRequestKeys,
MaxIntents: storage.MaxIntentsPerWriteIntentError.Get(&cArgs.EvalCtx.ClusterSettings().SV),
MaxIntents: storage.MaxIntentsPerLockConflictError.Get(&cArgs.EvalCtx.ClusterSettings().SV),
TargetBytes: h.TargetBytes,
AllowEmpty: h.AllowEmpty,
WholeRowsOfSize: h.WholeRowsOfSize,
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/replica_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (r *Replica) canDropLatchesBeforeEval(
ctx, 3, "can drop latches early for batch (%v); scanning lock table first to detect conflicts", ba,
)

maxIntents := storage.MaxIntentsPerWriteIntentError.Get(&r.store.cfg.Settings.SV)
maxIntents := storage.MaxIntentsPerLockConflictError.Get(&r.store.cfg.Settings.SV)
var intents []roachpb.Intent
// Check if any of the requests within the batch need to resolve any intents
// or if any of them need to use an intent interleaving iterator.
Expand Down
16 changes: 8 additions & 8 deletions pkg/kv/kvserver/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2306,9 +2306,9 @@ func TestStoreScanIntents(t *testing.T) {
// limits.
//
// The test proceeds as follows: a writer lays down more than
// `MaxIntentsPerWriteIntentErrorDefault` intents, and a reader is expected to
// `MaxIntentsPerLockConflictError` intents, and a reader is expected to
// encounter these intents and raise a `LockConflictError` with exactly
// `MaxIntentsPerWriteIntentErrorDefault` intents in the error.
// `MaxIntentsPerLockConflictError` intents in the error.
func TestStoreScanIntentsRespectsLimit(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
Expand All @@ -2331,10 +2331,10 @@ func TestStoreScanIntentsRespectsLimit(t *testing.T) {
ctx context.Context, ba *kvpb.BatchRequest, pErr *kvpb.Error,
) {
if errors.HasType(pErr.GoError(), (*kvpb.LockConflictError)(nil)) {
// Assert that the LockConflictError has MaxIntentsPerWriteIntentErrorIntents.
// Assert that the LockConflictError has MaxIntentsPerLockConflictError intents.
if trap := interceptLockConflictErrors.Load(); trap != nil && trap.(bool) {
require.Equal(
t, storage.MaxIntentsPerWriteIntentErrorDefault,
t, storage.MaxIntentsPerLockConflictErrorDefault,
len(pErr.GetDetail().(*kvpb.LockConflictError).Intents),
)
interceptLockConflictErrors.Store(false)
Expand All @@ -2356,13 +2356,13 @@ func TestStoreScanIntentsRespectsLimit(t *testing.T) {
var wg sync.WaitGroup
wg.Add(2)

// Lay down more than `MaxIntentsPerWriteIntentErrorDefault` intents.
// Lay down more than `MaxIntentsPerLockConflictErrorDefault` intents.
go func() {
defer wg.Done()
txn := newTransaction(
"test", roachpb.Key("test-key"), roachpb.NormalUserPriority, tc.Server(0).Clock(),
)
for j := 0; j < storage.MaxIntentsPerWriteIntentErrorDefault+10; j++ {
for j := 0; j < storage.MaxIntentsPerLockConflictErrorDefault+10; j++ {
var key roachpb.Key
key = append(key, keys.ScratchRangeMin...)
key = append(key, []byte(fmt.Sprintf("%d", j))...)
Expand All @@ -2385,10 +2385,10 @@ func TestStoreScanIntentsRespectsLimit(t *testing.T) {
}

// Now, expect a conflicting reader to encounter the intents and raise a
// LockConflictError with exactly `MaxIntentsPerWriteIntentErrorDefault`
// LockConflictError with exactly `MaxIntentsPerLockConflictErrorDefault`
// intents. See the TestingConcurrencyRetryFilter above.
var ba kv.Batch
for i := 0; i < storage.MaxIntentsPerWriteIntentErrorDefault+10; i += 10 {
for i := 0; i < storage.MaxIntentsPerLockConflictErrorDefault+10; i += 10 {
for _, key := range intentKeys[i : i+10] {
args := getArgs(key)
ba.AddRawRequest(&args)
Expand Down
14 changes: 7 additions & 7 deletions pkg/storage/mvcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ const (
// minimum total for a single store node must be under 2048 for Windows
// compatibility.
MinimumMaxOpenFiles = 1700
// MaxIntentsPerWriteIntentErrorDefault is the default value for maximum
// MaxIntentsPerLockConflictErrorDefault is the default value for maximum
// number of intents reported by ExportToSST and Scan operations in
// LockConflictError is set to half of the maximum lock table size.
// This value is subject to tuning in real environment as we have more data
// LockConflictError is set to half of the maximum lock table size. This
// value is subject to tuning in real environment as we have more data
// available.
MaxIntentsPerWriteIntentErrorDefault = 5000
MaxIntentsPerLockConflictErrorDefault = 5000
)

var minWALSyncInterval = settings.RegisterDurationSetting(
Expand Down Expand Up @@ -108,14 +108,14 @@ func CanUseMVCCRangeTombstones(ctx context.Context, st *cluster.Settings) bool {
MVCCRangeTombstonesEnabledInMixedClusters.Get(&st.SV)
}

// MaxIntentsPerWriteIntentError sets maximum number of intents returned in
// MaxIntentsPerLockConflictError sets maximum number of intents returned in
// LockConflictError in operations that return multiple intents per error.
// Currently it is used in Scan, ReverseScan, and ExportToSST.
var MaxIntentsPerWriteIntentError = settings.RegisterIntSetting(
var MaxIntentsPerLockConflictError = settings.RegisterIntSetting(
settings.TenantWritable,
"storage.mvcc.max_intents_per_error",
"maximum number of intents returned in error during export of scan requests",
MaxIntentsPerWriteIntentErrorDefault,
MaxIntentsPerLockConflictErrorDefault,
)

var rocksdbConcurrency = envutil.EnvOrDefaultInt(
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/mvcc_incremental_iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func assertExportedErrs(
ExportAllRevisions: revisions,
TargetSize: big,
MaxSize: big,
MaxIntents: uint64(MaxIntentsPerWriteIntentError.Default()),
MaxIntents: uint64(MaxIntentsPerLockConflictError.Default()),
StopMidKey: false,
}, &bytes.Buffer{})
require.Error(t, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/mvcc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6637,7 +6637,7 @@ func TestMVCCExportToSSTFailureIntentBatching(t *testing.T) {
ExportAllRevisions: true,
TargetSize: 0,
MaxSize: 0,
MaxIntents: uint64(MaxIntentsPerWriteIntentError.Default()),
MaxIntents: uint64(MaxIntentsPerLockConflictError.Default()),
StopMidKey: false,
}, &bytes.Buffer{})
if len(expectedIntentIndices) == 0 {
Expand All @@ -6657,15 +6657,15 @@ func TestMVCCExportToSSTFailureIntentBatching(t *testing.T) {
}

// Export range is fixed to k:["00010", "10000"), ts:(999, 2000] for all tests.
testDataCount := int(MaxIntentsPerWriteIntentError.Default() + 1)
testDataCount := int(MaxIntentsPerLockConflictError.Default() + 1)
testData := make([]testValue, testDataCount*2)
expectedErrors := make([]int, testDataCount)
for i := 0; i < testDataCount; i++ {
testData[i*2] = value(key(i*2+11), "value", ts(1000))
testData[i*2+1] = intent(key(i*2+12), "intent", ts(1001))
expectedErrors[i] = i*2 + 1
}
t.Run("Receive no more than limit intents", checkReportedErrors(testData, expectedErrors[:MaxIntentsPerWriteIntentError.Default()]))
t.Run("Receive no more than limit intents", checkReportedErrors(testData, expectedErrors[:MaxIntentsPerLockConflictError.Default()]))
}

// TestMVCCExportToSSTSplitMidKey verifies that split mid key in exports will
Expand Down

0 comments on commit d80a271

Please sign in to comment.