hyperledger/fabric · error

this instance should not be used after calling Done()

Error message

this instance should not be used after calling Done()

What it means

checkDone detected the query executor was used after Done() was called. Once Done releases the read lock and closes iterators, the executor is invalid — using it indicates a lifecycle bug or double-Done in caller code.

Source

Thrown at core/ledger/kvledger/txmgmt/txmgr/query_executor.go:381

// Done implements method in interface `ledger.QueryExecutor`
func (q *queryExecutor) Done() {
	logger.Debugf("Done with transaction simulation / query execution [%s]", q.txid)
	if q.doneInvoked {
		return
	}

	defer func() {
		q.txmgr.commitRWLock.RUnlock()
		q.doneInvoked = true
		for _, itr := range q.itrs {
			itr.Close()
		}
	}()
}

func (q *queryExecutor) checkDone() error {
	if q.doneInvoked {
		return errors.New("this instance should not be used after calling Done()")
	}
	return nil
}

func (q *queryExecutor) validateCollName(ns, coll string) error {
	return q.collNameValidator.validateCollName(ns, coll)
}

// resultsItr implements interface ledger.ResultsIterator
// this wraps the actual db iterator and intercept the calls
// to build rangeQueryInfo in the ReadWriteSet that is used
// for performing phantom read validation during commit
type resultsItr struct {
	ns                      string
	endKey                  string
	dbItr                   statedb.ResultsIterator
	rwSetBuilder            *rwsetutil.RWSetBuilder
	rangeQueryInfo          *kvrwset.RangeQueryInfo

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Do not reuse a query executor after Done()
  2. Obtain a fresh executor for subsequent queries
  3. Fix caller logic that retains the executor past Done
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/ledger/kvledger/txmgmt/txmgr/query_executor.go:381 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/0d8b99a46c2b29ca. Report an issue: GitHub.