Skip to content

Commit 4f725b0

Browse files
committed
Several bugfixes here:
1. don't enable statement timeout in parallel worker and 2. minor DSM cache fix. 3. don't clear learn_cache in a parallel worker.
1 parent 58fe21c commit 4f725b0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

‎aqo_shared.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,10 @@ reset_dsm_cache(void)
7777

7878
Assert(LWLockHeldByMeInMode(&aqo_state->lock, LW_EXCLUSIVE));
7979

80-
if (aqo_state->dsm_handler == DSM_HANDLE_INVALID)
80+
if (aqo_state->dsm_handler == DSM_HANDLE_INVALID || !seg)
8181
/* Fast path. No any cached data exists. */
8282
return;
8383

84-
Assert(seg);
85-
8684
hdr = (dsm_seg_hdr *) dsm_segment_address(seg);
8785
start = (char *) hdr + sizeof(dsm_seg_hdr);
8886

‎learn_cache.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include "postgres.h"
16+
#include "access/parallel.h" /* Just for IsParallelWorker() */
1617
#include "miscadmin.h"
1718

1819
#include "aqo.h"
@@ -316,20 +317,25 @@ lc_assign_hook(bool newval, void *extra)
316317
HASH_SEQ_STATUS status;
317318
htab_entry *entry;
318319

319-
if (!fss_htab || !IsUnderPostmaster)
320+
if (!fss_htab || !IsUnderPostmaster || IsParallelWorker())
321+
/* Clean this shared cache only in main backend process. */
320322
return;
321323

322324
/* Remove all entries, reset memory context. */
323325

324326
elog(DEBUG5, "[AQO] Cleanup local cache of ML data.");
325327

326-
/* Remove all frozen plans from a plancache. */
328+
/* Remove all entries in the shared hash table. */
327329
LWLockAcquire(&aqo_state->lock, LW_EXCLUSIVE);
328330
hash_seq_init(&status, fss_htab);
329331
while ((entry = (htab_entry *) hash_seq_search(&status)) != NULL)
330332
{
331333
if (!hash_search(fss_htab, (void *) &entry->key, HASH_REMOVE, NULL))
332334
elog(PANIC, "[AQO] The local ML cache is corrupted.");
333335
}
336+
337+
/* Now, clean additional DSM block */
338+
reset_dsm_cache();
339+
334340
LWLockRelease(&aqo_state->lock);
335341
}

0 commit comments

Comments
 (0)