diff --git a/src/backend/distributed/operations/repair_shards.c b/src/backend/distributed/operations/repair_shards.c index 121b0afdc..c3dfa791e 100644 --- a/src/backend/distributed/operations/repair_shards.c +++ b/src/backend/distributed/operations/repair_shards.c @@ -1067,7 +1067,7 @@ EnsureShardCanBeCopied(int64 shardId, const char *sourceNodeName, int32 sourceNo * Trigger deletion of orphaned shards and hope that this removes * the shard. */ - DropMarkedShardsInSeparateTransaction(); + DropOrphanedShardsInSeparateTransaction(); shardPlacementList = ShardPlacementList(shardId); targetPlacement = SearchShardPlacementInList(shardPlacementList, targetNodeName, diff --git a/src/backend/distributed/operations/shard_cleaner.c b/src/backend/distributed/operations/shard_cleaner.c index bbd6a666c..afa206594 100644 --- a/src/backend/distributed/operations/shard_cleaner.c +++ b/src/backend/distributed/operations/shard_cleaner.c @@ -56,7 +56,7 @@ citus_cleanup_orphaned_shards(PG_FUNCTION_ARGS) PreventInTransactionBlock(true, "citus_cleanup_orphaned_shards"); bool waitForLocks = true; - int droppedShardCount = DropMarkedShards(waitForLocks); + int droppedShardCount = DropOrphanedShards(waitForLocks); if (droppedShardCount > 0) { ereport(NOTICE, (errmsg("cleaned up %d orphaned shards", droppedShardCount))); @@ -78,7 +78,7 @@ isolation_cleanup_orphaned_shards(PG_FUNCTION_ARGS) EnsureCoordinator(); bool waitForLocks = true; - int droppedShardCount = DropMarkedShards(waitForLocks); + int droppedShardCount = DropOrphanedShards(waitForLocks); if (droppedShardCount > 0) { ereport(NOTICE, (errmsg("cleaned up %d orphaned shards", droppedShardCount))); @@ -89,32 +89,32 @@ isolation_cleanup_orphaned_shards(PG_FUNCTION_ARGS) /* - * DropMarkedShardsInSeparateTransaction cleans up orphaned shards by + * DropOrphanedShardsInSeparateTransaction cleans up orphaned shards by * connecting to localhost. This is done, so that the locks that - * DropMarkedShards takes are only held for a short time. + * DropOrphanedShards takes are only held for a short time. */ void -DropMarkedShardsInSeparateTransaction(void) +DropOrphanedShardsInSeparateTransaction(void) { ExecuteCriticalCommandInSeparateTransaction("CALL citus_cleanup_orphaned_shards()"); } /* - * TryDropMarkedShards is a wrapper around DropMarkedShards that catches + * TryDropOrphanedShards is a wrapper around DropOrphanedShards that catches * any errors to make it safe to use in the maintenance daemon. * * If dropping any of the shards failed this function returns -1, otherwise it * returns the number of dropped shards. */ int -TryDropMarkedShards(bool waitForLocks) +TryDropOrphanedShards(bool waitForLocks) { int droppedShardCount = 0; MemoryContext savedContext = CurrentMemoryContext; PG_TRY(); { - droppedShardCount = DropMarkedShards(waitForLocks); + droppedShardCount = DropOrphanedShards(waitForLocks); } PG_CATCH(); { @@ -133,7 +133,7 @@ TryDropMarkedShards(bool waitForLocks) /* - * DropMarkedShards removes shards that were marked SHARD_STATE_TO_DELETE before. + * DropOrphanedShards removes shards that were marked SHARD_STATE_TO_DELETE before. * * It does so by trying to take an exclusive lock on the shard and its * colocated placements before removing. If the lock cannot be obtained it @@ -152,7 +152,7 @@ TryDropMarkedShards(bool waitForLocks) * */ int -DropMarkedShards(bool waitForLocks) +DropOrphanedShards(bool waitForLocks) { int removedShardCount = 0; ListCell *shardPlacementCell = NULL; @@ -208,7 +208,7 @@ DropMarkedShards(bool waitForLocks) if (failedShardDropCount > 0) { - ereport(WARNING, (errmsg("Failed to drop %d old shards out of %d", + ereport(WARNING, (errmsg("Failed to drop %d orphaned shards out of %d", failedShardDropCount, list_length(shardPlacementList)))); } diff --git a/src/backend/distributed/operations/shard_rebalancer.c b/src/backend/distributed/operations/shard_rebalancer.c index 93716e624..0049d1f0e 100644 --- a/src/backend/distributed/operations/shard_rebalancer.c +++ b/src/backend/distributed/operations/shard_rebalancer.c @@ -701,7 +701,7 @@ ExecutePlacementUpdates(List *placementUpdateList, Oid shardReplicationModeOid, "unsupported"))); } - DropMarkedShardsInSeparateTransaction(); + DropOrphanedShardsInSeparateTransaction(); foreach(placementUpdateCell, placementUpdateList) { diff --git a/src/backend/distributed/shared_library_init.c b/src/backend/distributed/shared_library_init.c index 1f80eb45e..3bc921c55 100644 --- a/src/backend/distributed/shared_library_init.c +++ b/src/backend/distributed/shared_library_init.c @@ -645,7 +645,9 @@ RegisterCitusConfigVariables(void) DefineCustomBoolVariable( "citus.defer_drop_after_shard_move", - gettext_noop("When enabled a shard move will mark old shards for deletion"), + gettext_noop("When enabled a shard move will mark the original shards " + "for deletion after a successful move, instead of deleting " + "them right away."), gettext_noop("The deletion of a shard can sometimes run into a conflict with a " "long running transactions on a the shard during the drop phase of " "the shard move. This causes some moves to be rolled back after " diff --git a/src/backend/distributed/test/shard_rebalancer.c b/src/backend/distributed/test/shard_rebalancer.c index d43ffe446..4cccd851d 100644 --- a/src/backend/distributed/test/shard_rebalancer.c +++ b/src/backend/distributed/test/shard_rebalancer.c @@ -74,13 +74,13 @@ typedef struct RebalancePlanContext } RebalancePlacementContext; /* - * run_try_drop_marked_shards is a wrapper to run TryDropMarkedShards. + * run_try_drop_marked_shards is a wrapper to run TryDropOrphanedShards. */ Datum run_try_drop_marked_shards(PG_FUNCTION_ARGS) { bool waitForLocks = false; - TryDropMarkedShards(waitForLocks); + TryDropOrphanedShards(waitForLocks); PG_RETURN_VOID(); } diff --git a/src/backend/distributed/utils/maintenanced.c b/src/backend/distributed/utils/maintenanced.c index 293698180..2295830d6 100644 --- a/src/backend/distributed/utils/maintenanced.c +++ b/src/backend/distributed/utils/maintenanced.c @@ -645,7 +645,7 @@ CitusMaintenanceDaemonMain(Datum main_arg) lastShardCleanTime = GetCurrentTimestamp(); bool waitForLocks = false; - numberOfDroppedShards = TryDropMarkedShards(waitForLocks); + numberOfDroppedShards = TryDropOrphanedShards(waitForLocks); } CommitTransactionCommand(); diff --git a/src/include/distributed/shard_cleaner.h b/src/include/distributed/shard_cleaner.h index 83daf5cff..8a98254f9 100644 --- a/src/include/distributed/shard_cleaner.h +++ b/src/include/distributed/shard_cleaner.h @@ -17,8 +17,8 @@ extern bool DeferShardDeleteOnMove; extern double DesiredPercentFreeAfterMove; extern bool CheckAvailableSpaceBeforeMove; -extern int TryDropMarkedShards(bool waitForLocks); -extern int DropMarkedShards(bool waitForLocks); -extern void DropMarkedShardsInSeparateTransaction(void); +extern int TryDropOrphanedShards(bool waitForLocks); +extern int DropOrphanedShards(bool waitForLocks); +extern void DropOrphanedShardsInSeparateTransaction(void); #endif /*CITUS_SHARD_CLEANER_H */ diff --git a/src/test/regress/expected/isolation_rebalancer_deferred_drop.out b/src/test/regress/expected/isolation_rebalancer_deferred_drop.out index 0a982936e..199678ca0 100644 --- a/src/test/regress/expected/isolation_rebalancer_deferred_drop.out +++ b/src/test/regress/expected/isolation_rebalancer_deferred_drop.out @@ -79,7 +79,7 @@ step s1-drop-marked-shards: s1: WARNING: canceling statement due to lock timeout step s1-drop-marked-shards: <... completed> -s1: WARNING: Failed to drop 1 old shards out of 1 +s1: WARNING: Failed to drop 1 orphaned shards out of 1 step s1-commit: COMMIT;