Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 625f1ff

Browse files
committed
implicitely add referee_decision to the local relations hash. that fix posiible corruption of recovery due to pkey violation
1 parent 3b3b477 commit 625f1ff

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

multimaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,7 @@ MtmCreateLocalTableMap(void)
23112311
return htab;
23122312
}
23132313

2314-
static void MtmMakeRelationLocal(Oid relid)
2314+
void MtmMakeRelationLocal(Oid relid)
23152315
{
23162316
if (OidIsValid(relid)) {
23172317
MtmLock(LW_EXCLUSIVE);

multimaster.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ extern void MtmSetupReplicationHooks(struct PGLogicalHooks* hooks);
432432
extern bool MtmRecoveryCaughtUp(int nodeId, lsn_t walEndPtr);
433433
extern void MtmCheckRecoveryCaughtUp(int nodeId, lsn_t slotLSN);
434434
extern void MtmMakeTableLocal(char const* schema, char const* name);
435+
extern void MtmMakeRelationLocal(Oid relid);
435436
extern void MtmHandleApplyError(void);
436437
extern void MtmUpdateLsnMapping(int nodeId, lsn_t endLsn);
437438
extern lsn_t MtmGetFlushPosition(int nodeId);

pglogical_apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ process_remote_insert(StringInfo s, Relation rel)
859859
/* TODO: Report tuple identity in log */
860860
ereport(ERROR,
861861
(errcode(ERRCODE_UNIQUE_VIOLATION),
862-
MTM_ERRMSG("Unique constraints violated by remotely INSERTed tuple"),
862+
MTM_ERRMSG("Unique constraints violated by remotely INSERTed tuple in %s", RelationGetRelationName(rel)),
863863
errdetail("Cannot apply transaction because remotely INSERTed tuple conflicts with a local tuple on UNIQUE constraint and/or PRIMARY KEY")));
864864
}
865865
CHECK_FOR_INTERRUPTS();

state.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,25 @@ MtmRefereeHasLocalTable()
577577
{
578578
RangeVar *rv;
579579
Oid rel_oid;
580+
static bool _has_local_tables;
581+
582+
/* memoized */
583+
if (_has_local_tables)
584+
return true;
580585

581586
StartTransactionCommand();
582587
rv = makeRangeVar(MULTIMASTER_SCHEMA_NAME, "referee_decision", -1);
583588
rel_oid = RangeVarGetRelid(rv, NoLock, true);
584589
CommitTransactionCommand();
585590

586-
return OidIsValid(rel_oid);
591+
if (OidIsValid(rel_oid))
592+
{
593+
MtmMakeRelationLocal(rel_oid);
594+
_has_local_tables = true;
595+
return true;
596+
}
597+
else
598+
return false;
587599
}
588600

589601
static int

0 commit comments

Comments
 (0)