MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / clear

Method clear

src/jrd/tpc.cpp:432–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432void TipCache::StatusBlockData::clear(thread_db* tdbb)
433{
434 // memory could be already released at tpc_block_blocking_ast
435 PathName fName;
436 if (memory)
437 {
438 // wait for all initializing processes (PR)
439 acceptAst = false;
440
441 TraNumber oldest;
442 if (cache->m_tpcHeader)
443 oldest = cache->m_tpcHeader->getHeader()->oldest_transaction.load(std::memory_order_relaxed);
444 else
445 {
446 Database* dbb = tdbb->getDatabase();
447 if (dbb->dbb_flags & DBB_shared)
448 oldest = dbb->dbb_oldest_transaction;
449 else
450 {
451 WIN window(HEADER_PAGE_NUMBER);
452 const Ods::header_page* header_page = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header);
453 oldest = Ods::getOIT(header_page);
454 CCH_RELEASE(tdbb, &window);
455 }
456 }
457
458 if (blockNumber < oldest / cache->m_transactionsPerBlock && // old block => send AST
459 !LCK_convert(tdbb, &existenceLock, LCK_SW, LCK_WAIT))
460 {
461 ERR_bugcheck_msg("Unable to convert TPC lock (SW)");
462 }
463
464 fName = memory->getMapFileName();
465 delete memory;
466 memory = NULL;
467 }
468
469 if (fName.hasData())
470 {
471 // Here file is removed from SharedMemory created with skipLock parameter
472 // set to true. That means internal file lock is turned off.
473 // Appropriate locking is performed by existenceLock using LM.
474 // This should be in sync with SharedMemory constructor called
475 // in TipCache::StatusBlockData constructor.
476 if (LCK_lock(tdbb, &existenceLock, LCK_EX, LCK_NO_WAIT))
477 SharedMemoryBase::unlinkFile(fName.c_str());
478 else
479 {
480 tdbb->tdbb_status_vector->init();
481 return;
482 }
483 }
484
485 LCK_release(tdbb, &existenceLock);
486}
487
488TipCache::TransactionStatusBlock* TipCache::createTransactionStatusBlock(ULONG blockSize, TpcBlockNumber blockNumber)
489{

Callers 2

finalizeTpcMethod · 0.45
updateActiveSnapshotsMethod · 0.45

Calls 14

CCH_FETCHFunction · 0.85
getOITFunction · 0.85
CCH_RELEASEFunction · 0.85
LCK_convertFunction · 0.85
ERR_bugcheck_msgFunction · 0.85
LCK_lockFunction · 0.85
LCK_releaseFunction · 0.85
getDatabaseMethod · 0.80
getMapFileNameMethod · 0.80
loadMethod · 0.45
getHeaderMethod · 0.45
hasDataMethod · 0.45

Tested by

no test coverage detected