{"record":{"id":"1c4aefef7ccb340b","repo":"hyperledger/fabric","slug":"commit-failed","errorCode":null,"errorMessage":"commit failed","messagePattern":"commit failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"gossip/privdata/coordinator.go","lineNumber":231,"sourceCode":"\t}\n\n\t// Retrieve the private data.\n\t// RetrievePvtdata checks this peer's eligibility and then retreives from cache, transient store, or from a remote peer.\n\tretrievedPvtdata, err := pdp.RetrievePvtdata(pvtdataToRetrieve)\n\tif err != nil {\n\t\tc.logger.Warningf(\"Failed to retrieve pvtdata: %s\", err)\n\t\treturn err\n\t}\n\n\tblockAndPvtData.PvtData = retrievedPvtdata.blockPvtdata.PvtData\n\tblockAndPvtData.MissingPvtData = retrievedPvtdata.blockPvtdata.MissingPvtData\n\n\t// commit block and private data\n\tcommitStart := time.Now()\n\terr = c.CommitLegacy(blockAndPvtData, &ledger.CommitOptions{})\n\tc.reportCommitDuration(time.Since(commitStart))\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"commit failed\")\n\t}\n\n\t// Purge transactions\n\tgo retrievedPvtdata.Purge()\n\n\treturn nil\n}\n\n// StorePvtData used to persist private data into transient store\nfunc (c *coordinator) StorePvtData(txID string, privData *protostransientstore.TxPvtReadWriteSetWithConfigInfo, blkHeight uint64) error {\n\treturn c.store.Persist(txID, blkHeight, privData)\n}\n\n// GetPvtDataAndBlockByNum gets block by number and also returns all related private data\n// that requesting peer is eligible for.\n// The order of private data in slice of PvtDataCollections doesn't imply the order of\n// transactions in the block related to these private data, to get the correct placement\n// need to read TxPvtData.SeqInBlock field","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/gossip/privdata/coordinator.go#L213-L249","documentation":"StoreBlock wraps any error returned by the ledger's CommitLegacy with errors.Wrap(err, \"commit failed\"). The wrapped cause is the actual ledger error (e.g. duplicate commit, state DB failure), and this message indicates the block and its private data could not be persisted to the ledger.","triggerScenarios":"CommitLegacy fails during StoreBlock — commonly committing a block number that was already committed, ledger write errors, state/validation DB outages, or a private-data mismatch rejected by the ledger.","commonSituations":"Peer replaying a block it already committed (duplicate commit after reconnect); disk full or corrupted LevelDB/CouchDB; gRPC-restarted committer double-delivering a block; underlying ledger returning internal errors.","solutions":["Unwrap the error (errors.Cause / %v chain) to see the ledger's root cause and address it directly","Check whether the block number was already committed — if so, treat as idempotent success and skip","Verify ledger/state DB health (disk space, locks, corruption) and repair or resync from genesis","Rejoin the peer to the channel / rebuild the ledger if the ledger state is inconsistent"],"exampleFix":"// before\nif err := c.StoreBlock(block, pvtData); err != nil {\n    return err // opaque \"commit failed\"\n}\n// after\nif err := c.StoreBlock(block, pvtData); err != nil {\n    if strings.Contains(err.Error(), \"already committed\") {\n        return nil // idempotent\n    }\n    logger.Errorf(\"commit failed: %+v\", err) // log full cause chain\n    return err\n}","handlingStrategy":"try-catch","validationCode":"// pre-check: avoid duplicate commit\ncurrent, _ := ledger.GetBlockchainInfo()\nif block.Header.Number <= current.Height-1 {\n    return nil // already committed\n}","typeGuard":null,"tryCatchPattern":"err := coordinator.StoreBlock(block, pvtData)\nif err != nil {\n    var root error = err\n    for errors.Unwrap(root) != nil { root = errors.Unwrap(root) }\n    logger.Errorf(\"commit failed, root cause: %v\", root)\n    if isAlreadyCommitted(root) { return nil }\n    return fmt.Errorf(\"block %d not committed: %w\", block.Header.Number, err)\n}","preventionTips":["Unwrap and log the underlying ledger error, not just 'commit failed'","Make commit idempotent for already-committed block numbers","Monitor disk space and state DB health on committer peers","Reconnect block delivery carefully to avoid duplicate deliveries"],"tags":["gossip","privdata","ledger","commit"],"backgroundTag":"ledger-commit-failed","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}