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

Function TRA_header_write

src/jrd/tra.cpp:731–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729
730#ifdef SUPERSERVER_V2
731void TRA_header_write(thread_db* tdbb, Database* dbb, TraNumber number)
732{
733/**************************************
734 *
735 * T R A _ h e a d e r _ w r i t e
736 *
737 **************************************
738 *
739 * Functional description
740 * Force transaction ID on header to disk.
741 * Do post fetch check of the transaction
742 * ID header write as a concurrent thread
743 * might have written the header page
744 * while blocked on the latch.
745 *
746 * The idea is to amortize the cost of
747 * header page I/O across multiple transactions.
748 *
749 **************************************/
750 SET_TDBB(tdbb);
751
752 // If transaction number is already on disk just return.
753
754 if (!number || dbb->dbb_last_header_write < number)
755 {
756 WIN window(HEADER_PAGE_NUMBER);
757 header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
758
759 const TraNumber next_transaction = Ods::getNT(header);
760 const TraNumber oldest_active = Ods::getOAT(header);
761 const TraNumber oldest_transaction = Ods::getOIT(header);
762 const TraNumber oldest_snapshot = Ods::getOST(header);
763
764 if (next_transaction)
765 {
766 if (oldest_active > next_transaction)
767 BUGCHECK(266); //next transaction older than oldest active
768
769 if (oldest_transaction > next_transaction)
770 BUGCHECK(267); // next transaction older than oldest transaction
771 }
772
773 // The header page might have been written while waiting
774 // for the latch; perform a post fetch check and optimize
775 // this case by not writing the page again.
776
777 if (!number || dbb->dbb_last_header_write < number)
778 {
779 CCH_MARK_MUST_WRITE(tdbb, &window);
780
781 if (dbb->dbb_next_transaction > next_transaction)
782 Ods::writeNT(header, dbb->dbb_next_transaction);
783
784 if (dbb->dbb_oldest_active > oldest_active)
785 Ods::writeOAT(header, dbb->dbb_oldest_active);
786
787 if (dbb->dbb_oldest_transaction > oldest_transaction)
788 Ods::writeOIT(header, dbb->dbb_oldest_transaction);

Callers 2

JRD_shutdown_databaseFunction · 0.85
write_bufferFunction · 0.85

Calls 12

SET_TDBBFunction · 0.85
CCH_FETCHFunction · 0.85
getNTFunction · 0.85
getOATFunction · 0.85
getOITFunction · 0.85
getOSTFunction · 0.85
CCH_MARK_MUST_WRITEFunction · 0.85
writeNTFunction · 0.85
writeOATFunction · 0.85
writeOITFunction · 0.85
writeOSTFunction · 0.85
CCH_RELEASEFunction · 0.85

Tested by

no test coverage detected