8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 18:03:04 +01:00
This commit is contained in:
asfernandes 2011-06-26 18:48:00 +00:00
parent 4f5dd005ac
commit 47489fa71b
10 changed files with 43 additions and 34 deletions

View File

@ -152,7 +152,6 @@ bool SyncObject::lockConditional(SyncType type)
return true; return true;
} }
} }
} }
else else
{ {
@ -180,7 +179,7 @@ bool SyncObject::lockConditional(SyncType type)
} }
} }
return false; return false;
} }

View File

@ -207,8 +207,8 @@ public:
class SyncUnlockGuard class SyncUnlockGuard
{ {
public: public:
explicit SyncUnlockGuard(Sync& aSync) : explicit SyncUnlockGuard(Sync& aSync)
sync(aSync) : sync(aSync)
{ {
oldState = sync.getState(); oldState = sync.getState();

View File

@ -507,7 +507,7 @@ void ExtEngineManager::Trigger::setValues(thread_db* /*tdbb*/, Array<UCHAR>& msg
dsc desc; dsc desc;
EVL_field(rpb->rpb_relation, record, i, &desc); EVL_field(rpb->rpb_relation, record, i, &desc);
// CVC: I'm not sure why it's not important to check EVL_field's result. // CVC: I'm not sure why it's not important to check EVL_field's result.
unsigned align = type_alignments[desc.dsc_dtype]; unsigned align = type_alignments[desc.dsc_dtype];
if (align) if (align)
msgBuffer.resize(FB_ALIGN(msgBuffer.getCount(), align)); msgBuffer.resize(FB_ALIGN(msgBuffer.getCount(), align));

View File

@ -130,7 +130,7 @@ SLONG GarbageCollector::RelationData::minTranID() const
TranData::ConstAccessor accessor(&m_tranData); TranData::ConstAccessor accessor(&m_tranData);
if (accessor.getFirst()) if (accessor.getFirst())
return accessor.current()->first; return accessor.current()->first;
return MAX_TRA_NUMBER; return MAX_TRA_NUMBER;
} }

View File

@ -7281,9 +7281,9 @@ static void start_transaction(thread_db* tdbb, bool transliterate, jrd_tra** tra
try try
{ {
if (tpb_length > 0 && tpb == NULL) if (tpb_length > 0 && !tpb)
status_exception::raise(Arg::Gds(isc_bad_tpb_form)); status_exception::raise(Arg::Gds(isc_bad_tpb_form));
jrd_tra* transaction = TRA_start(tdbb, tpb_length, tpb); jrd_tra* transaction = TRA_start(tdbb, tpb_length, tpb);
transaction->tra_sibling = NULL; transaction->tra_sibling = NULL;

View File

@ -154,9 +154,9 @@ BackupManager::StateWriteGuard::StateWriteGuard(thread_db* _tdbb, Jrd::WIN* wnd)
BackupManager::StateWriteGuard::~StateWriteGuard() BackupManager::StateWriteGuard::~StateWriteGuard()
{ {
// It is important to set state into nbak_state_unknown *before* release of state lock, // It is important to set state into nbak_state_unknown *before* release of state lock,
// else someone could acquire state lock, fetch and modify some page before state will // otherwise someone could acquire state lock, fetch and modify some page before state will
// be set into unknown. But dirty page can't be written when backup state is unknown // be set into unknown. But dirty page can't be written when backup state is unknown
// because write target (database or delta) is also unknown. // because write target (database or delta) is also unknown.
if (!success) if (!success)
@ -263,22 +263,26 @@ void BackupManager::beginBackup(thread_db* tdbb)
struct stat st; struct stat st;
PageSpace* pageSpace = database->dbb_page_manager.findPageSpace(DB_PAGE_SPACE); PageSpace* pageSpace = database->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
char* func = NULL; char* func = NULL;
while (!func && fstat(pageSpace->file->fil_desc, &st) != 0) while (!func && fstat(pageSpace->file->fil_desc, &st) != 0)
{ {
if (errno != EINTR) if (errno != EINTR)
func = "fstat"; func = "fstat";
} }
while (!func && fchown(diff_file->fil_desc, st.st_uid, st.st_gid) != 0) while (!func && fchown(diff_file->fil_desc, st.st_uid, st.st_gid) != 0)
{ {
if (errno != EINTR) if (errno != EINTR)
func = "fchown"; func = "fchown";
} }
while (!func && fchmod(diff_file->fil_desc, st.st_mode) != 0) while (!func && fchmod(diff_file->fil_desc, st.st_mode) != 0)
{ {
if (errno != EINTR) if (errno != EINTR)
func = "fchmod"; func = "fchmod";
} }
if (func)
if (func)
{ {
stateGuard.setSuccess(); stateGuard.setSuccess();
Firebird::system_call_failed::raise(func); Firebird::system_call_failed::raise(func);

View File

@ -190,6 +190,7 @@ public:
~StateWriteGuard(); ~StateWriteGuard();
void releaseHeader(); void releaseHeader();
void setSuccess() void setSuccess()
{ {
success = true; success = true;
@ -213,7 +214,7 @@ public:
Jrd::Attachment* att = tdbb->getAttachment(); Jrd::Attachment* att = tdbb->getAttachment();
Database* dbb = tdbb->getDatabase(); Database* dbb = tdbb->getDatabase();
const bool ok = att ? const bool ok = att ?
att->backupStateReadLock(tdbb, LCK_WAIT) : att->backupStateReadLock(tdbb, LCK_WAIT) :
dbb->dbb_backup_manager->lockStateRead(tdbb, LCK_WAIT); dbb->dbb_backup_manager->lockStateRead(tdbb, LCK_WAIT);

View File

@ -406,7 +406,7 @@ SLONG TipCache::cacheTransactions(thread_db* tdbb, SLONG oldest)
#endif #endif
// hvlad: No need to cache TIP pages below hdr_oldest just refreshed from // hvlad: No need to cache TIP pages below hdr_oldest just refreshed from
// header page. Moreover out tip cache can now contain a gap between the last // header page. Moreover our tip cache can now contain a gap between the last
// cached tip page and new pages if our process was idle for long time // cached tip page and new pages if our process was idle for long time
oldest = MAX(oldest, hdr_oldest); oldest = MAX(oldest, hdr_oldest);

View File

@ -1271,9 +1271,7 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl
} }
} }
else else
{
VIO_temp_cleanup(tdbb, transaction); VIO_temp_cleanup(tdbb, transaction);
}
// Find out if there is a transaction savepoint we can use to rollback our transaction // Find out if there is a transaction savepoint we can use to rollback our transaction
bool tran_sav = false; bool tran_sav = false;
@ -3436,20 +3434,23 @@ static jrd_tra* transaction_start(thread_db* tdbb, jrd_tra* temp)
} }
} }
// Calculate attachment-local oldest active and oldest snapshot numbers // Calculate attachment-local oldest active and oldest snapshot numbers
// looking at current attachment's transactions only. Calculated values // looking at current attachment's transactions only. Calculated values
// are used to determine garbage collection threshold for attachment-local // are used to determine garbage collection threshold for attachment-local
// data such as temporary tables (GTT's). // data such as temporary tables (GTT's).
trans->tra_att_oldest_active = number; trans->tra_att_oldest_active = number;
SLONG att_oldest_active = number; SLONG att_oldest_active = number;
SLONG att_oldest_snapshot = number; SLONG att_oldest_snapshot = number;
for (jrd_tra* tx_att = attachment->att_transactions; tx_att; tx_att = tx_att->tra_next) for (jrd_tra* tx_att = attachment->att_transactions; tx_att; tx_att = tx_att->tra_next)
{ {
att_oldest_active = MIN(att_oldest_active, tx_att->tra_number); att_oldest_active = MIN(att_oldest_active, tx_att->tra_number);
att_oldest_snapshot = MIN(att_oldest_snapshot, tx_att->tra_att_oldest_active); att_oldest_snapshot = MIN(att_oldest_snapshot, tx_att->tra_att_oldest_active);
} }
trans->tra_att_oldest_active = (trans->tra_flags & TRA_read_committed) ? number : att_oldest_active; trans->tra_att_oldest_active = (trans->tra_flags & TRA_read_committed) ? number : att_oldest_active;
if (attachment->att_oldest_snapshot < att_oldest_snapshot) if (attachment->att_oldest_snapshot < att_oldest_snapshot)
attachment->att_oldest_snapshot = att_oldest_snapshot; attachment->att_oldest_snapshot = att_oldest_snapshot;

View File

@ -550,8 +550,8 @@ bool VIO_chase_record_version(thread_db* tdbb, record_param* rpb,
const bool gcPolicyCooperative = tdbb->getDatabase()->dbb_flags & DBB_gc_cooperative; const bool gcPolicyCooperative = tdbb->getDatabase()->dbb_flags & DBB_gc_cooperative;
const bool gcPolicyBackground = tdbb->getDatabase()->dbb_flags & DBB_gc_background; const bool gcPolicyBackground = tdbb->getDatabase()->dbb_flags & DBB_gc_background;
const SLONG oldest_snapshot = const SLONG oldest_snapshot = rpb->rpb_relation->isTemporary() ?
rpb->rpb_relation->isTemporary() ? attachment->att_oldest_snapshot : transaction->tra_oldest_active; attachment->att_oldest_snapshot : transaction->tra_oldest_active;
#ifdef VIO_DEBUG #ifdef VIO_DEBUG
if (debug_flag > DEBUG_TRACE_ALL) if (debug_flag > DEBUG_TRACE_ALL)
@ -1756,8 +1756,8 @@ bool VIO_garbage_collect(thread_db* tdbb, record_param* rpb, const jrd_tra* tran
return true; return true;
} }
const SLONG oldest_snapshot = const SLONG oldest_snapshot = rpb->rpb_relation->isTemporary() ?
rpb->rpb_relation->isTemporary() ? attachment->att_oldest_snapshot : transaction->tra_oldest_active; attachment->att_oldest_snapshot : transaction->tra_oldest_active;
while (true) while (true)
{ {
@ -3247,12 +3247,13 @@ void VIO_temp_cleanup(thread_db* tdbb, jrd_tra* transaction)
* *
* Functional description * Functional description
* Remove undo data for GTT ON COMMIT DELETE ROWS as their data will be released * Remove undo data for GTT ON COMMIT DELETE ROWS as their data will be released
* at transaction end anyway and we don't need to waste time backing it out on * at transaction end anyway and we don't need to waste time backing it out on
* rollback * rollback.
* *
**************************************/ **************************************/
{ {
Savepoint* sav_point = transaction->tra_save_point; Savepoint* sav_point = transaction->tra_save_point;
for (; sav_point; sav_point = sav_point->sav_next) for (; sav_point; sav_point = sav_point->sav_next)
{ {
for (VerbAction* action = sav_point->sav_verb_actions; action; action = action->vct_next) for (VerbAction* action = sav_point->sav_verb_actions; action; action = action->vct_next)
@ -3260,14 +3261,17 @@ void VIO_temp_cleanup(thread_db* tdbb, jrd_tra* transaction)
if (action->vct_relation->rel_flags & REL_temp_tran) if (action->vct_relation->rel_flags & REL_temp_tran)
{ {
RecordBitmap::reset(action->vct_records); RecordBitmap::reset(action->vct_records);
if (action->vct_undo) if (action->vct_undo)
{ {
if (action->vct_undo->getFirst()) if (action->vct_undo->getFirst())
{ {
do { do
{
action->vct_undo->current().release(transaction); action->vct_undo->current().release(transaction);
} while (action->vct_undo->getNext()); } while (action->vct_undo->getNext());
} }
delete action->vct_undo; delete action->vct_undo;
action->vct_undo = NULL; action->vct_undo = NULL;
} }
@ -3336,7 +3340,8 @@ void VIO_verb_cleanup(thread_db* tdbb, jrd_tra* transaction)
// Cleanup/merge deferred work/event post // Cleanup/merge deferred work/event post
if (sav_point->sav_verb_actions || sav_point->sav_verb_count || (sav_point->sav_flags & SAV_force_dfw)) if (sav_point->sav_verb_actions || sav_point->sav_verb_count ||
(sav_point->sav_flags & SAV_force_dfw))
{ {
if (sav_point->sav_verb_count) { if (sav_point->sav_verb_count) {
DFW_delete_deferred(transaction, sav_point->sav_number); DFW_delete_deferred(transaction, sav_point->sav_number);
@ -4037,9 +4042,8 @@ static void expunge(thread_db* tdbb, record_param* rpb, const jrd_tra* transacti
} }
#endif #endif
if (attachment->att_flags & ATT_no_cleanup) { if (attachment->att_flags & ATT_no_cleanup)
return; return;
}
// Re-fetch the record // Re-fetch the record
@ -4066,8 +4070,8 @@ static void expunge(thread_db* tdbb, record_param* rpb, const jrd_tra* transacti
// Make sure it looks kosher and delete the record. // Make sure it looks kosher and delete the record.
const SLONG oldest_snapshot = const SLONG oldest_snapshot = rpb->rpb_relation->isTemporary() ?
rpb->rpb_relation->isTemporary() ? attachment->att_oldest_snapshot : transaction->tra_oldest_active; attachment->att_oldest_snapshot : transaction->tra_oldest_active;
if (!(rpb->rpb_flags & rpb_deleted) || rpb->rpb_transaction_nr >= oldest_snapshot) if (!(rpb->rpb_flags & rpb_deleted) || rpb->rpb_transaction_nr >= oldest_snapshot)
{ {