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 2d4ac4c
Browse filesBrowse the repository at this point in the historyBrowse files
|`expire`|`ExpireAction.DETACH` (default), `.TRUNCATE`: empty the expired partition in place and leave it attached; locks the partition only, never the parent; `expire: truncate` in a document |
245
248
|`detach`|`DetachMode.AUTO` (concurrent where PostgreSQL allows), `.CONCURRENT`, `.BLOCKING`|
Copy file name to clipboardExpand all lines: docs/concepts/execution.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,10 +128,11 @@ repository).
128
128
129
129
## Waiting for a lock
130
130
131
-
An attach, a row move and a blocking detach each run under `lock_timeout`
131
+
An attach, a row move, a blocking detach and a truncate each run under `lock_timeout`
132
132
(`ddl_lock_timeout_ms` on the repository, 3000 by default). A statement waiting for a lock
133
133
keeps its place in PostgreSQL's queue, and every session that asks for a conflicting lock
134
-
after it waits behind it; for the locks these steps take, that is every writer of the table.
134
+
after it waits behind it; for the locks the first three take, that is every writer of the
135
+
table, and for a truncate every query that has to lock the partition it empties.
135
136
The move-and-attach holds `EXCLUSIVE` on the parent while it waits for the DEFAULT
136
137
partition, so a reader holding the table for a minute would otherwise stop writes for that
137
138
minute.
@@ -154,6 +155,7 @@ writers and runs without one.
154
155
| the move-and-attach ([DEFAULT reconciliation](#default-reconciliation), step 2) |`EXCLUSIVE` on the parent (one level above `ATTACH`'s own, so no writer is mid-routing), then `ATTACH`'s `ACCESS EXCLUSIVE` on the partition and the DEFAULT sibling — all taken before the move |
155
156
|`DETACH PARTITION` (plain) |`ACCESS EXCLUSIVE` on parent, partition, and every table referencing the parent; the parent is locked first, as a query through it does, so a reader waits rather than deadlocks |
156
157
|`DETACH PARTITION … CONCURRENTLY`|`SHARE UPDATE EXCLUSIVE` on the parent; `ACCESS EXCLUSIVE` on the partition and, in its second transaction, on referencing tables |
158
+
|`TRUNCATE` of an expired partition (`expire=truncate`) |`ACCESS EXCLUSIVE` on the partition and every relation below it; nothing on the parent, so writers to the other partitions do not wait |
157
159
|`DROP TABLE` of a detached table |`ACCESS EXCLUSIVE` on that table only |
158
160
|`COMMENT ON`|`SHARE UPDATE EXCLUSIVE` on the table |
159
161
| the catalog reads (tree, orphans, sizes, estimates) | no relation lock: the tree is walked over `pg_inherits`, not with `pg_partition_tree()`, which would take `ACCESS SHARE` on every member — and omit a partition whose `DETACH CONCURRENTLY` was interrupted |
@@ -189,11 +191,12 @@ one of a small number of states, each of which the next run converges:
189
191
| creating a partition or its subtree | a detached, unmarked table, unreachable by writers | completes the subtree, attaches it |
190
192
| a backfill, between the fill and the attach | a detached, unmarked table holding its window's rows, which DEFAULT no longer has |`plan` reports `unattached_rows`; `backfill` attaches it |
191
193
| a detach | a marked table, attached or pending | finishes the detach (`FINALIZE` if pending), then proceeds |
194
+
| a truncate | the partition with its rows, or empty: it is one transaction | empties it, or finds it empty |
192
195
| a drop | either the table or nothing | drops it, or finds nothing to do |
193
196
194
197
## Hooks
195
198
196
-
Eight hooks fire around create, attach, detach and drop, once per **lifecycle unit** — the partition
199
+
Ten hooks fire around create, attach, detach, truncate and drop, once per **lifecycle unit** — the partition
197
200
under the root, never per leaf of its subtree — and once per member of a root `HASH` or
198
201
`LIST`. A `before_*` hook that raises aborts that operation (the partition comes back on
199
202
the next run); an `after_*` hook that raises is logged and re-raised — the operation has
0 commit comments