Skip to content

Commit

Permalink
kv: remove EvalContext.DB
Browse files Browse the repository at this point in the history
Related to cockroachdb#66486.

Command evaluation is meant to operate in a sandbox. It certainly
shouldn't have access to a DB handle.
  • Loading branch information
nvanbenschoten committed Jun 30, 2021
1 parent aff208f commit b2bed86
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
1 change: 0 additions & 1 deletion pkg/kv/kvserver/batcheval/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ go_library(
deps = [
"//pkg/clusterversion",
"//pkg/keys",
"//pkg/kv",
"//pkg/kv/kvserver/abortspan",
"//pkg/kv/kvserver/batcheval/result",
"//pkg/kv/kvserver/closedts",
Expand Down
5 changes: 0 additions & 5 deletions pkg/kv/kvserver/batcheval/eval_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"context"
"fmt"

"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/abortspan"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/closedts"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/concurrency"
Expand Down Expand Up @@ -53,7 +52,6 @@ type EvalContext interface {

Engine() storage.Engine
Clock() *hlc.Clock
DB() *kv.DB
AbortSpan() *abortspan.AbortSpan
GetConcurrencyManager() concurrency.Manager

Expand Down Expand Up @@ -178,9 +176,6 @@ func (m *mockEvalCtxImpl) Engine() storage.Engine {
func (m *mockEvalCtxImpl) Clock() *hlc.Clock {
return m.MockEvalCtx.Clock
}
func (m *mockEvalCtxImpl) DB() *kv.DB {
panic("unimplemented")
}
func (m *mockEvalCtxImpl) AbortSpan() *abortspan.AbortSpan {
return m.MockEvalCtx.AbortSpan
}
Expand Down
9 changes: 2 additions & 7 deletions pkg/kv/kvserver/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,6 @@ func (r *Replica) Clock() *hlc.Clock {
return r.store.Clock()
}

// DB returns the Replica's client DB.
func (r *Replica) DB() *kv.DB {
return r.store.DB()
}

// Engine returns the Replica's underlying Engine. In most cases the
// evaluation Batch should be used instead.
func (r *Replica) Engine() storage.Engine {
Expand Down Expand Up @@ -1647,7 +1642,7 @@ func (r *Replica) maybeWatchForMergeLocked(ctx context.Context) (bool, error) {
PusheeTxn: intent.Txn,
PushType: roachpb.PUSH_ABORT,
})
if err := r.DB().Run(ctx, b); err != nil {
if err := r.store.DB().Run(ctx, b); err != nil {
select {
case <-r.store.stopper.ShouldQuiesce():
// The server is shutting down. The error while pushing the
Expand Down Expand Up @@ -1682,7 +1677,7 @@ func (r *Replica) maybeWatchForMergeLocked(ctx context.Context) (bool, error) {
var getRes *roachpb.GetResponse
for retry := retry.Start(base.DefaultRetryOptions()); retry.Next(); {
metaKey := keys.RangeMetaKey(desc.EndKey)
res, pErr := kv.SendWrappedWith(ctx, r.DB().NonTransactionalSender(), roachpb.Header{
res, pErr := kv.SendWrappedWith(ctx, r.store.DB().NonTransactionalSender(), roachpb.Header{
// Use READ_UNCOMMITTED to avoid trying to resolve intents, since
// resolving those intents might involve sending requests to this
// range, and that could deadlock. See the comment on
Expand Down
6 changes: 0 additions & 6 deletions pkg/kv/kvserver/replica_eval_context_span.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"context"

"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/abortspan"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/batcheval"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/closedts"
Expand Down Expand Up @@ -72,11 +71,6 @@ func (rec *SpanSetReplicaEvalContext) Clock() *hlc.Clock {
return rec.i.Clock()
}

// DB returns the Replica's client DB.
func (rec *SpanSetReplicaEvalContext) DB() *kv.DB {
return rec.i.DB()
}

// GetConcurrencyManager returns the concurrency.Manager.
func (rec *SpanSetReplicaEvalContext) GetConcurrencyManager() concurrency.Manager {
return rec.i.GetConcurrencyManager()
Expand Down

0 comments on commit b2bed86

Please sign in to comment.