Skip to content

Commit de05252

Browse files
committed
improve comments, better delayed_shutdown checking
1 parent b80945e commit de05252

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/relation_info.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
#include "utils/snapmgr.h"
2727

2828

29+
/*
30+
* We delay all invalidation jobs received in relcache hook.
31+
*/
2932
static List *delayed_invalidation_parent_rels = NIL;
3033
static List *delayed_invalidation_vague_rels = NIL;
31-
static bool delayed_shutdown = false;
34+
static bool delayed_shutdown = false; /* pathman was dropped */
35+
3236

3337
/* Add unique Oid to list, allocate in TopMemoryContext */
3438
#define list_add_unique(list, oid) \
@@ -291,11 +295,24 @@ finish_delayed_invalidation(void)
291295
{
292296
ListCell *lc;
293297

298+
/* Handle the probable 'DROP EXTENSION' case */
294299
if (delayed_shutdown)
295300
{
296301
delayed_shutdown = false;
297-
unload_config();
298-
return;
302+
303+
/* Check that PATHMAN_CONFIG table has indeed been dropped */
304+
if (InvalidOid == get_relname_relid(PATHMAN_CONFIG, get_pathman_schema()))
305+
{
306+
/* Ok, let's unload pg_pathman's config */
307+
unload_config();
308+
309+
/* Disregard all remaining invalidation jobs */
310+
free_invalidation_list(delayed_invalidation_parent_rels);
311+
free_invalidation_list(delayed_invalidation_vague_rels);
312+
313+
/* No need to continue, exit */
314+
return;
315+
}
299316
}
300317

301318
/* Process relations that are (or were) definitely partitioned */
@@ -324,16 +341,19 @@ finish_delayed_invalidation(void)
324341

325342
switch (search)
326343
{
344+
/* It's still parent */
327345
case PPS_ENTRY_PART_PARENT:
328346
perform_parent_refresh(parent);
329347
break;
330348

349+
/* It *might have been* parent before (not in PATHMAN_CONFIG) */
331350
case PPS_ENTRY_PARENT:
332351
remove_pathman_relation_info(parent);
333352
break;
334353

354+
/* How come we still don't know?? */
335355
case PPS_NOT_SURE:
336-
elog(ERROR, "This should never happen");
356+
elog(ERROR, "Unknown table status, this should never happen");
337357
break;
338358

339359
default:
@@ -482,6 +502,11 @@ try_syscache_parent_search(Oid partition, PartParentSearch *status)
482502
{
483503
parent = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhparent;
484504

505+
/*
506+
* NB: don't forget that 'inh' flag does not immediately
507+
* mean that this is a pg_pathman's partition. It might
508+
* be just a casual inheriting table.
509+
*/
485510
if (status) *status = PPS_ENTRY_PARENT;
486511

487512
/* Check that PATHMAN_CONFIG contains this table */

0 commit comments

Comments
 (0)