Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc297fec

Browse files
author
Alena Rybakina
committed
Add memory context to cover memory space when applying aqo_timeout handler and applying
isQueryUsingSystemRelation_walker and add UtilityMemCtx for allocation space for junk_fssand actual_fss list and reset it after cleaning aqo database process.
1 parent34147af commitc297fec

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

‎aqo.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ _PG_init(void)
316316
create_upper_paths_hook=aqo_store_upper_signature_hook;
317317

318318
init_deactivated_queries_storage();
319-
319+
320320
/*
321321
* Create own Top memory Context for reporting AQO memory in the future.
322322
*/

‎postprocessing.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ static int exec_nested_level = 0;
615615
staticvoid
616616
aqo_timeout_handler(void)
617617
{
618+
MemoryContextoldctx=MemoryContextSwitchTo(AQOLearnMemCtx);
618619
aqo_obj_statctx= {NIL,NIL,NIL, false, false};
619620

620621
if (!timeoutCtl.queryDesc|| !ExtractFromQueryEnv(timeoutCtl.queryDesc))
@@ -627,6 +628,7 @@ aqo_timeout_handler(void)
627628

628629
elog(NOTICE,"[AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data.");
629630
learnOnPlanState(timeoutCtl.queryDesc->planstate, (void*)&ctx);
631+
MemoryContextSwitchTo(oldctx);
630632
}
631633

632634
staticbool

‎preprocessing.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ aqo_planner(Query *parse,
157157

158158
selectivity_cache_clear();
159159
MemoryContextSwitchTo(oldctx);
160-
160+
161161
oldctx=MemoryContextSwitchTo(AQOUtilityMemCtx);
162162
query_context.query_hash=get_query_hash(parse,query_string);
163163
MemoryContextSwitchTo(oldctx);
@@ -458,6 +458,7 @@ jointree_walker(Node *jtnode, void *context)
458458
staticbool
459459
isQueryUsingSystemRelation_walker(Node*node,void*context)
460460
{
461+
MemoryContextoldctx=MemoryContextSwitchTo(AQOLearnMemCtx);
461462
AQOPreWalkerCtx*ctx= (AQOPreWalkerCtx*)context;
462463

463464
if (node==NULL)
@@ -499,6 +500,7 @@ isQueryUsingSystemRelation_walker(Node *node, void *context)
499500
}
500501

501502
jointree_walker((Node*)query->jointree,context);
503+
MemoryContextSwitchTo(oldctx);
502504

503505
/* Recursively plunge into subqueries and CTEs */
504506
returnquery_tree_walker(query,

‎selectivity_cache.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ cache_selectivity(int clause_hash,
5151
AQOCacheSelectivity=AllocSetContextCreate(AQOTopMemCtx,
5252
"AQOCacheSelectivity",
5353
ALLOCSET_DEFAULT_SIZES);
54-
54+
5555

5656
foreach(l,objects)
5757
{

‎storage.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,7 @@ cleanup_aqo_database(bool gentle, int *fs_num, int *fss_num)
20262026
for(i=0;i<dentry->nrels;i++)
20272027
{
20282028
Oidreloid=ObjectIdGetDatum(*(Oid*)ptr);
2029+
MemoryContextoldctx=MemoryContextSwitchTo(AQOUtilityMemCtx);
20292030

20302031
if (!SearchSysCacheExists1(RELOID,reloid))
20312032
/* Remember this value */
@@ -2034,6 +2035,7 @@ cleanup_aqo_database(bool gentle, int *fs_num, int *fss_num)
20342035
else
20352036
actual_fss=list_append_unique_int(actual_fss,
20362037
dentry->key.fss);
2038+
MemoryContextSwitchTo(oldctx);
20372039

20382040
ptr+=sizeof(Oid);
20392041
}
@@ -2083,8 +2085,7 @@ cleanup_aqo_database(bool gentle, int *fs_num, int *fss_num)
20832085
(*fs_num)+= (int)_aqo_queries_remove(entry->queryid);
20842086
}
20852087

2086-
list_free(junk_fss);
2087-
list_free(actual_fss);
2088+
MemoryContextReset(AQOUtilityMemCtx);
20882089
}
20892090

20902091
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp