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

txnwait: do not require vmodule to log deadlocks in a workload #99315

Merged
merged 1 commit into from
Jun 25, 2024
Merged
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
18 changes: 14 additions & 4 deletions pkg/kv/kvserver/txnwait/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ type TestingKnobs struct {
//
// Queue is thread safe.
type Queue struct {
cfg Config
mu struct {
cfg Config
every log.EveryN // dictates logging for transaction aborts resulting from deadlock detection
mu struct {
syncutil.RWMutex
txns map[uuid.UUID]*pendingTxn
queries map[uuid.UUID]*waitingQueries
Expand All @@ -273,7 +274,10 @@ type Queue struct {

// NewQueue instantiates a new Queue.
func NewQueue(cfg Config) *Queue {
return &Queue{cfg: cfg}
return &Queue{
cfg: cfg,
every: log.Every(1 * time.Second),
}
}

// Enable allows transactions to be enqueued and waiting pushers
Expand Down Expand Up @@ -754,9 +758,15 @@ func (q *Queue) waitForPush(
// Break the deadlock if the pusher has higher priority.
p1, p2 := pusheePriority, pusherPriority
if p1 < p2 || (p1 == p2 && bytes.Compare(req.PusheeTxn.ID.GetBytes(), req.PusherTxn.ID.GetBytes()) < 0) {
// NB: It's useful to have logs indicating the transactions involved
// in a deadlock, but we don't want these to be too spammy.
level := log.Level(1)
if q.every.ShouldLog() {
level = 0 // will behave like a log.Infof
}
log.VEventf(
ctx,
1,
level,
"%s breaking deadlock by force push of %s; dependencies=%s",
req.PusherTxn.ID.Short(),
req.PusheeTxn.ID.Short(),
Expand Down
Loading