mirror of https://github.com/citusdata/citus.git
Use "orphaned shards" naming in more places
We were not very consistent in how we named these shards.pull/5024/head
parent
3f60e4f394
commit
1a83628195
|
@ -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,
|
||||
|
|
|
@ -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))));
|
||||
}
|
||||
|
||||
|
|
|
@ -701,7 +701,7 @@ ExecutePlacementUpdates(List *placementUpdateList, Oid shardReplicationModeOid,
|
|||
"unsupported")));
|
||||
}
|
||||
|
||||
DropMarkedShardsInSeparateTransaction();
|
||||
DropOrphanedShardsInSeparateTransaction();
|
||||
|
||||
foreach(placementUpdateCell, placementUpdateList)
|
||||
{
|
||||
|
|
|
@ -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 "
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -645,7 +645,7 @@ CitusMaintenanceDaemonMain(Datum main_arg)
|
|||
lastShardCleanTime = GetCurrentTimestamp();
|
||||
|
||||
bool waitForLocks = false;
|
||||
numberOfDroppedShards = TryDropMarkedShards(waitForLocks);
|
||||
numberOfDroppedShards = TryDropOrphanedShards(waitForLocks);
|
||||
}
|
||||
|
||||
CommitTransactionCommand();
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -79,7 +79,7 @@ step s1-drop-marked-shards:
|
|||
<waiting ...>
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue