{"record":{"id":"27c7e09e3f53fa25","repo":"hyperledger/fabric","slug":"failed-to-read-wal-and-cannot-repair-s","errorCode":null,"errorMessage":"failed to read WAL and cannot repair: %s","messagePattern":"failed to read WAL and cannot repair: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/consensus/etcdraft/storage.go","lineNumber":217,"sourceCode":"\n\tlg.Debugf(\"Loading WAL at Term %d and Index %d\", walsnap.Term, walsnap.Index)\n\n\tvar repaired bool\n\tfor {\n\t\tif w, err = wal.Open(lg.Zap(), walDir, walsnap); err != nil {\n\t\t\treturn nil, st, nil, errors.Errorf(\"failed to open WAL: %s\", err)\n\t\t}\n\n\t\tif _, st, ents, err = w.ReadAll(); err != nil {\n\t\t\tlg.Warnf(\"Failed to read WAL: %s\", err)\n\n\t\t\tif errc := w.Close(); errc != nil {\n\t\t\t\treturn nil, st, nil, errors.Errorf(\"failed to close erroneous WAL: %s\", errc)\n\t\t\t}\n\n\t\t\t// only repair UnexpectedEOF and only repair once\n\t\t\tif repaired || err != io.ErrUnexpectedEOF {\n\t\t\t\treturn nil, st, nil, errors.Errorf(\"failed to read WAL and cannot repair: %s\", err)\n\t\t\t}\n\n\t\t\tif !wal.Repair(lg.Zap(), walDir) {\n\t\t\t\treturn nil, st, nil, errors.Errorf(\"failed to repair WAL: %s\", err)\n\t\t\t}\n\n\t\t\trepaired = true\n\t\t\t// next loop should be able to open WAL and return\n\t\t\tcontinue\n\t\t}\n\n\t\t// successfully opened WAL and read all entries, break\n\t\tbreak\n\t}\n\n\treturn w, st, ents, nil\n}\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/consensus/etcdraft/storage.go#L199-L235","documentation":"createOrReadWAL guard: reading the etcdraft write-ahead log failed with an error other than UnexpectedEOF (or a second UnexpectedEOF after one repair attempt), so the WAL is corrupt beyond the single-shot repair capability. The chain cannot be started from this WAL; the message includes the underlying read error.","triggerScenarios":"Thrown at orderer/consensus/etcdraft/storage.go:217 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the WAL directory from backup","Delete the WAL and let the node re-replicate the ledger from other consenters via snapshot/block pull","Rejoin the node to the channel to rebuild state from scratch"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}