Skip to content

Commit ca5f91e

Browse files
committed
query: increase logs to find deadlock issue.
1 parent 42a196f commit ca5f91e

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

query/worker.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package query
22

33
import (
44
"errors"
5+
"fmt"
56
"time"
67

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

47+
// String returns the string representation of the queryJob code.
48+
func (q *queryJob) String() string {
49+
return fmt.Sprintf("QueryJob(index=%v): tries=%v, timeout=%v, +"+
50+
"request_msg: %v", q.index, q.tries, q.timeout, q.Req)
51+
}
52+
4653
// jobResult is the final result of the worker's handling of the queryJob.
4754
type jobResult struct {
4855
job *queryJob
@@ -96,7 +103,7 @@ func (w *worker) Run(results chan<- *jobResult, quit <-chan struct{}) {
96103
select {
97104
// Poll a new job from the nextJob channel.
98105
case job = <-w.nextJob:
99-
log.Tracef("Worker %v picked up job with index %v",
106+
log.Infof("Worker %v picked up job with index %v",
100107
peer.Addr(), job.Index())
101108

102109
// Ignore any message received while not working on anything.
@@ -154,7 +161,7 @@ func (w *worker) Run(results chan<- *jobResult, quit <-chan struct{}) {
154161
job.Req, resp, peer.Addr(),
155162
)
156163

157-
log.Tracef("Worker %v handled msg %T while "+
164+
log.Infof("Worker %v handled msg %T while "+
158165
"waiting for response to %T (job=%v). "+
159166
"Finished=%v, progressed=%v",
160167
peer.Addr(), resp, job.Req, job.Index(),
@@ -189,7 +196,7 @@ func (w *worker) Run(results chan<- *jobResult, quit <-chan struct{}) {
189196
// The query did experience a timeout and will
190197
// be given to someone else.
191198
jobErr = ErrQueryTimeout
192-
log.Tracef("Worker %v timeout for request %T "+
199+
log.Infof("Worker %v timeout for request %T "+
193200
"with job index %v", peer.Addr(),
194201
job.Req, job.Index())
195202

query/workmanager.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ Loop:
308308
delete(currentQueries, result.job.index)
309309
batch := currentBatches[batchNum]
310310

311+
log.Infof("Job(%v) received a result=%v, "+
312+
"batchNum=%v, batch=%v, pendingQueries=%v, "+
313+
"pendingBatches=%v", result.job, result,
314+
batchNum, batch, len(currentQueries),
315+
len(currentBatches))
316+
317+
log.Infof("Batch info: %v,%v,%v", batch.maxRetries,
318+
batch.timeout, batch.noRetryMax)
319+
311320
switch {
312321
// If the query ended because it was canceled, drop it.
313322
case result.err == ErrJobCanceled:
@@ -431,9 +440,15 @@ Loop:
431440
// Add all new queries in the batch to our work queue,
432441
// with priority given by the order they were
433442
// scheduled.
434-
log.Debugf("Adding new batch(%d) of %d queries to "+
443+
log.Infof("Adding new batch(%d) of %d queries to "+
435444
"work queue", batchIndex, len(batch.requests))
436445

446+
log.Infof("Current queries to manage %d: %v",
447+
len(currentQueries), currentQueries)
448+
449+
log.Infof("Current batches to manage %d: %v",
450+
len(currentBatches), currentBatches)
451+
437452
for _, q := range batch.requests {
438453
heap.Push(work, &queryJob{
439454
index: queryIndex,

0 commit comments

Comments
 (0)