Skip to content

Commit 1ba2b8d

Browse files
craig[bot]pav-kv
andcommitted
Merge #155515
155515: batcheval: downgrade ReadWriter to Reader r=ssd a=pav-kv Epic: none Release note: none Co-authored-by: Pavel Kalinnikov <[email protected]>
2 parents 1ace7f9 + 4f6ba67 commit 1ba2b8d

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

pkg/kv/kvserver/batcheval/cmd_add_sstable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,12 @@ func EvalAddSSTable(
468468
func computeSSTStatsDiffWithFallback(
469469
ctx context.Context,
470470
sst []byte,
471-
readWriter storage.ReadWriter,
471+
reader storage.Reader,
472472
nowNanos int64,
473473
start, end storage.MVCCKey,
474474
) (enginepb.MVCCStats, error) {
475475
stats, err := storage.ComputeSSTStatsDiff(
476-
ctx, sst, readWriter, nowNanos, start, end)
476+
ctx, sst, reader, nowNanos, start, end)
477477
if errors.IsAny(err, storage.ComputeSSTStatsDiffReaderHasRangeKeys, storage.ComputeStatsDiffViolation) {
478478
log.KvExec.Warningf(ctx, "computing SST stats as estimates because of ComputeSSTStatsDiff error: %s", err)
479479
sstStats, err := computeSSTStats(ctx, sst, nowNanos)

pkg/kv/kvserver/batcheval/cmd_clear_range.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func ClearRange(
168168
// path of simply subtracting the non-system values is accurate.
169169
// Returns the delta stats.
170170
func computeStatsDelta(
171-
ctx context.Context, readWriter storage.ReadWriter, cArgs CommandArgs, from, to roachpb.Key,
171+
ctx context.Context, reader storage.Reader, cArgs CommandArgs, from, to roachpb.Key,
172172
) (enginepb.MVCCStats, error) {
173173
desc := cArgs.EvalCtx.Desc()
174174
var delta enginepb.MVCCStats
@@ -189,7 +189,7 @@ func computeStatsDelta(
189189
// If we can't use the fast stats path, or race test is enabled, compute stats
190190
// across the key span to be cleared.
191191
if !entireRange || util.RaceEnabled {
192-
computed, err := storage.ComputeStats(ctx, readWriter, from, to, delta.LastUpdateNanos)
192+
computed, err := storage.ComputeStats(ctx, reader, from, to, delta.LastUpdateNanos)
193193
if err != nil {
194194
return enginepb.MVCCStats{}, err
195195
}
@@ -214,7 +214,7 @@ func computeStatsDelta(
214214
if !entireRange {
215215
leftPeekBound, rightPeekBound := rangeTombstonePeekBounds(
216216
from, to, desc.StartKey.AsRawKey(), desc.EndKey.AsRawKey())
217-
rkIter, err := readWriter.NewMVCCIterator(ctx, storage.MVCCKeyIterKind, storage.IterOptions{
217+
rkIter, err := reader.NewMVCCIterator(ctx, storage.MVCCKeyIterKind, storage.IterOptions{
218218
KeyTypes: storage.IterKeyTypeRangesOnly,
219219
LowerBound: leftPeekBound,
220220
UpperBound: rightPeekBound,

pkg/kv/kvserver/replica_write.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ func (r *Replica) evaluateWriteBatchWrapper(
746746
ui uncertainty.Interval,
747747
omitInRangefeeds bool,
748748
) (storage.Batch, *kvpb.BatchResponse, result.Result, *kvpb.Error) {
749-
batch, opLogger := r.newBatchedEngine(ba, g)
749+
batch, opLogger := r.newBatchedEngine(g)
750750
now := timeutil.Now()
751751
br, res, pErr := evaluateBatch(ctx, idKey, batch, rec, ms, ba, g, st, ui, readWrite, omitInRangefeeds)
752752
r.store.metrics.ReplicaWriteBatchEvaluationLatency.RecordValue(timeutil.Since(now).Nanoseconds())
@@ -764,9 +764,7 @@ func (r *Replica) evaluateWriteBatchWrapper(
764764
// are enabled, it also returns an engine.OpLoggerBatch. If non-nil, then this
765765
// OpLogger is attached to the returned engine.Batch, recording all operations.
766766
// Its recording should be attached to the Result of request evaluation.
767-
func (r *Replica) newBatchedEngine(
768-
ba *kvpb.BatchRequest, g *concurrency.Guard,
769-
) (storage.Batch, *storage.OpLoggerBatch) {
767+
func (r *Replica) newBatchedEngine(g *concurrency.Guard) (storage.Batch, *storage.OpLoggerBatch) {
770768
batch := r.store.TODOEngine().NewBatch()
771769
if !batch.ConsistentIterators() {
772770
// This is not currently needed for correctness, but future optimizations

0 commit comments

Comments
 (0)