mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 21:23:04 +01:00
Refactoring: simplify the rescheduling usage
This commit is contained in:
parent
bea124b133
commit
34cb7c8c25
@ -4014,7 +4014,7 @@ const StmtNode* InAutonomousTransactionNode::execute(thread_db* tdbb, jrd_req* r
|
||||
{
|
||||
// Force unconditional reschedule. It prevents new transactions being
|
||||
// started after an attachment or a database shutdown has been initiated.
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb, true);
|
||||
|
||||
jrd_tra* const org_transaction = request->req_transaction;
|
||||
fb_assert(tdbb->getTransaction() == org_transaction);
|
||||
|
@ -283,7 +283,7 @@ bool DsqlDmlRequest::fetch(thread_db* tdbb, UCHAR* msgBuffer)
|
||||
|
||||
thread_db::TimerGuard timerGuard(tdbb, req_timer, false);
|
||||
if (req_timer && req_timer->expired())
|
||||
tdbb->checkCancelState(true);
|
||||
tdbb->checkCancelState();
|
||||
|
||||
UCHAR* dsqlMsgBuffer = req_msg_buffers[message->msg_buffer_number];
|
||||
if (prefetchedFirstRow)
|
||||
|
@ -806,8 +806,7 @@ bool PASS1_node_match(DsqlCompilerScratch* dsqlScratch, const ExprNode* node1, c
|
||||
DEV_BLKCHK(node1, dsql_type_nod);
|
||||
DEV_BLKCHK(node2, dsql_type_nod);
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
if (!node1 && !node2)
|
||||
return true;
|
||||
|
@ -981,7 +981,7 @@ namespace Jrd {
|
||||
releaseGuard.leave();
|
||||
|
||||
ThreadContextHolder tdbb(att->att_database, att, &status_vector);
|
||||
tdbb->tdbb_quantum = SWEEP_QUANTUM;
|
||||
tdbb->markAsSweeper();
|
||||
|
||||
DatabaseContextHolder dbHolder(tdbb);
|
||||
|
||||
@ -1018,10 +1018,7 @@ namespace Jrd {
|
||||
}
|
||||
|
||||
// scheduling
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
{
|
||||
JRD_reschedule(tdbb, SWEEP_QUANTUM, true);
|
||||
}
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
// nbackup state check
|
||||
int bak_state = Ods::hdr_nbak_unknown;
|
||||
|
@ -628,8 +628,7 @@ USHORT blb::BLB_get_segment(thread_db* tdbb, void* segment, USHORT buffer_length
|
||||
if (blb_flags & BLB_temporary)
|
||||
ERR_post(Arg::Gds(isc_cannot_read_new_blob));
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
// If we reached end of file, we're still there
|
||||
|
||||
|
@ -2098,10 +2098,7 @@ void BTR_selectivity(thread_db* tdbb, jrd_rel* relation, USHORT id, SelectivityL
|
||||
while (true)
|
||||
{
|
||||
if (node.isEndBucket || (nodes % 100 == 0))
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
}
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
if (node.isEndBucket || node.isEndLevel)
|
||||
break;
|
||||
@ -3940,8 +3937,14 @@ static ULONG fast_load(thread_db* tdbb,
|
||||
currLevel->pointer = levelPointer;
|
||||
}
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
error = JRD_reschedule(tdbb, 0, false);
|
||||
try
|
||||
{
|
||||
JRD_reschedule(tdbb);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
||||
// To finish up, put an end of level marker on the last bucket
|
||||
@ -6258,8 +6261,7 @@ static contents remove_leaf_node(thread_db* tdbb, index_insertion* insertion, WI
|
||||
|
||||
// Until deletion of duplicate nodes becomes efficient, limit
|
||||
// leaf level traversal by rescheduling.
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
}
|
||||
|
||||
// If we've needed to search thru a significant number of pages, warn the
|
||||
@ -6291,8 +6293,7 @@ static bool scan(thread_db* tdbb, UCHAR* pointer, RecordBitmap** bitmap, RecordB
|
||||
**************************************/
|
||||
SET_TDBB(tdbb);
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
// if the search key is flagged to indicate a multi-segment index
|
||||
// stuff the key to the stuff boundary
|
||||
|
@ -523,7 +523,7 @@ bool CCH_exclusive_attachment(thread_db* tdbb, USHORT level, SSHORT wait_flag, S
|
||||
{
|
||||
try
|
||||
{
|
||||
tdbb->checkCancelState(true);
|
||||
tdbb->checkCancelState();
|
||||
|
||||
bool found = false;
|
||||
for (Jrd::Attachment* other_attachment = attachment->att_next; other_attachment;
|
||||
@ -2905,7 +2905,7 @@ void BufferControl::cache_reader(BufferControl* bcb)
|
||||
// Otherwise, wait for event notification.
|
||||
BufferDesc* bdb;
|
||||
if (found)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb, true);
|
||||
else if (bcb->bcb_flags & BCB_free_pending &&
|
||||
(bdb = get_buffer(tdbb, FREE_PAGE, LATCH_none, 1)))
|
||||
{
|
||||
@ -3019,9 +3019,7 @@ void BufferControl::cache_writer(BufferControl* bcb)
|
||||
// Otherwise, wait for event notification.
|
||||
|
||||
if ((bcb->bcb_flags & BCB_free_pending) || dbb->dbb_flush_cycle)
|
||||
{
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
}
|
||||
JRD_reschedule(tdbb, true);
|
||||
#ifdef CACHE_READER
|
||||
else if (SBM_next(bcb->bcb_prefetch, &starting_page, RSE_get_forward))
|
||||
{
|
||||
|
@ -667,7 +667,7 @@ ULONG DPM_data_pages(thread_db* tdbb, jrd_rel* relation)
|
||||
|
||||
CCH_RELEASE(tdbb, &window);
|
||||
|
||||
tdbb->checkCancelState(true);
|
||||
tdbb->checkCancelState();
|
||||
}
|
||||
|
||||
CCH_RELEASE(tdbb, &window);
|
||||
@ -1888,7 +1888,7 @@ bool DPM_next(thread_db* tdbb, record_param* rpb, USHORT lock_type, bool onepage
|
||||
return false;
|
||||
|
||||
if (sweeper)
|
||||
tdbb->checkCancelState(true);
|
||||
tdbb->checkCancelState();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,7 @@ RecordBitmap** EVL_bitmap(thread_db* tdbb, const InversionNode* node, RecordBitm
|
||||
|
||||
DEV_BLKCHK(node, type_nod);
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
switch (node->type)
|
||||
{
|
||||
|
@ -53,8 +53,7 @@ namespace Jrd
|
||||
|
||||
SET_TDBB(tdbb);
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
request->req_flags &= ~req_null;
|
||||
|
||||
|
@ -636,8 +636,7 @@ void EXE_receive(thread_db* tdbb,
|
||||
|
||||
DEV_BLKCHK(request, type_req);
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_tra* transaction = request->req_transaction;
|
||||
|
||||
@ -789,8 +788,7 @@ void EXE_send(thread_db* tdbb, jrd_req* request, USHORT msg, ULONG length, const
|
||||
SET_TDBB(tdbb);
|
||||
DEV_BLKCHK(request, type_req);
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
if (!(request->req_flags & req_active))
|
||||
ERR_post(Arg::Gds(isc_req_sync));
|
||||
@ -1317,8 +1315,7 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
|
||||
{
|
||||
if (request->req_operation == jrd_req::req_evaluate)
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
if (node->hasLineColumn)
|
||||
{
|
||||
|
@ -502,8 +502,7 @@ void IDX_create_index(thread_db* tdbb,
|
||||
if (creation.duplicates > 0)
|
||||
break;
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
}
|
||||
|
||||
gc_record.release();
|
||||
|
@ -8759,7 +8759,7 @@ SSHORT thread_db::getCharSet() const
|
||||
return attachment->att_charset;
|
||||
}
|
||||
|
||||
ISC_STATUS thread_db::checkCancelState(ISC_STATUS* secondary)
|
||||
ISC_STATUS thread_db::getCancelState(ISC_STATUS* secondary)
|
||||
{
|
||||
// Test for asynchronous shutdown/cancellation requests.
|
||||
// But do that only if we're neither in the verb cleanup state
|
||||
@ -8820,56 +8820,49 @@ ISC_STATUS thread_db::checkCancelState(ISC_STATUS* secondary)
|
||||
return FB_SUCCESS;
|
||||
}
|
||||
|
||||
bool thread_db::checkCancelState(bool punt)
|
||||
void thread_db::checkCancelState()
|
||||
{
|
||||
ISC_STATUS secondary = 0;
|
||||
const ISC_STATUS error = checkCancelState(&secondary);
|
||||
const ISC_STATUS error = getCancelState(&secondary);
|
||||
|
||||
if (!error)
|
||||
return false;
|
||||
if (error)
|
||||
{
|
||||
Arg::Gds status(error);
|
||||
|
||||
Arg::Gds status(error);
|
||||
if (error == isc_shutdown)
|
||||
status << Arg::Str(attachment->att_filename);
|
||||
|
||||
if (error == isc_shutdown)
|
||||
status << Arg::Str(attachment->att_filename);
|
||||
if (secondary)
|
||||
status << Arg::Gds(secondary);
|
||||
|
||||
if (secondary)
|
||||
status << Arg::Gds(secondary);
|
||||
if (attachment)
|
||||
attachment->att_flags &= ~ATT_cancel_raise;
|
||||
|
||||
if (attachment)
|
||||
attachment->att_flags &= ~ATT_cancel_raise;
|
||||
tdbb_flags |= TDBB_sys_error;
|
||||
status.copyTo(tdbb_status_vector);
|
||||
|
||||
tdbb_flags |= TDBB_sys_error;
|
||||
status.copyTo(tdbb_status_vector);
|
||||
|
||||
if (punt)
|
||||
CCH_unwind(this, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool thread_db::reschedule(SLONG quantum, bool punt)
|
||||
void thread_db::reschedule()
|
||||
{
|
||||
// Somebody has kindly offered to relinquish
|
||||
// control so that somebody else may run
|
||||
|
||||
if (checkCancelState(punt))
|
||||
return true;
|
||||
checkCancelState();
|
||||
|
||||
{ // checkout scope
|
||||
EngineCheckout cout(this, FB_FUNCTION);
|
||||
Thread::yield();
|
||||
}
|
||||
|
||||
if (checkCancelState(punt))
|
||||
return true;
|
||||
checkCancelState();
|
||||
|
||||
Monitoring::checkState(this);
|
||||
|
||||
tdbb_quantum = (tdbb_quantum <= 0) ?
|
||||
(quantum ? quantum : QUANTUM) : tdbb_quantum;
|
||||
|
||||
return false;
|
||||
if (tdbb_quantum <= 0)
|
||||
tdbb_quantum = (tdbb_flags & TDBB_sweeper) ? SWEEP_QUANTUM : QUANTUM;
|
||||
}
|
||||
|
||||
// end thread_db methods
|
||||
|
@ -106,8 +106,6 @@ namespace EDS {
|
||||
|
||||
namespace Jrd {
|
||||
|
||||
const int QUANTUM = 100; // Default quantum
|
||||
const int SWEEP_QUANTUM = 10; // Make sweeps less disruptive
|
||||
const unsigned MAX_CALLBACKS = 50;
|
||||
|
||||
// fwd. decl.
|
||||
@ -492,6 +490,9 @@ const ULONG TDBB_replicator = 16384; // Replicator
|
||||
|
||||
class thread_db : public Firebird::ThreadData
|
||||
{
|
||||
const static int QUANTUM = 100; // Default quantum
|
||||
const static int SWEEP_QUANTUM = 10; // Make sweeps less disruptive
|
||||
|
||||
private:
|
||||
MemoryPool* defaultPool;
|
||||
void setDefaultPool(MemoryPool* p)
|
||||
@ -601,6 +602,12 @@ public:
|
||||
|
||||
SSHORT getCharSet() const;
|
||||
|
||||
void markAsSweeper()
|
||||
{
|
||||
tdbb_quantum = SWEEP_QUANTUM;
|
||||
tdbb_flags |= TDBB_sweeper;
|
||||
}
|
||||
|
||||
void bumpStats(const RuntimeStatistics::StatType index, SINT64 delta = 1)
|
||||
{
|
||||
reqStat->bumpValue(index, delta);
|
||||
@ -637,9 +644,9 @@ public:
|
||||
attStat->bumpRelValue(index, relation_id, delta);
|
||||
}
|
||||
|
||||
ISC_STATUS checkCancelState(ISC_STATUS* secondary = NULL);
|
||||
bool checkCancelState(bool punt);
|
||||
bool reschedule(SLONG quantum, bool punt);
|
||||
ISC_STATUS getCancelState(ISC_STATUS* secondary = NULL);
|
||||
void checkCancelState();
|
||||
void reschedule();
|
||||
const TimeoutTimer* getTimeoutTimer() const
|
||||
{
|
||||
return tdbb_reqTimer;
|
||||
@ -790,6 +797,25 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// Helper class to temporarily activate sweeper context
|
||||
class ThreadSweepGuard
|
||||
{
|
||||
public:
|
||||
explicit ThreadSweepGuard(thread_db* tdbb)
|
||||
: m_tdbb(tdbb)
|
||||
{
|
||||
m_tdbb->markAsSweeper();
|
||||
}
|
||||
|
||||
~ThreadSweepGuard()
|
||||
{
|
||||
m_tdbb->tdbb_flags &= ~TDBB_sweeper;
|
||||
}
|
||||
|
||||
private:
|
||||
thread_db* const m_tdbb;
|
||||
};
|
||||
|
||||
// CVC: This class was designed to restore the thread's default status vector automatically.
|
||||
// In several places, tdbb_status_vector is replaced by a local temporary.
|
||||
class ThreadStatusGuard
|
||||
@ -864,9 +890,15 @@ typedef Firebird::HalfStaticArray<UCHAR, 256> MoveBuffer;
|
||||
|
||||
} //namespace Jrd
|
||||
|
||||
inline bool JRD_reschedule(Jrd::thread_db* tdbb, SLONG quantum, bool punt)
|
||||
inline bool JRD_reschedule(Jrd::thread_db* tdbb, bool force = false)
|
||||
{
|
||||
return tdbb->reschedule(quantum, punt);
|
||||
if (force || --tdbb->tdbb_quantum < 0)
|
||||
{
|
||||
tdbb->reschedule();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Threading macros
|
||||
@ -1063,7 +1095,7 @@ namespace Jrd {
|
||||
// If we were signalled to cancel/shutdown, react as soon as possible.
|
||||
// We cannot throw immediately, but we can reschedule ourselves.
|
||||
|
||||
if (m_tdbb && m_tdbb->tdbb_quantum > 0 && m_tdbb->checkCancelState())
|
||||
if (m_tdbb && m_tdbb->tdbb_quantum > 0 && m_tdbb->getCancelState() != FB_SUCCESS)
|
||||
m_tdbb->tdbb_quantum = 0;
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ bool LCK_convert(thread_db* tdbb, Lock* lock, USHORT level, SSHORT wait)
|
||||
case isc_lock_conflict:
|
||||
case isc_lock_timeout:
|
||||
statusVector.copyTo(tdbb->tdbb_status_vector);
|
||||
tdbb->checkCancelState(true);
|
||||
tdbb->checkCancelState();
|
||||
return false;
|
||||
case isc_lockmanerr:
|
||||
dbb->dbb_flags |= DBB_bugcheck;
|
||||
@ -687,7 +687,7 @@ bool LCK_lock(thread_db* tdbb, Lock* lock, USHORT level, SSHORT wait)
|
||||
case isc_lock_conflict:
|
||||
case isc_lock_timeout:
|
||||
statusVector.copyTo(tdbb->tdbb_status_vector);
|
||||
tdbb->checkCancelState(true);
|
||||
tdbb->checkCancelState();
|
||||
return false;
|
||||
case isc_lockmanerr:
|
||||
dbb->dbb_flags |= DBB_bugcheck;
|
||||
|
@ -548,8 +548,7 @@ void BackupManager::endBackup(thread_db* tdbb, bool recover)
|
||||
{
|
||||
int n = 0;
|
||||
do {
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, QUANTUM, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
WIN window2(DB_PAGE_SPACE, all.current().db_page);
|
||||
NBAK_TRACE(("Merge page %d, diff=%d", all.current().db_page, all.current().diff_page));
|
||||
|
@ -132,8 +132,7 @@ bool BaseAggWinStream<ThisType, NextType>::evaluateGroup(thread_db* tdbb) const
|
||||
{
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
Impure* const impure = getImpure(request);
|
||||
|
||||
@ -378,8 +377,7 @@ void AggregatedStream::print(thread_db* tdbb, string& plan, bool detailed, unsig
|
||||
|
||||
bool AggregatedStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -82,8 +82,7 @@ void BitmapTableScan::close(thread_db* tdbb) const
|
||||
|
||||
bool BitmapTableScan::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -149,8 +149,7 @@ void BufferedStream::close(thread_db* tdbb) const
|
||||
|
||||
bool BufferedStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -77,8 +77,7 @@ void ConditionalStream::close(thread_db* tdbb) const
|
||||
|
||||
bool ConditionalStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -78,8 +78,7 @@ void ExternalTableScan::close(thread_db* tdbb) const
|
||||
|
||||
bool ExternalTableScan::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -72,8 +72,7 @@ void FilteredStream::close(thread_db* tdbb) const
|
||||
|
||||
bool FilteredStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -83,8 +83,7 @@ void FirstRowsStream::close(thread_db* tdbb) const
|
||||
|
||||
bool FirstRowsStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -76,8 +76,7 @@ void FullOuterJoin::close(thread_db* tdbb) const
|
||||
|
||||
bool FullOuterJoin::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -133,8 +133,7 @@ void FullTableScan::close(thread_db* tdbb) const
|
||||
|
||||
bool FullTableScan::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -331,8 +331,7 @@ void HashJoin::close(thread_db* tdbb) const
|
||||
|
||||
bool HashJoin::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -111,8 +111,7 @@ void IndexTableScan::close(thread_db* tdbb) const
|
||||
|
||||
bool IndexTableScan::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -70,8 +70,7 @@ void LockedStream::close(thread_db* tdbb) const
|
||||
|
||||
bool LockedStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -127,8 +127,7 @@ void MergeJoin::close(thread_db* tdbb) const
|
||||
|
||||
bool MergeJoin::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -84,8 +84,7 @@ void NestedLoopJoin::close(thread_db* tdbb) const
|
||||
|
||||
bool NestedLoopJoin::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -159,8 +159,7 @@ void ProcedureScan::close(thread_db* tdbb) const
|
||||
|
||||
bool ProcedureScan::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
UserId* invoker = m_procedure->invoker ? m_procedure->invoker : tdbb->getAttachment()->att_ss_user;
|
||||
AutoSetRestore<UserId*> userIdHolder(&tdbb->getAttachment()->att_ss_user, invoker);
|
||||
|
@ -117,8 +117,7 @@ void RecursiveStream::close(thread_db* tdbb) const
|
||||
|
||||
bool RecursiveStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -70,8 +70,7 @@ void SingularStream::close(thread_db* tdbb) const
|
||||
|
||||
bool SingularStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -82,8 +82,7 @@ void SkipRowsStream::close(thread_db* tdbb) const
|
||||
|
||||
bool SkipRowsStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -83,8 +83,7 @@ void SortedStream::close(thread_db* tdbb) const
|
||||
|
||||
bool SortedStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
|
@ -99,8 +99,7 @@ void Union::close(thread_db* tdbb) const
|
||||
|
||||
bool Union::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -73,8 +73,7 @@ void VirtualTableScan::close(thread_db* tdbb) const
|
||||
|
||||
bool VirtualTableScan::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -362,8 +362,7 @@ void WindowedStream::close(thread_db* tdbb) const
|
||||
|
||||
bool WindowedStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
Impure* const impure = request->getImpure<Impure>(m_impure);
|
||||
@ -545,8 +544,7 @@ void WindowedStream::WindowStream::close(thread_db* tdbb) const
|
||||
|
||||
bool WindowedStream::WindowStream::getRecord(thread_db* tdbb) const
|
||||
{
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
jrd_req* const request = tdbb->getRequest();
|
||||
record_param* const rpb = &request->req_rpb[m_stream];
|
||||
|
@ -346,7 +346,7 @@ void Applier::process(thread_db* tdbb, ULONG length, const UCHAR* data)
|
||||
}
|
||||
|
||||
// Check cancellation flags and reset monitoring state if necessary
|
||||
tdbb->checkCancelState(true);
|
||||
tdbb->checkCancelState();
|
||||
Monitoring::checkState(tdbb);
|
||||
}
|
||||
|
||||
|
@ -1814,7 +1814,7 @@ void TRA_sweep(thread_db* tdbb)
|
||||
// 2) Execution is throttled in JRD_reschedule() by
|
||||
// yielding the processor when our quantum expires.
|
||||
|
||||
tdbb->tdbb_flags |= TDBB_sweeper;
|
||||
ThreadSweepGuard sweepGuard(tdbb);
|
||||
|
||||
TraceSweepEvent traceSweep(tdbb);
|
||||
|
||||
@ -1880,7 +1880,6 @@ void TRA_sweep(thread_db* tdbb)
|
||||
|
||||
TRA_commit(tdbb, transaction, false);
|
||||
|
||||
tdbb->tdbb_flags &= ~TDBB_sweeper;
|
||||
tdbb->setTransaction(tdbb_old_trans);
|
||||
dbb->clearSweepFlags(tdbb);
|
||||
}
|
||||
@ -1905,7 +1904,6 @@ void TRA_sweep(thread_db* tdbb)
|
||||
}
|
||||
}
|
||||
|
||||
tdbb->tdbb_flags &= ~TDBB_sweeper;
|
||||
tdbb->setTransaction(tdbb_old_trans);
|
||||
dbb->clearSweepFlags(tdbb);
|
||||
|
||||
@ -3296,7 +3294,6 @@ static void transaction_options(thread_db* tdbb,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((transaction->tra_flags & TRA_read_committed) && !(tdbb->tdbb_flags & TDBB_sweeper))
|
||||
{
|
||||
if (tdbb->getDatabase()->dbb_config->getReadConsistency())
|
||||
|
@ -755,11 +755,9 @@ static int validate(Firebird::UtilSvc* svc)
|
||||
{
|
||||
// should be EngineContextHolder but it is declared in jrd.cpp
|
||||
BackgroundContextHolder tdbb(dbb, att, &status, FB_FUNCTION);
|
||||
|
||||
att->att_use_count++;
|
||||
|
||||
|
||||
tdbb->tdbb_flags |= TDBB_sweeper;
|
||||
|
||||
val_pool = dbb->createPool();
|
||||
Jrd::ContextPoolHolder context(tdbb, val_pool);
|
||||
|
||||
@ -1027,7 +1025,7 @@ bool Validation::run(thread_db* tdbb, USHORT flags)
|
||||
for (USHORT i = 0; i < VAL_MAX_ERROR; i++)
|
||||
vdr_err_counts[i] = 0;
|
||||
|
||||
tdbb->tdbb_flags |= TDBB_sweeper;
|
||||
ThreadSweepGuard sweepGuard(tdbb);
|
||||
|
||||
gds__log("Database: %s\n\tValidation started", fileName.c_str());
|
||||
|
||||
@ -1046,8 +1044,6 @@ bool Validation::run(thread_db* tdbb, USHORT flags)
|
||||
CCH_flush(tdbb, flushFlags, 0);
|
||||
}
|
||||
|
||||
tdbb->tdbb_flags &= ~TDBB_sweeper;
|
||||
|
||||
cleanup();
|
||||
|
||||
gds__log("Database: %s\n\tValidation finished: %d errors, %d warnings, %d fixed",
|
||||
@ -1063,7 +1059,6 @@ bool Validation::run(thread_db* tdbb, USHORT flags)
|
||||
|
||||
cleanup();
|
||||
dbb->deletePool(val_pool);
|
||||
tdbb->tdbb_flags &= ~TDBB_sweeper;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1178,10 +1173,8 @@ Validation::FETCH_CODE Validation::fetch_page(bool mark, ULONG page_number,
|
||||
**************************************/
|
||||
Database* dbb = vdr_tdbb->getDatabase();
|
||||
|
||||
if (--vdr_tdbb->tdbb_quantum < 0)
|
||||
if (JRD_reschedule(vdr_tdbb))
|
||||
{
|
||||
JRD_reschedule(vdr_tdbb, 0, true);
|
||||
|
||||
if (vdr_service && vdr_service->finished())
|
||||
{
|
||||
CCH_unwind(vdr_tdbb, false);
|
||||
|
@ -3932,8 +3932,7 @@ bool VIO_sweep(thread_db* tdbb, jrd_tra* transaction, TraceSweepEvent* traceSwee
|
||||
if (relation->rel_flags & REL_deleting)
|
||||
break;
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, SWEEP_QUANTUM, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
transaction->tra_oldest_active = dbb->dbb_oldest_snapshot;
|
||||
if (TipCache* cache = dbb->dbb_tip_cache)
|
||||
@ -4705,8 +4704,7 @@ static void garbage_collect(thread_db* tdbb, record_param* rpb, ULONG prior_page
|
||||
++backversions;
|
||||
|
||||
// Don't monopolize the server while chasing long back version chains.
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
}
|
||||
|
||||
IDX_garbage_collect(tdbb, rpb, going, staying);
|
||||
@ -4791,8 +4789,7 @@ void Database::garbage_collector(Database* dbb)
|
||||
attachment->att_user = &user;
|
||||
|
||||
BackgroundContextHolder tdbb(dbb, attachment, &status_vector, FB_FUNCTION);
|
||||
tdbb->tdbb_quantum = SWEEP_QUANTUM;
|
||||
tdbb->tdbb_flags = TDBB_sweeper;
|
||||
tdbb->markAsSweeper();
|
||||
|
||||
record_param rpb;
|
||||
rpb.getWindow(tdbb).win_flags = WIN_garbage_collector;
|
||||
@ -4930,8 +4927,7 @@ void Database::garbage_collector(Database* dbb)
|
||||
break;
|
||||
}
|
||||
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, SWEEP_QUANTUM, true);
|
||||
JRD_reschedule(tdbb);
|
||||
|
||||
if (rpb.rpb_number >= last)
|
||||
break;
|
||||
@ -4963,7 +4959,7 @@ void Database::garbage_collector(Database* dbb)
|
||||
|
||||
if (found)
|
||||
{
|
||||
JRD_reschedule(tdbb, SWEEP_QUANTUM, true);
|
||||
JRD_reschedule(tdbb, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -5272,8 +5268,7 @@ static void list_staying_fast(thread_db* tdbb, record_param* rpb, RecordStack& s
|
||||
***/
|
||||
|
||||
// Don't monopolize the server while chasing long back version chains.
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
}
|
||||
|
||||
delete backout_rec;
|
||||
@ -5402,8 +5397,7 @@ static void list_staying(thread_db* tdbb, record_param* rpb, RecordStack& stayin
|
||||
++depth;
|
||||
|
||||
// Don't monopolize the server while chasing long back version chains.
|
||||
if (--tdbb->tdbb_quantum < 0)
|
||||
JRD_reschedule(tdbb, 0, true);
|
||||
JRD_reschedule(tdbb);
|
||||
}
|
||||
|
||||
if (timed_out)
|
||||
|
@ -3872,7 +3872,7 @@ void LockManager::wait_for_request(thread_db* tdbb, lrq* request, SSHORT lck_wai
|
||||
// if so we mark our own request as rejected
|
||||
|
||||
// !!! this will be changed to have no dependency on thread_db !!!
|
||||
const bool cancelled = (tdbb->checkCancelState() != FB_SUCCESS);
|
||||
const bool cancelled = (tdbb->getCancelState() != FB_SUCCESS);
|
||||
|
||||
if (cancelled || (lck_wait < 0 && lock_timeout <= current_time))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user