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

Commit83dc5af

Browse files
committed
fix complete cache invalidation event handling
1 parent3370dc4 commit83dc5af

File tree

5 files changed

+199
-67
lines changed

5 files changed

+199
-67
lines changed

‎src/hooks.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
#include"utils/lsyscache.h"
3737

3838

39+
#ifdefUSE_ASSERT_CHECKING
40+
#defineUSE_RELCACHE_LOGGING
41+
#endif
42+
43+
3944
/* Borrowed from joinpath.c */
4045
#definePATH_PARAM_BY_REL(path,rel) \
4146
((path)->param_info && bms_overlap(PATH_REQ_OUTER(path), (rel)->relids))
@@ -808,6 +813,18 @@ pathman_relcache_hook(Datum arg, Oid relid)
808813
if (!IsPathmanReady())
809814
return;
810815

816+
/* Special case: flush whole relcache */
817+
if (relid==InvalidOid)
818+
{
819+
delay_invalidation_whole_cache();
820+
821+
#ifdefUSE_RELCACHE_LOGGING
822+
elog(DEBUG2,"Invalidation message for all relations [%u]",MyProcPid);
823+
#endif
824+
825+
return;
826+
}
827+
811828
/* We shouldn't even consider special OIDs */
812829
if (relid<FirstNormalObjectId)
813830
return;
@@ -827,16 +844,20 @@ pathman_relcache_hook(Datum arg, Oid relid)
827844
{
828845
delay_invalidation_parent_rel(parent_relid);
829846

847+
#ifdefUSE_RELCACHE_LOGGING
830848
elog(DEBUG2,"Invalidation message for partition %u [%u]",
831849
relid,MyProcPid);
850+
#endif
832851
}
833852
/* We can't say, perform full invalidation procedure */
834853
else
835854
{
836855
delay_invalidation_vague_rel(relid);
837856

838-
elog(DEBUG2,"Invalidation message for vague relation %u [%u]",
857+
#ifdefUSE_RELCACHE_LOGGING
858+
elog(DEBUG2,"Invalidation message for vague rel %u [%u]",
839859
relid,MyProcPid);
860+
#endif
840861
}
841862
}
842863

‎src/include/init.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef struct
5454

5555
#definePATHMAN_MCXT_COUNT4
5656
externMemoryContextTopPathmanContext;
57+
externMemoryContextPathmanInvalJobsContext;
5758
externMemoryContextPathmanRelationCacheContext;
5859
externMemoryContextPathmanParentCacheContext;
5960
externMemoryContextPathmanBoundCacheContext;

‎src/include/relation_info.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ const PartRelationInfo *refresh_pathman_relation_info(Oid relid,
275275
Datum*values,
276276
boolallow_incomplete);
277277
PartRelationInfo*invalidate_pathman_relation_info(Oidrelid,bool*found);
278+
voidinvalidate_pathman_relation_info_cache(constOid*parents,intparents_count);
278279
voidremove_pathman_relation_info(Oidrelid);
279280
constPartRelationInfo*get_pathman_relation_info(Oidrelid);
280281
constPartRelationInfo*get_pathman_relation_info_after_lock(Oidrelid,
@@ -296,6 +297,7 @@ char *canonicalize_partitioning_expression(const Oid relid,
296297

297298
/* Global invalidation routines */
298299
voiddelay_pathman_shutdown(void);
300+
voiddelay_invalidation_whole_cache(void);
299301
voiddelay_invalidation_parent_rel(Oidparent);
300302
voiddelay_invalidation_vague_rel(Oidvague_rel);
301303
voidfinish_delayed_invalidation(void);

‎src/init.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
/* Various memory contexts for caches */
4343
MemoryContextTopPathmanContext=NULL;
44+
MemoryContextPathmanInvalJobsContext=NULL;
4445
MemoryContextPathmanRelationCacheContext=NULL;
4546
MemoryContextPathmanParentCacheContext=NULL;
4647
MemoryContextPathmanBoundCacheContext=NULL;
@@ -312,6 +313,7 @@ init_local_cache(void)
312313
if (TopPathmanContext)
313314
{
314315
/* Check that child contexts exist */
316+
Assert(MemoryContextIsValid(PathmanInvalJobsContext));
315317
Assert(MemoryContextIsValid(PathmanRelationCacheContext));
316318
Assert(MemoryContextIsValid(PathmanParentCacheContext));
317319
Assert(MemoryContextIsValid(PathmanBoundCacheContext));
@@ -322,6 +324,7 @@ init_local_cache(void)
322324
/* Initialize pg_pathman's memory contexts */
323325
else
324326
{
327+
Assert(PathmanInvalJobsContext==NULL);
325328
Assert(PathmanRelationCacheContext==NULL);
326329
Assert(PathmanParentCacheContext==NULL);
327330
Assert(PathmanBoundCacheContext==NULL);
@@ -331,6 +334,11 @@ init_local_cache(void)
331334
CppAsString(TopPathmanContext),
332335
ALLOCSET_DEFAULT_SIZES);
333336

337+
PathmanInvalJobsContext=
338+
AllocSetContextCreate(TopMemoryContext,
339+
CppAsString(PathmanInvalJobsContext),
340+
ALLOCSET_SMALL_SIZES);
341+
334342
/* For PartRelationInfo */
335343
PathmanRelationCacheContext=
336344
AllocSetContextCreate(TopPathmanContext,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp