From 4056a5e87024bda18de287bfc1212b132d9c69e6 Mon Sep 17 00:00:00 2001 From: AlexPeshkoff Date: Mon, 4 Dec 2023 17:58:51 +0300 Subject: [PATCH] Fixed #7905: Segfault during TPC initialization (cherry picked from commit 103373302d16e32cc2ed37b51cb198766d863912) --- src/jrd/tpc.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/jrd/tpc.cpp b/src/jrd/tpc.cpp index c0960a5d5a5..3adbdc338e8 100644 --- a/src/jrd/tpc.cpp +++ b/src/jrd/tpc.cpp @@ -432,8 +432,23 @@ void TipCache::StatusBlockData::clear(thread_db* tdbb) // wait for all initializing processes (PR) acceptAst = false; - TraNumber oldest = - cache->m_tpcHeader->getHeader()->oldest_transaction.load(std::memory_order_relaxed); + TraNumber oldest; + if (cache->m_tpcHeader) + oldest = cache->m_tpcHeader->getHeader()->oldest_transaction.load(std::memory_order_relaxed); + else + { + Database* dbb = tdbb->getDatabase(); + if (dbb->dbb_flags & DBB_shared) + oldest = dbb->dbb_oldest_transaction; + else + { + WIN window(HEADER_PAGE_NUMBER); + const Ods::header_page* header_page = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); + oldest = Ods::getOIT(header_page); + CCH_RELEASE(tdbb, &window); + } + } + if (blockNumber < oldest / cache->m_transactionsPerBlock && // old block => send AST !LCK_convert(tdbb, &existenceLock, LCK_SW, LCK_WAIT)) {