From 01540d78d61dc31b96399e7b4ddb1fb12d228951 Mon Sep 17 00:00:00 2001 From: Sameer Awasekar Date: Wed, 1 Jun 2022 23:13:33 +0530 Subject: [PATCH] Rename method to IsCommitRecursive --- src/backend/distributed/shardsplit/pgoutput.c | 20 +++++++++---------- .../shardsplit/shardsplit_shared_memory.c | 9 --------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/backend/distributed/shardsplit/pgoutput.c b/src/backend/distributed/shardsplit/pgoutput.c index f0d6d5c96..e7f37faa3 100644 --- a/src/backend/distributed/shardsplit/pgoutput.c +++ b/src/backend/distributed/shardsplit/pgoutput.c @@ -33,7 +33,7 @@ static void split_change_cb(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change); /* Helper methods */ -static bool ShouldCommitBeApplied(Relation sourceShardRelation); +static bool IsCommitRecursive(Relation sourceShardRelation); static int32_t GetHashValueForIncomingTuple(Relation sourceShardRelation, HeapTuple tuple, bool *shouldHandleUpdate); @@ -183,29 +183,28 @@ FindTargetRelationOid(Relation sourceShardRelation, /* - * ShouldCommitBeApplied avoids recursive commit case when source shard and - * new split child shards are placed on the same node. When the source shard + * IsCommitRecursive returns true when commit is recursive. When the source shard * recives a commit(1), the WAL sender processes this commit message. This * commit is applied to a child shard which is placed on the same node as a - * part of replication. This in turn creates one more commit(2). + * part of replication. This in turn creates one more commit(2) which is recursive in nature. * Commit 2 should be skipped as the source shard and destination for commit 2 * are same and the commit has already been applied. */ bool -ShouldCommitBeApplied(Relation sourceShardRelation) +IsCommitRecursive(Relation sourceShardRelation) { Oid sourceShardOid = sourceShardRelation->rd_id; for (int i = 0; i < shardSplitInfoArraySize; i++) { /* skip the commit when destination is equal to the source */ ShardSplitInfo *shardSplitInfo = &shardSplitInfoArray[i]; - if (shardSplitInfo->splitChildShardOid == sourceShardOid) + if (sourceShardOid == shardSplitInfo->splitChildShardOid) { - return false; + return true; } } - return true; + return false; } @@ -229,13 +228,14 @@ split_change_cb(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, &shardSplitInfoArraySize); } - char *replicationSlotName = ctx->slot->data.name.data; - if (!ShouldCommitBeApplied(relation)) + /* avoid applying recursive commit */ + if (IsCommitRecursive(relation)) { return; } Oid targetRelationOid = InvalidOid; + char *replicationSlotName = ctx->slot->data.name.data; switch (change->action) { case REORDER_BUFFER_CHANGE_INSERT: diff --git a/src/backend/distributed/shardsplit/shardsplit_shared_memory.c b/src/backend/distributed/shardsplit/shardsplit_shared_memory.c index 34dd6646c..0e2ac6029 100644 --- a/src/backend/distributed/shardsplit/shardsplit_shared_memory.c +++ b/src/backend/distributed/shardsplit/shardsplit_shared_memory.c @@ -202,15 +202,6 @@ decode_replication_slot(char *slotName, uint32_t *nodeId, dsm_handle *dsmHandle) { - if (slotName == NULL || - nodeId == NULL || - dsmHandle == NULL) - { - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Invalid Out parameters"))); - } - int index = 0; char *strtokPosition = NULL; char *dupSlotName = pstrdup(slotName);