From 2f3f320d28ecc1718e6f6ccb28a55e43f01964b9 Mon Sep 17 00:00:00 2001 From: DanS Date: Fri, 27 Mar 2026 14:01:50 -0500 Subject: [PATCH] Handle ReadBlockFromDisk failure during IBD gracefully During Initial Block Download, block data may not be flushed to disk when the wallet notification thread tries to read it. Instead of crashing with a fatal error, log a message and retry on the next cycle. --- src/validationinterface.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index 57f6468c4..4836530ac 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -179,6 +179,13 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip) // Read block from disk. CBlock block; if (!ReadBlockFromDisk(block, pindexLastTip,1)) { + if (IsInitialBlockDownload()) { + // During IBD, block data may not be flushed to disk yet. + // Sleep briefly and retry on the next cycle instead of crashing. + LogPrintf("%s: block at height %d not yet readable, will retry\n", + __func__, pindexLastTip->GetHeight()); + break; + } LogPrintf("*** %s\n", "Failed to read block while notifying wallets of block disconnects"); uiInterface.ThreadSafeMessageBox( _("Error: A fatal internal error occurred, see debug.log for details"), @@ -206,6 +213,14 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip) // Read block from disk. CBlock block; if (!ReadBlockFromDisk(block, blockData.pindex, 1)) { + if (IsInitialBlockDownload()) { + // During IBD, block data may not be flushed to disk yet. + // Push unprocessed blocks back and retry on the next cycle. + LogPrintf("%s: block at height %d not yet readable, will retry\n", + __func__, blockData.pindex->GetHeight()); + blockStack.push_back(blockData); + break; + } LogPrintf("*** %s\n", "Failed to read block while notifying wallets of block connects"); uiInterface.ThreadSafeMessageBox( _("Error: A fatal internal error occurred, see debug.log for details"),