hyperledger/fabric · error

error while trying to check the presence of TXID [%s]

Error message

error while trying to check the presence of TXID [%s]

What it means

This is a wrapped error (errors.WithMessagef/Wrapf) from txIDExists: the underlying goleveldb iterator operation failed while scanning the txid key range. The original cause is embedded — typical roots include goleveldb 'DB closed', corrupted index DB files, or I/O errors.

Source

Thrown at common/ledger/blkstorage/blockindex.go:235

		return peer.TxValidationCode(-1), 0, err
	}
	return peer.TxValidationCode(v.TxValidationCode), blkNum, nil
}

func (index *blockIndex) txIDExists(txID string) (bool, error) {
	if !index.isAttributeIndexed(IndexableAttrTxID) {
		return false, errors.New("transaction IDs not maintained in index")
	}
	rangeScan := constructTxIDRangeScan(txID)
	itr, err := index.db.GetIterator(rangeScan.startKey, rangeScan.stopKey)
	if err != nil {
		return false, errors.WithMessagef(err, "error while trying to check the presence of TXID [%s]", txID)
	}
	defer itr.Release()

	present := itr.Next()
	if err := itr.Error(); err != nil {
		return false, errors.Wrapf(err, "error while trying to check the presence of TXID [%s]", txID)
	}
	return present, nil
}

func (index *blockIndex) getTxIDVal(txID string) (*TxIDIndexValue, uint64, error) {
	if !index.isAttributeIndexed(IndexableAttrTxID) {
		return nil, 0, errors.New("transaction IDs not maintained in index")
	}
	rangeScan := constructTxIDRangeScan(txID)
	itr, err := index.db.GetIterator(rangeScan.startKey, rangeScan.stopKey)
	if err != nil {
		return nil, 0, errors.WithMessagef(err, "error while trying to retrieve transaction info by TXID [%s]", txID)
	}
	defer itr.Release()

	present := itr.Next()
	if err := itr.Error(); err != nil {
		return nil, 0, errors.Wrapf(err, "error while trying to retrieve transaction info by TXID [%s]", txID)

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Read the wrapped cause (errors.Unwrap / %v of the returned error) — fix the root DB/IO problem it names
  2. If 'leveldb: closed', ensure the peer/store is running and queries are not issued after Close; reinitialize access via blkstorage provider
  3. If corruption is indicated, stop the peer, back up and rebuild/reinitialize the index DB so syncIndex regenerates txid keys
  4. Check disk space/permissions on the ledger data directory

Example fix

// before
exists, err := store.TxIDExists(txid)
if err != nil { log.Println(err) } // only shows wrapper message
// after
exists, err := store.TxIDExists(txid)
if err != nil {
    log.Printf("txid lookup failed for %s: %+v", txid, err) // logs full cause chain
    if strings.Contains(fmt.Sprint(err), "closed") { reopenProvider() }
}
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

exists, err := store.TxIDExists(txid)
var dbErr *leveldb.errors // inspect cause chain
if err != nil {
    log.Printf("txid check failed: %+v", err) // print full chain to expose root cause
    if errors.Is(err, leveldb.ErrClosed) { return retryAfterReopen() }
    return fmt.Errorf("index DB unhealthy; consider rebuild: %w", err)
}

Prevention

When it happens

Trigger: Calling txIDExists when index.db.GetIterator fails (e.g. database already closed, corrupted MANIFEST/log files) or itr.Error() reports an iterator-level failure during/after the range scan over constructTxIDRangeScan(txID) keys.

Common situations: Peer shutting down or restarted while a query is in flight; disk full or permission issues on the index DB directory; goleveldb corruption after unclean shutdown; concurrent open/close misuse of the store.

Related errors


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