From ed6dd8b0861f0df03ca6f454028ecab2d04df78c Mon Sep 17 00:00:00 2001 From: Ahmet Gedemenli Date: Fri, 13 Jan 2023 15:33:43 +0300 Subject: [PATCH] Mark 0/0 lsn results as null (#6617) Marks `source_lsn` and `target_lsn` fields as null if the result is 0/0 --- .../distributed/operations/shard_rebalancer.c | 10 + .../isolation_shard_rebalancer_progress.out | 180 +++++++++--------- .../isolation_shard_rebalancer_progress.spec | 12 +- 3 files changed, 106 insertions(+), 96 deletions(-) diff --git a/src/backend/distributed/operations/shard_rebalancer.c b/src/backend/distributed/operations/shard_rebalancer.c index dd9eb4a1f..66da61dd9 100644 --- a/src/backend/distributed/operations/shard_rebalancer.c +++ b/src/backend/distributed/operations/shard_rebalancer.c @@ -1298,7 +1298,17 @@ get_rebalance_progress(PG_FUNCTION_ARGS) values[11] = PointerGetDatum( cstring_to_text(PlacementUpdateTypeNames[step->updateType])); values[12] = LSNGetDatum(sourceLSN); + if (sourceLSN == InvalidXLogRecPtr) + { + nulls[12] = true; + } + values[13] = LSNGetDatum(targetLSN); + if (targetLSN == InvalidXLogRecPtr) + { + nulls[13] = true; + } + values[14] = PointerGetDatum(cstring_to_text( PlacementUpdateStatusNames[ pg_atomic_read_u64( diff --git a/src/test/regress/expected/isolation_shard_rebalancer_progress.out b/src/test/regress/expected/isolation_shard_rebalancer_progress.out index ba210da34..8553a1d4d 100644 --- a/src/test/regress/expected/isolation_shard_rebalancer_progress.out +++ b/src/test/regress/expected/isolation_shard_rebalancer_progress.out @@ -32,9 +32,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -76,9 +76,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -115,9 +115,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -154,9 +154,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -197,9 +197,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -241,9 +241,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -284,9 +284,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -328,9 +328,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -371,9 +371,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -415,9 +415,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -458,9 +458,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -500,9 +500,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -543,9 +543,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -585,9 +585,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -629,9 +629,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -671,9 +671,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -715,9 +715,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -757,9 +757,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -800,9 +800,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -842,9 +842,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -885,9 +885,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -927,9 +927,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -971,9 +971,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -1013,9 +1013,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -1057,9 +1057,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -1099,9 +1099,9 @@ step s7-get-progress: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); @@ -1145,9 +1145,9 @@ step s7-get-progress-ordered: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available FROM get_rebalance_progress() ORDER BY 1, 2, 3, 4, 5; @@ -1195,9 +1195,9 @@ step s7-get-progress-ordered: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available FROM get_rebalance_progress() ORDER BY 1, 2, 3, 4, 5; @@ -1241,9 +1241,9 @@ step s7-get-progress-ordered: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available FROM get_rebalance_progress() ORDER BY 1, 2, 3, 4, 5; @@ -1291,9 +1291,9 @@ step s7-get-progress-ordered: ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available FROM get_rebalance_progress() ORDER BY 1, 2, 3, 4, 5; diff --git a/src/test/regress/spec/isolation_shard_rebalancer_progress.spec b/src/test/regress/spec/isolation_shard_rebalancer_progress.spec index d7c540101..e329e9483 100644 --- a/src/test/regress/spec/isolation_shard_rebalancer_progress.spec +++ b/src/test/regress/spec/isolation_shard_rebalancer_progress.spec @@ -144,9 +144,9 @@ step "s7-get-progress" ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available, + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available, status FROM get_rebalance_progress(); } @@ -170,9 +170,9 @@ step "s7-get-progress-ordered" ( SELECT size FROM possible_sizes WHERE ABS(size - target_shard_size) = (SELECT MIN(ABS(size - target_shard_size)) FROM possible_sizes )) target_shard_size, progress, operation_type, - source_lsn >= target_lsn as lsn_sanity_check, - source_lsn > '0/0' as source_lsn_available, - target_lsn > '0/0' as target_lsn_available + target_lsn IS NULL OR source_lsn >= target_lsn AS lsn_sanity_check, + source_lsn IS NOT NULL AS source_lsn_available, + target_lsn IS NOT NULL AS target_lsn_available FROM get_rebalance_progress() ORDER BY 1, 2, 3, 4, 5; }