diff --git a/query/worker.go b/query/worker.go index dc15a18c..71de04f1 100644 --- a/query/worker.go +++ b/query/worker.go @@ -2,6 +2,7 @@ package query import ( "errors" + "fmt" "time" "github.com/btcsuite/btcd/wire" @@ -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 diff --git a/query/workmanager.go b/query/workmanager.go index e99f57ab..052a842c 100644 --- a/query/workmanager.go +++ b/query/workmanager.go @@ -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: @@ -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,