Skip to content

Commit f85ccdf

Browse files
committed
Improvement. Clean a list of deactivated queries during the call of
the aqo_reset() routine: we want to clean all the AQO internal state on reset.
1 parent db8179b commit f85ccdf

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

storage.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ init_deactivated_queries_storage(void)
195195
MemSet(&hash_ctl, 0, sizeof(hash_ctl));
196196
hash_ctl.keysize = sizeof(uint64);
197197
hash_ctl.entrysize = sizeof(uint64);
198-
deactivated_queries = hash_create("aqo_deactivated_queries",
198+
deactivated_queries = hash_create("AQO deactivated queries",
199199
128, /* start small and extend */
200200
&hash_ctl,
201201
HASH_ELEM | HASH_BLOBS);
@@ -207,15 +207,29 @@ query_is_deactivated(uint64 queryid)
207207
{
208208
bool found;
209209

210-
hash_search(deactivated_queries, &queryid, HASH_FIND, &found);
210+
(void) hash_search(deactivated_queries, &queryid, HASH_FIND, &found);
211211
return found;
212212
}
213213

214214
/* Adds given query hash into the set of hashes of deactivated queries */
215215
void
216216
add_deactivated_query(uint64 queryid)
217217
{
218-
hash_search(deactivated_queries, &queryid, HASH_ENTER, NULL);
218+
(void) hash_search(deactivated_queries, &queryid, HASH_ENTER, NULL);
219+
}
220+
221+
static void
222+
reset_deactivated_queries(void)
223+
{
224+
HASH_SEQ_STATUS hash_seq;
225+
uint64 *queryid;
226+
227+
hash_seq_init(&hash_seq, deactivated_queries);
228+
while ((queryid = hash_seq_search(&hash_seq)) != NULL)
229+
{
230+
if (!hash_search(deactivated_queries, queryid, HASH_REMOVE, NULL))
231+
elog(PANIC, "[AQO] hash table corrupted");
232+
}
219233
}
220234

221235
/*
@@ -2177,7 +2191,6 @@ aqo_queries_update(PG_FUNCTION_ARGS)
21772191
{ PG_ARGISNULL(AQ_FS), PG_ARGISNULL(AQ_LEARN_AQO),
21782192
PG_ARGISNULL(AQ_USE_AQO), PG_ARGISNULL(AQ_AUTO_TUNING) };
21792193

2180-
21812194
if (PG_ARGISNULL(AQ_QUERYID))
21822195
PG_RETURN_BOOL(false);
21832196

@@ -2209,6 +2222,10 @@ aqo_reset(PG_FUNCTION_ARGS)
22092222
counter += aqo_qtexts_reset();
22102223
counter += aqo_data_reset();
22112224
counter += aqo_queries_reset();
2225+
2226+
/* Cleanup cache of deactivated queries */
2227+
reset_deactivated_queries();
2228+
22122229
PG_RETURN_INT64(counter);
22132230
}
22142231

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy