Skip to content

Commit

Permalink
query: increase logs to find deadlock issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggie1984 committed Dec 10, 2023
1 parent 42a196f commit 788e3f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions query/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package query

import (
"errors"
"fmt"
"time"

"github.com/btcsuite/btcd/wire"
Expand Down Expand Up @@ -43,6 +44,12 @@ func (q *queryJob) Index() uint64 {
return q.index
}

// String returns the string representation of the queryJob code.
func (q *queryJob) String() string {
return fmt.Sprintf("QueryJob(index=%v): tries=%v, timeout=%v, +"+
"request_msg: %v", q.index, q.tries, q.timeout, q.Req)
}

// jobResult is the final result of the worker's handling of the queryJob.
type jobResult struct {
job *queryJob
Expand Down
15 changes: 15 additions & 0 deletions query/workmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ Loop:
delete(currentQueries, result.job.index)
batch := currentBatches[batchNum]

log.Debugf("Job(%v) received a result=%v, "+
"batchNum=%v, batch=%v, pendingQueries=%v, "+
"pendingBatches=%v", result.job, result,
batchNum, batch, len(currentQueries),
len(currentBatches))

log.Debugf("Batch info: %v,%v,%v", batch.maxRetries,
batch.timeout, batch.noRetryMax)

switch {
// If the query ended because it was canceled, drop it.
case result.err == ErrJobCanceled:
Expand Down Expand Up @@ -434,6 +443,12 @@ Loop:
log.Debugf("Adding new batch(%d) of %d queries to "+
"work queue", batchIndex, len(batch.requests))

log.Debugf("Current queries to manage %d: %v",
len(currentQueries), currentQueries)

log.Debugf("Current batches to manage %d: %v",
len(currentBatches), currentBatches)

for _, q := range batch.requests {
heap.Push(work, &queryJob{
index: queryIndex,
Expand Down

0 comments on commit 788e3f7

Please sign in to comment.