mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 06:03:02 +01:00
Restored some of the old logic. The change was experimental and it doesn't look safe to me anymore.
This commit is contained in:
parent
fa80ab814d
commit
8ac82bde83
@ -537,10 +537,10 @@ void BackupManager::begin_backup(thread_db* tdbb)
|
|||||||
{
|
{
|
||||||
NBAK_TRACE(("begin_backup"));
|
NBAK_TRACE(("begin_backup"));
|
||||||
|
|
||||||
|
// Lock header page first to prevent possible deadlock
|
||||||
WIN window(HEADER_PAGE);
|
WIN window(HEADER_PAGE);
|
||||||
Ods::header_page* header = NULL;
|
Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
|
||||||
bool state_locked = false, database_locked = false;
|
bool state_locked = false, header_locked = true, database_locked = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#ifndef SUPERSERVER
|
#ifndef SUPERSERVER
|
||||||
// Send AST's to flush other caches. While this lock is taken no pages may have
|
// Send AST's to flush other caches. While this lock is taken no pages may have
|
||||||
@ -562,6 +562,7 @@ void BackupManager::begin_backup(thread_db* tdbb)
|
|||||||
if (backup_state != nbak_state_normal) {
|
if (backup_state != nbak_state_normal) {
|
||||||
NBAK_TRACE(("end backup - invalid state %d", backup_state));
|
NBAK_TRACE(("end backup - invalid state %d", backup_state));
|
||||||
unlock_state_write(tdbb);
|
unlock_state_write(tdbb);
|
||||||
|
CCH_RELEASE(tdbb, &window);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create file
|
// Create file
|
||||||
@ -601,8 +602,6 @@ void BackupManager::begin_backup(thread_db* tdbb)
|
|||||||
GenerateGuid(&guid);
|
GenerateGuid(&guid);
|
||||||
tdbb->tdbb_flags |= TDBB_set_backup_state;
|
tdbb->tdbb_flags |= TDBB_set_backup_state;
|
||||||
// Set state in database header page. All changes are written to main database file yet.
|
// Set state in database header page. All changes are written to main database file yet.
|
||||||
Ods::header_page* header =
|
|
||||||
(Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
|
|
||||||
CCH_MARK_MUST_WRITE(tdbb, &window);
|
CCH_MARK_MUST_WRITE(tdbb, &window);
|
||||||
int newState = nbak_state_stalled;
|
int newState = nbak_state_stalled;
|
||||||
header->hdr_flags = (header->hdr_flags & ~Ods::hdr_backup_mask) | newState;
|
header->hdr_flags = (header->hdr_flags & ~Ods::hdr_backup_mask) | newState;
|
||||||
@ -613,7 +612,7 @@ void BackupManager::begin_backup(thread_db* tdbb)
|
|||||||
PAG_replace_entry_first(header, Ods::HDR_backup_guid, sizeof(guid),
|
PAG_replace_entry_first(header, Ods::HDR_backup_guid, sizeof(guid),
|
||||||
reinterpret_cast<const UCHAR*>(&guid));
|
reinterpret_cast<const UCHAR*>(&guid));
|
||||||
|
|
||||||
header = NULL;
|
header_locked = false;
|
||||||
CCH_RELEASE(tdbb, &window);
|
CCH_RELEASE(tdbb, &window);
|
||||||
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
||||||
|
|
||||||
@ -632,7 +631,7 @@ void BackupManager::begin_backup(thread_db* tdbb)
|
|||||||
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
||||||
if (state_locked)
|
if (state_locked)
|
||||||
unlock_state_write(tdbb);
|
unlock_state_write(tdbb);
|
||||||
if (header)
|
if (header_locked)
|
||||||
CCH_RELEASE(tdbb, &window);
|
CCH_RELEASE(tdbb, &window);
|
||||||
#ifndef SUPERSERVER
|
#ifndef SUPERSERVER
|
||||||
if (database_locked)
|
if (database_locked)
|
||||||
@ -667,13 +666,15 @@ void BackupManager::end_backup(thread_db* tdbb, bool recover)
|
|||||||
// for some instants and anything is possible at
|
// for some instants and anything is possible at
|
||||||
// that times.
|
// that times.
|
||||||
|
|
||||||
|
// Lock header page first to prevent possible deadlock
|
||||||
WIN window(HEADER_PAGE);
|
WIN window(HEADER_PAGE);
|
||||||
Ods::header_page* header = NULL;
|
Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
|
||||||
bool state_locked = false;
|
bool state_locked = false, header_locked = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (recover) {
|
if (recover) {
|
||||||
if (!try_lock_state_write(tdbb)) {
|
if (!try_lock_state_write(tdbb)) {
|
||||||
|
CCH_RELEASE(tdbb, &window);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -687,6 +688,7 @@ void BackupManager::end_backup(thread_db* tdbb, bool recover)
|
|||||||
{
|
{
|
||||||
NBAK_TRACE(("invalid state %d", backup_state));
|
NBAK_TRACE(("invalid state %d", backup_state));
|
||||||
unlock_state_write(tdbb);
|
unlock_state_write(tdbb);
|
||||||
|
CCH_RELEASE(tdbb, &window);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NBAK_TRACE(("difference file %s", diff_name));
|
NBAK_TRACE(("difference file %s", diff_name));
|
||||||
@ -696,7 +698,6 @@ void BackupManager::end_backup(thread_db* tdbb, bool recover)
|
|||||||
backup_state = nbak_state_merge;
|
backup_state = nbak_state_merge;
|
||||||
adjusted_scn = ++current_scn;
|
adjusted_scn = ++current_scn;
|
||||||
NBAK_TRACE(("New state is getting to become %d", backup_state));
|
NBAK_TRACE(("New state is getting to become %d", backup_state));
|
||||||
header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
|
|
||||||
CCH_MARK_MUST_WRITE(tdbb, &window);
|
CCH_MARK_MUST_WRITE(tdbb, &window);
|
||||||
NBAK_TRACE(("New state is getting to become after fetches %d", backup_state));
|
NBAK_TRACE(("New state is getting to become after fetches %d", backup_state));
|
||||||
// Generate new SCN
|
// Generate new SCN
|
||||||
@ -704,7 +705,7 @@ void BackupManager::end_backup(thread_db* tdbb, bool recover)
|
|||||||
NBAK_TRACE(("new SCN=%d is getting written to header", header->hdr_header.pag_scn));
|
NBAK_TRACE(("new SCN=%d is getting written to header", header->hdr_header.pag_scn));
|
||||||
// Adjust state
|
// Adjust state
|
||||||
header->hdr_flags = (header->hdr_flags & ~Ods::hdr_backup_mask) | backup_state;
|
header->hdr_flags = (header->hdr_flags & ~Ods::hdr_backup_mask) | backup_state;
|
||||||
header = NULL;
|
header_locked = false;
|
||||||
CCH_RELEASE(tdbb, &window);
|
CCH_RELEASE(tdbb, &window);
|
||||||
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
||||||
NBAK_TRACE(("Set state %d in header page", backup_state));
|
NBAK_TRACE(("Set state %d in header page", backup_state));
|
||||||
@ -713,7 +714,7 @@ void BackupManager::end_backup(thread_db* tdbb, bool recover)
|
|||||||
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
||||||
if (state_locked)
|
if (state_locked)
|
||||||
unlock_state_write(tdbb);
|
unlock_state_write(tdbb);
|
||||||
if (header)
|
if (header_locked)
|
||||||
CCH_RELEASE(tdbb, &window);
|
CCH_RELEASE(tdbb, &window);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@ -769,6 +770,7 @@ void BackupManager::end_backup(thread_db* tdbb, bool recover)
|
|||||||
window.win_flags = 0;
|
window.win_flags = 0;
|
||||||
header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
|
header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
|
||||||
state_locked = false;
|
state_locked = false;
|
||||||
|
header_locked = true;
|
||||||
try {
|
try {
|
||||||
lock_state_write(tdbb, true);
|
lock_state_write(tdbb, true);
|
||||||
state_locked = true;
|
state_locked = true;
|
||||||
@ -789,7 +791,7 @@ void BackupManager::end_backup(thread_db* tdbb, bool recover)
|
|||||||
// Generate new SCN
|
// Generate new SCN
|
||||||
header->hdr_header.pag_scn = ++current_scn;
|
header->hdr_header.pag_scn = ++current_scn;
|
||||||
NBAK_TRACE(("new SCN=%d is getting written to header", header->hdr_header.pag_scn));
|
NBAK_TRACE(("new SCN=%d is getting written to header", header->hdr_header.pag_scn));
|
||||||
header = NULL;
|
header_locked = false;
|
||||||
CCH_RELEASE(tdbb, &window);
|
CCH_RELEASE(tdbb, &window);
|
||||||
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
||||||
|
|
||||||
@ -814,7 +816,7 @@ void BackupManager::end_backup(thread_db* tdbb, bool recover)
|
|||||||
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
tdbb->tdbb_flags &= ~TDBB_set_backup_state;
|
||||||
if (state_locked)
|
if (state_locked)
|
||||||
unlock_state_write(tdbb);
|
unlock_state_write(tdbb);
|
||||||
if (header)
|
if (header_locked)
|
||||||
CCH_RELEASE(tdbb, &window);
|
CCH_RELEASE(tdbb, &window);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user