-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix regression that stopped retention working on empty partition…
… sets
- Loading branch information
Showing
3 changed files
with
15 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ LOOP | |
SELECT child_start_time INTO v_partition_timestamp FROM @[email protected]_partition_info(v_row.partition_schemaname||'.'||v_row.partition_tablename | ||
, v_partition_interval::text | ||
, p_parent_table); | ||
-- Add one interval since partition names contain the start of the constraint period | ||
-- Add one interval since partition lower boundary is the start of the constraint period | ||
IF (v_partition_timestamp + v_partition_interval) < (p_reference_timestamp - v_retention) THEN | ||
|
||
-- Do not allow final partition to be dropped if it is not a sub-partition parent | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,8 +254,14 @@ LOOP | |
RAISE DEBUG 'run_maint: v_current_partition_timestamp: %, v_max_time_default: %', v_current_partition_timestamp, v_max_time_default; | ||
IF v_current_partition_timestamp IS NULL AND v_max_time_default IS NULL THEN | ||
-- Partition set is completely empty and infinite time partitions not set | ||
-- Nothing to do | ||
|
||
-- Still need to run retention if needed. Note similar call below for non-empty sets. Keep in sync. | ||
IF v_row.retention IS NOT NULL THEN | ||
v_drop_count := v_drop_count + @[email protected]_partition_time(v_row.parent_table); | ||
END IF; | ||
|
||
UPDATE @[email protected]_config SET maintenance_last_run = clock_timestamp() WHERE parent_table = v_row.parent_table; | ||
-- Nothing else to do | ||
CONTINUE; | ||
END IF; | ||
RAISE DEBUG 'run_maint: v_child_timestamp: %, v_current_partition_timestamp: %, v_max_time_default: %', v_child_timestamp, v_current_partition_timestamp, v_max_time_default; | ||
|
@@ -314,7 +320,7 @@ LOOP | |
v_premade_count = round(EXTRACT('epoch' FROM age(v_next_partition_timestamp, v_current_partition_timestamp)) / EXTRACT('epoch' FROM v_row.partition_interval::interval)); | ||
END LOOP; | ||
|
||
-- Run retention if needed | ||
-- Run retention if needed. Note similar call above when partition set is empty. Keep in sync. | ||
IF v_row.retention IS NOT NULL THEN | ||
v_drop_count := v_drop_count + @[email protected]_partition_time(v_row.parent_table); | ||
END IF; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters