mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 20:03:03 +01:00
Small metadata cache cleanup
This commit is contained in:
parent
301e56f1d3
commit
eb1ae27de8
@ -2333,7 +2333,7 @@ static bool delete_index(thread_db* tdbb, SSHORT phase, DeferredWork* work,
|
|||||||
wait = (transaction->tra_flags & TRA_nowait) ? FALSE : TRUE;
|
wait = (transaction->tra_flags & TRA_nowait) ? FALSE : TRUE;
|
||||||
// Try to clear trigger cache to release lock
|
// Try to clear trigger cache to release lock
|
||||||
if (index->idl_count)
|
if (index->idl_count)
|
||||||
MET_clear_cache(tdbb, NULL);
|
MET_clear_cache(tdbb);
|
||||||
if (index->idl_count ||
|
if (index->idl_count ||
|
||||||
!LCK_lock_non_blocking(tdbb, index->idl_lock, LCK_EX, wait))
|
!LCK_lock_non_blocking(tdbb, index->idl_lock, LCK_EX, wait))
|
||||||
{
|
{
|
||||||
@ -2673,7 +2673,7 @@ static bool delete_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work,
|
|||||||
|
|
||||||
wait = (transaction->tra_flags & TRA_nowait) ? FALSE : TRUE;
|
wait = (transaction->tra_flags & TRA_nowait) ? FALSE : TRUE;
|
||||||
if (relation->rel_use_count)
|
if (relation->rel_use_count)
|
||||||
MET_clear_cache(tdbb, NULL);
|
MET_clear_cache(tdbb);
|
||||||
if (relation->rel_use_count ||
|
if (relation->rel_use_count ||
|
||||||
(relation->rel_existence_lock &&
|
(relation->rel_existence_lock &&
|
||||||
!LCK_convert_non_blocking(tdbb, relation->rel_existence_lock,
|
!LCK_convert_non_blocking(tdbb, relation->rel_existence_lock,
|
||||||
|
@ -550,6 +550,11 @@ class jrd_prc : public pool_alloc_rpt<SCHAR, type_prc>
|
|||||||
#define PRC_blocking 16 /* Blocking someone from dropping procedure */
|
#define PRC_blocking 16 /* Blocking someone from dropping procedure */
|
||||||
#define PRC_create 32 /* Newly created */
|
#define PRC_create 32 /* Newly created */
|
||||||
#define PRC_being_altered 64 /* Procedure is getting altered */
|
#define PRC_being_altered 64 /* Procedure is getting altered */
|
||||||
|
// This flag is used to make sure that MET_remove_procedure
|
||||||
|
// does not delete and remove procedure block from cache
|
||||||
|
// so dfw.epp:modify_procedure() can flip procedure body without
|
||||||
|
// invalidating procedure pointers from other parts of metadata cache
|
||||||
|
|
||||||
#define PRC_check_existence 128 /* Existence lock released */
|
#define PRC_check_existence 128 /* Existence lock released */
|
||||||
|
|
||||||
#define MAX_PROC_ALTER 64 /* No. of times an in-cache procedure can be altered */
|
#define MAX_PROC_ALTER 64 /* No. of times an in-cache procedure can be altered */
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
* 2004.01.16 Vlad Horsun: added support for default parameters
|
* 2004.01.16 Vlad Horsun: added support for default parameters
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
$Id: met.epp,v 1.107 2004-04-10 19:03:42 skidder Exp $
|
$Id: met.epp,v 1.108 2004-04-10 19:46:47 skidder Exp $
|
||||||
*/
|
*/
|
||||||
// This MUST be at the top of the file
|
// This MUST be at the top of the file
|
||||||
#ifdef DARWIN
|
#ifdef DARWIN
|
||||||
@ -332,7 +332,7 @@ void MET_verify_cache(thread_db* tdbb) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool MET_clear_cache(thread_db* tdbb, jrd_prc* proc)
|
void MET_clear_cache(thread_db* tdbb)
|
||||||
{
|
{
|
||||||
/**************************************
|
/**************************************
|
||||||
*
|
*
|
||||||
@ -341,9 +341,8 @@ bool MET_clear_cache(thread_db* tdbb, jrd_prc* proc)
|
|||||||
**************************************
|
**************************************
|
||||||
*
|
*
|
||||||
* Functional description
|
* Functional description
|
||||||
* Try to release all resources locked by cached triggers
|
* Remove all unused objects from metadata cache to
|
||||||
* do not remove proc procedure from cache because it will be
|
* release resources they use
|
||||||
* handled by the caller
|
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
SET_TDBB(tdbb);
|
SET_TDBB(tdbb);
|
||||||
@ -368,8 +367,6 @@ bool MET_clear_cache(thread_db* tdbb, jrd_prc* proc)
|
|||||||
release_cached_triggers(tdbb, relation->rel_post_modify);
|
release_cached_triggers(tdbb, relation->rel_post_modify);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = true;
|
|
||||||
|
|
||||||
vec* procedures = dbb->dbb_procedures;
|
vec* procedures = dbb->dbb_procedures;
|
||||||
if (procedures) {
|
if (procedures) {
|
||||||
jrd_prc* procedure;
|
jrd_prc* procedure;
|
||||||
@ -396,19 +393,12 @@ bool MET_clear_cache(thread_db* tdbb, jrd_prc* proc)
|
|||||||
{
|
{
|
||||||
if ( (procedure = (jrd_prc*)(*ptr)) && procedure->prc_request &&
|
if ( (procedure = (jrd_prc*)(*ptr)) && procedure->prc_request &&
|
||||||
!(procedure->prc_flags & PRC_obsolete) &&
|
!(procedure->prc_flags & PRC_obsolete) &&
|
||||||
procedure->prc_use_count != procedure->prc_int_use_count
|
procedure->prc_use_count != procedure->prc_int_use_count )
|
||||||
&& procedure != proc )
|
|
||||||
{
|
{
|
||||||
adjust_dependencies(procedure);
|
adjust_dependencies(procedure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proc) {
|
|
||||||
result = proc->prc_use_count == proc->prc_int_use_count;
|
|
||||||
if (proc->prc_request)
|
|
||||||
adjust_dependencies(proc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Deallocate all used requests */
|
/* Deallocate all used requests */
|
||||||
for (ptr = procedures->begin(), end = procedures->end();
|
for (ptr = procedures->begin(), end = procedures->end();
|
||||||
ptr < end; ptr++)
|
ptr < end; ptr++)
|
||||||
@ -419,8 +409,7 @@ bool MET_clear_cache(thread_db* tdbb, jrd_prc* proc)
|
|||||||
if ( procedure->prc_request &&
|
if ( procedure->prc_request &&
|
||||||
!(procedure->prc_flags & PRC_obsolete) &&
|
!(procedure->prc_flags & PRC_obsolete) &&
|
||||||
procedure->prc_int_use_count >= 0 &&
|
procedure->prc_int_use_count >= 0 &&
|
||||||
procedure->prc_use_count == procedure->prc_int_use_count &&
|
procedure->prc_use_count == procedure->prc_int_use_count )
|
||||||
procedure != proc )
|
|
||||||
{
|
{
|
||||||
CMP_release(tdbb, procedure->prc_request);
|
CMP_release(tdbb, procedure->prc_request);
|
||||||
procedure->prc_request = NULL;
|
procedure->prc_request = NULL;
|
||||||
@ -441,9 +430,8 @@ bool MET_clear_cache(thread_db* tdbb, jrd_prc* proc)
|
|||||||
ptr < end; ptr++)
|
ptr < end; ptr++)
|
||||||
{
|
{
|
||||||
if ( (procedure = (jrd_prc*)(*ptr)) &&
|
if ( (procedure = (jrd_prc*)(*ptr)) &&
|
||||||
(procedure->prc_flags & PRC_obsolete) && (procedure != proc) )
|
(procedure->prc_flags & PRC_obsolete) )
|
||||||
{
|
{
|
||||||
procedure->prc_flags &= ~PRC_being_altered; // Just a safety sake
|
|
||||||
MET_remove_procedure(tdbb, procedure->prc_id, procedure);
|
MET_remove_procedure(tdbb, procedure->prc_id, procedure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,7 +440,6 @@ bool MET_clear_cache(thread_db* tdbb, jrd_prc* proc)
|
|||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
MET_verify_cache(tdbb);
|
MET_verify_cache(tdbb);
|
||||||
#endif
|
#endif
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MET_procedure_in_use(thread_db* tdbb, jrd_prc* proc)
|
bool MET_procedure_in_use(thread_db* tdbb, jrd_prc* proc)
|
||||||
|
@ -85,7 +85,7 @@ void MET_release_triggers(Jrd::thread_db*, Jrd::trig_vec**);
|
|||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
void MET_verify_cache(Jrd::thread_db*);
|
void MET_verify_cache(Jrd::thread_db*);
|
||||||
#endif
|
#endif
|
||||||
bool MET_clear_cache(Jrd::thread_db*, Jrd::jrd_prc*);
|
void MET_clear_cache(Jrd::thread_db*);
|
||||||
bool MET_procedure_in_use(Jrd::thread_db*, Jrd::jrd_prc*);
|
bool MET_procedure_in_use(Jrd::thread_db*, Jrd::jrd_prc*);
|
||||||
void MET_remove_procedure(Jrd::thread_db*, int, Jrd::jrd_prc*);
|
void MET_remove_procedure(Jrd::thread_db*, int, Jrd::jrd_prc*);
|
||||||
void MET_revoke(Jrd::thread_db*, Jrd::jrd_tra*, const TEXT*, const TEXT*, const TEXT*);
|
void MET_revoke(Jrd::thread_db*, Jrd::jrd_tra*, const TEXT*, const TEXT*, const TEXT*);
|
||||||
|
Loading…
Reference in New Issue
Block a user