You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d9a7b1c
Browse filesBrowse the repository at this point in the historyBrowse files
Alexey Shalaev
committed
feat: an expired partition stays detached for a week unless the policy names a drop
A LifecyclePolicy without drop= (every flat config, every bare TablePartitionConfig, every YAML table without drop:) used DropAfter() with no grace, so an expired partition was detached and dropped in the same run and a wrong retention lost the data at once. The default is now DropAfter(grace=timedelta(days=7)). An explicit DropAfter() keeps its zero grace; DropNever() is unchanged.
Closes#106
Copy file name to clipboardExpand all lines: docs/concepts/lifecycle.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,8 +138,8 @@ referencing rows are gone. See [Handle foreign keys](../guide/foreign-keys.md).
138
138
139
139
| Rule | Effect |
140
140
|---|---|
141
-
|`DropAfter()` (default: no grace) | dropped in the same run as the detach |
142
-
|`DropAfter(grace=timedelta(days=7))`| kept detached for a week, then dropped. The detach instant is recorded on the table's marker; an orphan marked by an older version, or adopted, has no instant and is treated as past its grace |
141
+
|`DropAfter()` (no grace) | dropped in the same run as the detach |
142
+
|`DropAfter(grace=timedelta(days=7))`(the default when the policy names no drop) | kept detached for a week, then dropped. The detach instant is recorded on the table's marker; an orphan marked by an older version, or adopted, has no instant and is treated as past its grace |
143
143
|`DropAfter(grace=…, when=predicate)`| dropped only once the grace has passed *and* the predicate holds — "not while bigger than 150 GB on a weekday" is a `Callback` over the size fact |
144
144
|`DropNever()`| detached partitions are left alone; something else owns the drop — an archive pipeline, a DBA. They are never re-attached, and a wanted window whose name such a table holds is reported (`name_unusable`), not recreated over it |
ACCESS SHARE on the template during CREATE; SHARE UPDATE EXCLUSIVE on the parent and ACCESS EXCLUSIVE on the new partition (and on a DEFAULT sibling) during ATTACH -- EXCLUSIVE on the parent instead, which holds off writes, when rows of the window are taken out of a DEFAULT sibling in the attach's transaction; SHARE ROW EXCLUSIVE on every table referencing the parent through a foreign key
181
180
DETACH public.events__2025_08 (outside a transaction block)
182
181
SHARE UPDATE EXCLUSIVE on the parent (CONCURRENTLY), ACCESS EXCLUSIVE on the partition and, in the second transaction, on every table referencing the parent through a foreign key; ...
183
-
DROP public.events__2025_08
184
-
ACCESS EXCLUSIVE on the dropped table only
185
182
```
186
183
187
184
The heaviest lock each operation takes, and on what, as measured on PostgreSQL 15 and 17
Copy file name to clipboardExpand all lines: docs/reference/configuration.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Types are the accepted inputs; defaults are what you get when the field is omitt
10
10
|`schema`|`str`|`None`| Schema of the parent table; read back as `db_schema`. Recommended. |
11
11
|`table_name`|`str`| required | The parent table, lowercase, at most 63 bytes minus the scheme's longest suffix. |
12
12
|`scheme`|`RangePartitioning \| ListPartitioning \| HashPartitioning`| from the flat fields | The root level and everything below it. |
13
-
|`lifecycle`|`LifecyclePolicy`|`CreateAhead(count=6)`, `KeepNewest(count=12)`, `DetachMode.AUTO`, `DropAfter()`| When partitions of the progression level are created, detached and dropped. |
13
+
|`lifecycle`|`LifecyclePolicy`|`CreateAhead(count=6)`, `KeepNewest(count=12)`, `DetachMode.AUTO`, `DropAfter(grace=timedelta(days=7))`| When partitions of the progression level are created, detached and dropped. |
14
14
|`leaves`|`LocalLeaves \| ForeignLeaves`|`LocalLeaves()`| What kind of relation the leaves are. |
15
15
16
16
Flat fields, accepted instead of `scheme` / `lifecycle` for a time-partitioned RANGE root:
@@ -103,7 +103,7 @@ literals.
103
103
|`creation`|`CreateAhead \| CreateUntil \| CreateNextIf`|`CreateAhead(count=6)`| which windows must exist ahead of the cursor |
104
104
|`retention`| any predicate |`KeepNewest(count=12)`| when a window behind the cursor has expired |
0 commit comments