Use "orphaned shards" naming in more places

We were not very consistent in how we named these shards.
pull/5024/head
Jelte Fennema 2021-06-04 11:31:06 +02:00
parent 3f60e4f394
commit 1a83628195
8 changed files with 23 additions and 21 deletions

View File

@ -1067,7 +1067,7 @@ EnsureShardCanBeCopied(int64 shardId, const char *sourceNodeName, int32 sourceNo
* Trigger deletion of orphaned shards and hope that this removes * Trigger deletion of orphaned shards and hope that this removes
* the shard. * the shard.
*/ */
DropMarkedShardsInSeparateTransaction(); DropOrphanedShardsInSeparateTransaction();
shardPlacementList = ShardPlacementList(shardId); shardPlacementList = ShardPlacementList(shardId);
targetPlacement = SearchShardPlacementInList(shardPlacementList, targetPlacement = SearchShardPlacementInList(shardPlacementList,
targetNodeName, targetNodeName,

View File

@ -56,7 +56,7 @@ citus_cleanup_orphaned_shards(PG_FUNCTION_ARGS)
PreventInTransactionBlock(true, "citus_cleanup_orphaned_shards"); PreventInTransactionBlock(true, "citus_cleanup_orphaned_shards");
bool waitForLocks = true; bool waitForLocks = true;
int droppedShardCount = DropMarkedShards(waitForLocks); int droppedShardCount = DropOrphanedShards(waitForLocks);
if (droppedShardCount > 0) if (droppedShardCount > 0)
{ {
ereport(NOTICE, (errmsg("cleaned up %d orphaned shards", droppedShardCount))); ereport(NOTICE, (errmsg("cleaned up %d orphaned shards", droppedShardCount)));
@ -78,7 +78,7 @@ isolation_cleanup_orphaned_shards(PG_FUNCTION_ARGS)
EnsureCoordinator(); EnsureCoordinator();
bool waitForLocks = true; bool waitForLocks = true;
int droppedShardCount = DropMarkedShards(waitForLocks); int droppedShardCount = DropOrphanedShards(waitForLocks);
if (droppedShardCount > 0) if (droppedShardCount > 0)
{ {
ereport(NOTICE, (errmsg("cleaned up %d orphaned shards", droppedShardCount))); 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 * 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 void
DropMarkedShardsInSeparateTransaction(void) DropOrphanedShardsInSeparateTransaction(void)
{ {
ExecuteCriticalCommandInSeparateTransaction("CALL citus_cleanup_orphaned_shards()"); 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. * 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 * If dropping any of the shards failed this function returns -1, otherwise it
* returns the number of dropped shards. * returns the number of dropped shards.
*/ */
int int
TryDropMarkedShards(bool waitForLocks) TryDropOrphanedShards(bool waitForLocks)
{ {
int droppedShardCount = 0; int droppedShardCount = 0;
MemoryContext savedContext = CurrentMemoryContext; MemoryContext savedContext = CurrentMemoryContext;
PG_TRY(); PG_TRY();
{ {
droppedShardCount = DropMarkedShards(waitForLocks); droppedShardCount = DropOrphanedShards(waitForLocks);
} }
PG_CATCH(); 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 * 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 * colocated placements before removing. If the lock cannot be obtained it
@ -152,7 +152,7 @@ TryDropMarkedShards(bool waitForLocks)
* *
*/ */
int int
DropMarkedShards(bool waitForLocks) DropOrphanedShards(bool waitForLocks)
{ {
int removedShardCount = 0; int removedShardCount = 0;
ListCell *shardPlacementCell = NULL; ListCell *shardPlacementCell = NULL;
@ -208,7 +208,7 @@ DropMarkedShards(bool waitForLocks)
if (failedShardDropCount > 0) 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)))); failedShardDropCount, list_length(shardPlacementList))));
} }

View File

@ -701,7 +701,7 @@ ExecutePlacementUpdates(List *placementUpdateList, Oid shardReplicationModeOid,
"unsupported"))); "unsupported")));
} }
DropMarkedShardsInSeparateTransaction(); DropOrphanedShardsInSeparateTransaction();
foreach(placementUpdateCell, placementUpdateList) foreach(placementUpdateCell, placementUpdateList)
{ {

View File

@ -645,7 +645,9 @@ RegisterCitusConfigVariables(void)
DefineCustomBoolVariable( DefineCustomBoolVariable(
"citus.defer_drop_after_shard_move", "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 " 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 " "long running transactions on a the shard during the drop phase of "
"the shard move. This causes some moves to be rolled back after " "the shard move. This causes some moves to be rolled back after "

View File

@ -74,13 +74,13 @@ typedef struct RebalancePlanContext
} RebalancePlacementContext; } RebalancePlacementContext;
/* /*
* run_try_drop_marked_shards is a wrapper to run TryDropMarkedShards. * run_try_drop_marked_shards is a wrapper to run TryDropOrphanedShards.
*/ */
Datum Datum
run_try_drop_marked_shards(PG_FUNCTION_ARGS) run_try_drop_marked_shards(PG_FUNCTION_ARGS)
{ {
bool waitForLocks = false; bool waitForLocks = false;
TryDropMarkedShards(waitForLocks); TryDropOrphanedShards(waitForLocks);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }

View File

@ -645,7 +645,7 @@ CitusMaintenanceDaemonMain(Datum main_arg)
lastShardCleanTime = GetCurrentTimestamp(); lastShardCleanTime = GetCurrentTimestamp();
bool waitForLocks = false; bool waitForLocks = false;
numberOfDroppedShards = TryDropMarkedShards(waitForLocks); numberOfDroppedShards = TryDropOrphanedShards(waitForLocks);
} }
CommitTransactionCommand(); CommitTransactionCommand();

View File

@ -17,8 +17,8 @@ extern bool DeferShardDeleteOnMove;
extern double DesiredPercentFreeAfterMove; extern double DesiredPercentFreeAfterMove;
extern bool CheckAvailableSpaceBeforeMove; extern bool CheckAvailableSpaceBeforeMove;
extern int TryDropMarkedShards(bool waitForLocks); extern int TryDropOrphanedShards(bool waitForLocks);
extern int DropMarkedShards(bool waitForLocks); extern int DropOrphanedShards(bool waitForLocks);
extern void DropMarkedShardsInSeparateTransaction(void); extern void DropOrphanedShardsInSeparateTransaction(void);
#endif /*CITUS_SHARD_CLEANER_H */ #endif /*CITUS_SHARD_CLEANER_H */

View File

@ -79,7 +79,7 @@ step s1-drop-marked-shards:
<waiting ...> <waiting ...>
s1: WARNING: canceling statement due to lock timeout s1: WARNING: canceling statement due to lock timeout
step s1-drop-marked-shards: <... completed> 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: step s1-commit:
COMMIT; COMMIT;