Deferred drop Hello World

niupre/TestDeferredDropAndCleanup
Nitish Upreti 2022-08-25 13:18:04 -07:00
parent bf61fe3565
commit 92b1cdf6c0
3 changed files with 15 additions and 4 deletions

View File

@ -61,6 +61,8 @@ typedef struct CleanupRecord
CleanupPolicy policy;
} CleanupRecord;
/* operation ID set by StartNewOperationNeedingCleanup */
OperationId CurrentOperationId = INVALID_OPERATION_ID;
/* declarations for dynamic loading */
PG_FUNCTION_INFO_V1(citus_cleanup_orphaned_shards);
@ -189,6 +191,12 @@ TryDropOrphanedShards(bool waitForLocks)
static int
DropOrphanedShardsForCleanup()
{
/* Only runs on Coordinator */
if (!IsCoordinator())
{
return 0;
}
List *cleanupRecordList = ListCleanupRecords();
int removedShardCountForCleanup = 0;
@ -543,7 +551,7 @@ static bool
TryDropShardOutsideTransaction(char *qualifiedTableName, char *nodeName, int nodePort)
{
ereport(LOG, (errmsg("dropping shard placement %s "
"on %s:%d after it was moved away",
"on %s:%d",
qualifiedTableName, nodeName, nodePort)));
/* prepare sql query to execute to drop the shard */

View File

@ -92,5 +92,8 @@ ALTER TABLE citus.pg_dist_cleanup SET SCHEMA pg_catalog;
-- Sequence used to generate an operation ID for use in pg_dist_cleanup_record.
CREATE SEQUENCE citus.pg_dist_operation_id_seq;
ALTER SEQUENCE citus.pg_dist_operation_id_seq SET SCHEMA pg_catalog;
CREATE SEQUENCE citus.pg_dist_operationid_seq;
ALTER SEQUENCE citus.pg_dist_operationid_seq SET SCHEMA pg_catalog;
CREATE SEQUENCE citus.pg_dist_cleanup_recordid_seq;
ALTER SEQUENCE citus.pg_dist_cleanup_recordid_seq SET SCHEMA pg_catalog;

View File

@ -28,7 +28,7 @@
#define PG_CATALOG "pg_catalog"
#define PG_DIST_CLEANUP "pg_dist_cleanup"
#define OPERATIONID_SEQUENCE_NAME "pg_dist_operationid_seq"
#define CLEANUPRECORDID_SEQUENCE_NAME "pg_dist_cleanup_record_id_seq"
#define CLEANUPRECORDID_SEQUENCE_NAME "pg_dist_cleanup_recordid_seq"
#endif /* PG_DIST_CLEANUP_H */