Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concurrency: move finalizedTxnCache into lock table #57947

Merged
merged 1 commit into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions pkg/kv/kvserver/concurrency/concurrency_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ type lockTable interface {
// txn.WriteTimestamp.
UpdateLocks(*roachpb.LockUpdate) error

// Informs the lock table that a transaction is finalized. This is used
// by the lock table in a best-effort manner to avoid waiting on locks
// of finalized transactions and telling the caller via
// lockTableGuard.ResolveBeforeEvaluation to resolve a batch of intents.
TransactionIsFinalized(*roachpb.Transaction)

// String returns a debug string representing the state of the lockTable.
String() string
}
Expand All @@ -588,6 +594,11 @@ type lockTableGuard interface {

// CurState returns the latest waiting state.
CurState() waitingState

// ResolveBeforeScanning lists the locks to resolve before scanning again.
// This must be called after the waiting state has transitioned to
// doneWaiting.
ResolveBeforeScanning() []roachpb.LockUpdate
}

// lockTableWaiter is concerned with waiting in lock wait-queues for locks held
Expand Down Expand Up @@ -646,11 +657,6 @@ type lockTableWaiter interface {
// and, in turn, remove this method. This will likely fall out of pulling
// all replicated locks into the lockTable.
WaitOnLock(context.Context, Request, *roachpb.Intent) *Error

// ClearCaches wipes all caches maintained by the lockTableWaiter. This is
// primarily used to recover memory when a replica loses a lease. However,
// it is also used in tests to reset the state of the lockTableWaiter.
ClearCaches()
}

// txnWaitQueue holds a collection of wait-queues for transaction records.
Expand Down
12 changes: 5 additions & 7 deletions pkg/kv/kvserver/concurrency/concurrency_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func (c *Config) initDefaults() {
func NewManager(cfg Config) Manager {
cfg.initDefaults()
m := new(managerImpl)
lt := &lockTableImpl{
maxLocks: cfg.MaxLockTableSize,
}
*m = managerImpl{
// TODO(nvanbenschoten): move pkg/storage/spanlatch to a new
// pkg/storage/concurrency/latch package. Make it implement the
Expand All @@ -82,14 +85,12 @@ func NewManager(cfg Config) Manager {
cfg.SlowLatchGauge,
),
},
lt: &lockTableImpl{
maxLocks: cfg.MaxLockTableSize,
},
lt: lt,
ltw: &lockTableWaiterImpl{
st: cfg.Settings,
stopper: cfg.Stopper,
ir: cfg.IntentResolver,
lm: m,
lt: lt,
disableTxnPushing: cfg.DisableTxnPushing,
},
// TODO(nvanbenschoten): move pkg/storage/txnwait to a new
Expand Down Expand Up @@ -344,9 +345,6 @@ func (m *managerImpl) OnRangeLeaseUpdated(seq roachpb.LeaseSequence, isLeasehold
const disable = true
m.lt.Clear(disable)
m.twq.Clear(disable)
// Also clear caches, since they won't be needed any time soon and
// consume memory.
m.ltw.ClearCaches()
}
}

Expand Down
Loading