From 11544d983a189670c04232a46aa687d6e9bdffa2 Mon Sep 17 00:00:00 2001 From: marta-lokhova Date: Tue, 15 Oct 2024 13:22:05 -0700 Subject: [PATCH] Bugfix: make partial checkpoint files during DB migration, fix bug in catchup that doesn't catch this --- src/catchup/VerifyLedgerChainWork.cpp | 11 +++++++++++ src/history/HistoryManagerImpl.cpp | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/catchup/VerifyLedgerChainWork.cpp b/src/catchup/VerifyLedgerChainWork.cpp index 327df362c0..a5603fd1e0 100644 --- a/src/catchup/VerifyLedgerChainWork.cpp +++ b/src/catchup/VerifyLedgerChainWork.cpp @@ -185,6 +185,8 @@ VerifyLedgerChainWork::verifyHistoryOfSingleCheckpoint() CLOG_DEBUG(History, "Verifying ledger headers from {} for checkpoint {}", ft.localPath_nogz(), mCurrCheckpoint); + auto const& hm = mApp.getHistoryManager(); + while (hdrIn) { try @@ -243,6 +245,15 @@ VerifyLedgerChainWork::verifyHistoryOfSingleCheckpoint() if (beginCheckpoint) { + if (!hm.isFirstLedgerInCheckpoint(curr.header.ledgerSeq)) + { + CLOG_ERROR( + History, "Checkpoint did not start with {} - got {}", + hm.firstLedgerInCheckpointContaining(curr.header.ledgerSeq), + curr.header.ledgerSeq); + return HistoryManager::VERIFY_STATUS_ERR_MISSING_ENTRIES; + } + // At the beginning of checkpoint, we can't verify the link with // previous ledger, so at least verify that header content hashes to // correct value diff --git a/src/history/HistoryManagerImpl.cpp b/src/history/HistoryManagerImpl.cpp index 41e3f3a6f7..cb24896ce0 100644 --- a/src/history/HistoryManagerImpl.cpp +++ b/src/history/HistoryManagerImpl.cpp @@ -159,6 +159,9 @@ HistoryManagerImpl::dropSQLBasedPublish() populateCheckpointFilesFromDB(mApp, mApp.getDatabase().getSession(), firstLedgerInCheckpointContaining(lcl), freq, *mCheckpoint); + LedgerHeaderUtils::copyToStream( + mApp.getDatabase(), mApp.getDatabase().getSession(), + firstLedgerInCheckpointContaining(lcl), freq, *mCheckpoint); } mApp.getDatabase().clearPreparedStatementCache();