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

Method actualizeState

src/jrd/nbak.cpp:956–1055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

954}
955
956bool BackupManager::actualizeState(thread_db* tdbb)
957{
958 // State is unknown. We need to read it from the disk.
959 // We cannot use CCH for this because of likely recursion.
960 NBAK_TRACE(("actualizeState: current_state=%i", backup_state));
961
962 if (dbCreating)
963 {
964 backup_state = Ods::hdr_nbak_normal;
965 return true;
966 }
967
968 SET_TDBB(tdbb);
969
970 FbStatusVector* status = tdbb->tdbb_status_vector;
971
972 // Read original page from database file or shadows.
973 SSHORT retryCount = 0;
974 Ods::header_page* header = reinterpret_cast<Ods::header_page*>(spare_buffer);
975 BufferDesc temp_bdb(database->dbb_bcb);
976 temp_bdb.bdb_page = HEADER_PAGE_NUMBER;
977 temp_bdb.bdb_buffer = &header->hdr_header;
978 PageSpace* pageSpace = database->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
979 fb_assert(pageSpace);
980 jrd_file* file = pageSpace->file;
981
982 // It's header page, never encrypted
983 while (!PIO_read(tdbb, file, &temp_bdb, temp_bdb.bdb_buffer, status))
984 {
985 if (!CCH_rollover_to_shadow(tdbb, database, file, false))
986 {
987 NBAK_TRACE(("Shadow change error"));
988 return false;
989 }
990 if (file != pageSpace->file)
991 file = pageSpace->file;
992 else
993 {
994 if (retryCount++ == 3)
995 {
996 NBAK_TRACE(("IO error"));
997 return false;
998 }
999 }
1000 }
1001
1002 const int new_backup_state = header->hdr_flags & Ods::hdr_backup_mask;
1003 NBAK_TRACE(("backup state read from header is %d", new_backup_state));
1004 // Check is we missed lock/unlock cycle and need to invalidate
1005 // our allocation table and file handle
1006 const bool missed_cycle = (header->hdr_header.pag_scn - current_scn) > 1;
1007 current_scn = header->hdr_header.pag_scn;
1008
1009 // Read difference file name from header clumplets
1010 explicit_diff_name = false;
1011 const UCHAR* p = header->hdr_data;
1012 const UCHAR* const end = reinterpret_cast<UCHAR*>(header) + header->hdr_page_size;
1013 while (p < end)

Callers 1

fetchMethod · 0.80

Calls 7

SET_TDBBFunction · 0.85
CCH_rollover_to_shadowFunction · 0.85
ERR_bugcheck_msgFunction · 0.85
findPageSpaceMethod · 0.80
tryReleaseLockMethod · 0.80
PIO_readFunction · 0.50
assignMethod · 0.45

Tested by

no test coverage detected