mirror of https://github.com/citusdata/citus.git
Accept invalidation before fk graph validity check (#5017)
InvalidateForeignKeyGraph sends an invalidation via shared memory to all backends, including the current one. However, we might not call AcceptInvalidationMessages before reading from the cache below. It would be better to also add a call to AcceptInvalidationMessages in IsForeignConstraintRelationshipGraphValid.pull/5022/head
parent
f9c7d74623
commit
fa29d6667a
|
@ -32,6 +32,7 @@
|
|||
#if PG_VERSION_NUM >= PG_VERSION_13
|
||||
#include "common/hashfn.h"
|
||||
#endif
|
||||
#include "utils/inval.h"
|
||||
#include "utils/memutils.h"
|
||||
|
||||
|
||||
|
@ -82,6 +83,7 @@ static ForeignConstraintRelationshipNode * GetRelationshipNodeForRelationId(Oid
|
|||
relationId,
|
||||
bool *isFound);
|
||||
static void CreateForeignConstraintRelationshipGraph(void);
|
||||
static bool IsForeignConstraintRelationshipGraphValid(void);
|
||||
static List * GetNeighbourList(ForeignConstraintRelationshipNode *relationshipNode,
|
||||
bool isReferencing);
|
||||
static List * GetRelationIdsFromRelationshipNodeList(List *fKeyRelationshipNodeList);
|
||||
|
@ -348,9 +350,15 @@ CreateForeignConstraintRelationshipGraph()
|
|||
/*
|
||||
* IsForeignConstraintGraphValid check whether there is a valid graph.
|
||||
*/
|
||||
bool
|
||||
static bool
|
||||
IsForeignConstraintRelationshipGraphValid()
|
||||
{
|
||||
/*
|
||||
* We might have some concurrent metadata changes. In order to get the changes,
|
||||
* we first need to accept the cache invalidation messages.
|
||||
*/
|
||||
AcceptInvalidationMessages();
|
||||
|
||||
if (fConstraintRelationshipGraph != NULL && fConstraintRelationshipGraph->isValid)
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -20,7 +20,6 @@ extern bool ConnectedToReferenceTableViaFKey(Oid relationId);
|
|||
extern List * ReferencedRelationIdList(Oid relationId);
|
||||
extern List * ReferencingRelationIdList(Oid relationId);
|
||||
extern void SetForeignConstraintRelationshipGraphInvalid(void);
|
||||
extern bool IsForeignConstraintRelationshipGraphValid(void);
|
||||
extern void ClearForeignConstraintRelationshipGraphContext(void);
|
||||
extern HTAB * CreateOidVisitedHashSet(void);
|
||||
extern bool OidVisited(HTAB *oidVisitedMap, Oid oid);
|
||||
|
|
Loading…
Reference in New Issue