hyperledger/fabric · error
the supplied snapshots appear to be non-comparable. State db
Error message
the supplied snapshots appear to be non-comparable. State db types do not match. Snapshot1 state db type: %s Snapshot2 state db type: %s
What it means
hashesEqual compares two ledger snapshots during snapshot comparison (Compare). Snapshots are only comparable if their state database types (e.g. LevelDB vs CouchDB) match. When mdata1.StateDBType differs from mdata2.StateDBType the snapshots cannot be meaningfully diffed and this error is returned.
Source
Thrown at internal/ledgerutil/compare/compare.go:545
}
if mdata1.ChannelName != mdata2.ChannelName {
return false, false, "", 0, errors.Errorf("the supplied snapshots appear to be non-comparable. Channel names do not match."+
"\nSnapshot1 channel name: %s\nSnapshot2 channel name: %s", mdata1.ChannelName, mdata2.ChannelName)
}
if mdata1.LastBlockNumber != mdata2.LastBlockNumber {
return false, false, "", 0, errors.Errorf("the supplied snapshots appear to be non-comparable. Last block numbers do not match."+
"\nSnapshot1 last block number: %v\nSnapshot2 last block number: %v", mdata1.LastBlockNumber, mdata2.LastBlockNumber)
}
if mdata1.LastBlockHashInHex != mdata2.LastBlockHashInHex {
return false, false, "", 0, errors.Errorf("the supplied snapshots appear to be non-comparable. Last block hashes do not match."+
"\nSnapshot1 last block hash: %s\nSnapshot2 last block hash: %s", mdata1.LastBlockHashInHex, mdata2.LastBlockHashInHex)
}
if mdata1.StateDBType != mdata2.StateDBType {
return false, false, "", 0, errors.Errorf("the supplied snapshots appear to be non-comparable. State db types do not match."+
"\nSnapshot1 state db type: %s\nSnapshot2 state db type: %s", mdata1.StateDBType, mdata2.StateDBType)
}
pubDataHash1 := mdata1.FilesAndHashes[privacyenabledstate.PubStateDataFileName]
pubMdataHash1 := mdata1.FilesAndHashes[privacyenabledstate.PubStateMetadataFileName]
pvtDataHash1 := mdata1.FilesAndHashes[privacyenabledstate.PvtStateHashesFileName]
pvtMdataHash1 := mdata1.FilesAndHashes[privacyenabledstate.PvtStateHashesMetadataFileName]
pubDataHash2 := mdata2.FilesAndHashes[privacyenabledstate.PubStateDataFileName]
pubMdataHash2 := mdata2.FilesAndHashes[privacyenabledstate.PubStateMetadataFileName]
pvtDataHash2 := mdata2.FilesAndHashes[privacyenabledstate.PvtStateHashesFileName]
pvtMdataHash2 := mdata2.FilesAndHashes[privacyenabledstate.PvtStateHashesMetadataFileName]
equalPub = pubDataHash1 == pubDataHash2 && pubMdataHash1 == pubMdataHash2
equalPvt = pvtDataHash1 == pvtDataHash2 && pvtMdataHash1 == pvtMdataHash2
return equalPub, equalPvt, mdata1.ChannelName, mdata1.LastBlockNumber, nil
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Take both snapshots from peers configured with the same state database (ledger.state.stateDatabase matching)
- If a peer was migrated (e.g. CouchDB to LevelDB), retake the snapshot after ensuring both peers run identical versions/config
- Verify snapshot metadata (files metadata json StateDBType fields) before invoking compare
Defensive patterns
Strategy: validation
Validate before calling
// Go: compare StateDBType in both snapshots' metadata before invoking compare
var m1, m2 SnapshotMetadata // loaded from each snapshot's files metadata
if m1.StateDBType != m2.StateDBType {
return fmt.Errorf("refusing to compare: state db types differ (%s vs %s)", m1.StateDBType, m2.StateDBType)
} Try / catch
if err := ledgerutil.Compare(dir1, dir2, outDir); err != nil {
if strings.Contains(err.Error(), "State db types do not match") {
return fmt.Errorf("retake snapshots from peers with the same state database config: %w", err)
}
return err
} Prevention
- Take snapshots only from peers with identical ledger.state.stateDatabase settings
- Check StateDBType in each snapshot's metadata json before comparing
- Avoid comparing snapshots across networks or across DB-migration boundaries
When it happens
Trigger: Running the snapshot compare utility on two snapshots taken from ledgers configured with different state DB types, or one snapshot taken before/after a peer state database configuration change.
Common situations: Comparing a snapshot from a LevelDB peer with one from a CouchDB peer; peer reconfigured from CouchDB to LevelDB between snapshots; comparing snapshots from different networks/environments.
Related errors
- dir %s not empty
- recovery for DB [%s] not possible. Ledger [%s] is created fr
- error decoding the block number
- error decoding the data hash
- error decoding the previous hash
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/fc0962bbbbe1fa9c.
Report an issue: GitHub.