- Notifications
You must be signed in to change notification settings - Fork5.2k
Commit27f2044
committed
Revert GetTransactionSnapshot() to return historic snapshot during LR
Commit1585ff7 changed GetTransactionSnapshot() to throw an errorif it's called during logical decoding, instead of returning thehistoric snapshot. I made that change for extra protection, because ahistoric snapshot can only be used to access catalog tables whileGetTransactionSnapshot() is usually called when you're executingarbitrary queries. You might get very subtle visibility problems ifyou tried to use the historic snapshot for arbitrary queries.There's no built-in code in PostgreSQL that callsGetTransactionSnapshot() during logical decoding, but it turns outthat the pglogical extension does just that, to evaluate row filterexpressions. You would get weird results if the row filter runsarbitrary queries, but it is sane as long as you don't access anynon-catalog tables. Even though there are no checks to enforce that inpglogical, a typical row filter expression does not access any tablesand works fine. Accessing tables marked with the user_catalog_table =true option is also OK.To fix pglogical with row filters, and any other extensions that mightdo similar things, revert GetTransactionSnapshot() to return ahistoric snapshot during logical decoding.To try to still catch the unsafe usage of historic snapshots, addchecks in heap_beginscan() and index_beginscan() to complain if youtry to use a historic snapshot to scan a non-catalog table. We're veryclose to the version 18 release however, so add those new checks onlyin master.Backpatch-through: 18Reported-by: Noah Misch <noah@leadboat.com>Reviewed-by: Noah Misch <noah@leadboat.com>Discussion:https://www.postgresql.org/message-id/20250809222338.cc.nmisch@google.com1 parentfc38714 commit27f2044
1 file changed
+15
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | | - | |
276 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
277 | 280 | | |
278 | 281 | | |
279 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
280 | 291 | | |
281 | 292 | | |
282 | 293 | | |
| |||
0 commit comments
Comments
(0)