CARVIEW |
Select Language
HTTP/2 200
date: Wed, 16 Jul 2025 16:19:49 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/postgres/postgres.git
etag: W/"7c46dd31e50ed258f084a66a83535283"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=ici%2FXHaXAhNlsp0VXHyeFuq5J8l%2FaBC0tpNpve3xac7iYcrsszxKDw%2F8pKeAuL5kuKjhogLfzy2lQtD8tuiAK5zB9mNG4DguNtfMgcJBtY9EQrkNe1%2FO7v0%2BpQGsfvtY8w19ET0r3EJh1YHZDwrv0e%2F8BcP5xPfJxaFjKoSg1Fv5PZuvLeHybZAY8lVclk44L8ugQ%2B2uIMVhk%2Fz2NRA32XfBBowSrbP9XTkKef89ExwxCDEjSyir1hgmGunwGlIp7qaKSnS84APbTwn2b5MSxA%3D%3D--sAtk79z0YLxK%2Ba%2Fc--xfbStFSVvALcOqbRZB0nCA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1948990185.1752682788; Path=/; Domain=github.com; Expires=Thu, 16 Jul 2026 16:19:48 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 16 Jul 2026 16:19:48 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: CB48:3B9130:3647D:40323:6877D124
Add info in WAL records in preparation for logical slot conflict hand… · postgres/postgres@6af1793 · GitHub
Copy file name to clipboardExpand all lines: src/backend/access/gist/gistxlog.c
Copy file name to clipboardExpand all lines: src/backend/access/hash/hash_xlog.c
Copy file name to clipboardExpand all lines: src/backend/access/hash/hashinsert.c
Copy file name to clipboardExpand all lines: src/backend/access/heap/heapam.c
Copy file name to clipboardExpand all lines: src/backend/access/heap/pruneheap.c
Copy file name to clipboardExpand all lines: src/backend/access/nbtree/nbtpage.c
Copy file name to clipboardExpand all lines: src/backend/access/spgist/spgvacuum.c
Copy file name to clipboardExpand all lines: src/include/access/gistxlog.h
Copy file name to clipboardExpand all lines: src/include/access/hash_xlog.h
Copy file name to clipboardExpand all lines: src/include/access/heapam_xlog.h
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit 6af1793
committed
Add info in WAL records in preparation for logical slot conflict handling
This commit only implements one prerequisite part for allowing logical
decoding. The commit message contains an explanation of the overall design,
which later commits will refer back to.
Overall design:
1. We want to enable logical decoding on standbys, but replay of WAL
from the primary might remove data that is needed by logical decoding,
causing error(s) on the standby. To prevent those errors, a new replication
conflict scenario needs to be addressed (as much as hot standby does).
2. Our chosen strategy for dealing with this type of replication slot
is to invalidate logical slots for which needed data has been removed.
3. To do this we need the latestRemovedXid for each change, just as we
do for physical replication conflicts, but we also need to know
whether any particular change was to data that logical replication
might access. That way, during WAL replay, we know when there is a risk of
conflict and, if so, if there is a conflict.
4. We can't rely on the standby's relcache entries for this purpose in
any way, because the startup process can't access catalog contents.
5. Therefore every WAL record that potentially removes data from the
index or heap must carry a flag indicating whether or not it is one
that might be accessed during logical decoding.
Why do we need this for logical decoding on standby?
First, let's forget about logical decoding on standby and recall that
on a primary database, any catalog rows that may be needed by a logical
decoding replication slot are not removed.
This is done thanks to the catalog_xmin associated with the logical
replication slot.
But, with logical decoding on standby, in the following cases:
- hot_standby_feedback is off
- hot_standby_feedback is on but there is no a physical slot between
the primary and the standby. Then, hot_standby_feedback will work,
but only while the connection is alive (for example a node restart
would break it)
Then, the primary may delete system catalog rows that could be needed
by the logical decoding on the standby (as it does not know about the
catalog_xmin on the standby).
So, it’s mandatory to identify those rows and invalidate the slots
that may need them if any. Identifying those rows is the purpose of
this commit.
Implementation:
When a WAL replay on standby indicates that a catalog table tuple is
to be deleted by an xid that is greater than a logical slot's
catalog_xmin, then that means the slot's catalog_xmin conflicts with
the xid, and we need to handle the conflict. While subsequent commits
will do the actual conflict handling, this commit adds a new field
isCatalogRel in such WAL records (and a new bit set in the
xl_heap_visible flags field), that is true for catalog tables, so as to
arrange for conflict handling.
The affected WAL records are the ones that already contain the
snapshotConflictHorizon field, namely:
- gistxlogDelete
- gistxlogPageReuse
- xl_hash_vacuum_one_page
- xl_heap_prune
- xl_heap_freeze_page
- xl_heap_visible
- xl_btree_reuse_page
- xl_btree_delete
- spgxlogVacuumRedirect
Due to this new field being added, xl_hash_vacuum_one_page and
gistxlogDelete do now contain the offsets to be deleted as a
FLEXIBLE_ARRAY_MEMBER. This is needed to ensure correct alignment.
It's not needed on the others struct where isCatalogRel has
been added.
This commit just introduces the WAL format changes mentioned above. Handling
the actual conflicts will follow in future commits.
Bumps XLOG_PAGE_MAGIC as the several WAL records are changed.
Author: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>
Author: Andres Freund <andres@anarazel.de> (in an older version)
Author: Amit Khandekar <amitdkhan.pg@gmail.com> (in an older version)
Reviewed-by: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>1 parent ab73291 commit 6af1793Copy full SHA for 6af1793
File tree
Expand file treeCollapse file tree
15 files changed
+61
-29
lines changedFilter options
- src
- backend/access
- gist
- hash
- heap
- nbtree
- spgist
- include
- access
- utils
Expand file treeCollapse file tree
15 files changed
+61
-29
lines changedsrc/backend/access/gist/gistxlog.c
Copy file name to clipboardExpand all lines: src/backend/access/gist/gistxlog.c+4-8Lines changed: 4 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
177 | 177 |
| |
178 | 178 |
| |
179 | 179 |
| |
| 180 | + | |
180 | 181 |
| |
181 | 182 |
| |
182 | 183 |
| |
| |||
203 | 204 |
| |
204 | 205 |
| |
205 | 206 |
| |
206 |
| - | |
207 |
| - | |
208 |
| - | |
209 |
| - | |
210 |
| - | |
211 |
| - | |
212 |
| - | |
213 |
| - | |
| 207 | + | |
214 | 208 |
| |
215 | 209 |
| |
216 | 210 |
| |
| |||
609 | 603 |
| |
610 | 604 |
| |
611 | 605 |
| |
| 606 | + | |
612 | 607 |
| |
613 | 608 |
| |
614 | 609 |
| |
| |||
678 | 673 |
| |
679 | 674 |
| |
680 | 675 |
| |
| 676 | + | |
681 | 677 |
| |
682 | 678 |
| |
683 | 679 |
| |
|
src/backend/access/hash/hash_xlog.c
Copy file name to clipboardExpand all lines: src/backend/access/hash/hash_xlog.c+3-8Lines changed: 3 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
980 | 980 |
| |
981 | 981 |
| |
982 | 982 |
| |
| 983 | + | |
983 | 984 |
| |
984 | 985 |
| |
| 986 | + | |
985 | 987 |
| |
986 | 988 |
| |
987 | 989 |
| |
| |||
1010 | 1012 |
| |
1011 | 1013 |
| |
1012 | 1014 |
| |
1013 |
| - | |
1014 |
| - | |
1015 |
| - | |
1016 |
| - | |
1017 |
| - | |
1018 |
| - | |
1019 |
| - | |
1020 |
| - | |
| 1015 | + | |
1021 | 1016 |
| |
1022 | 1017 |
| |
1023 | 1018 |
| |
|
src/backend/access/hash/hashinsert.c
Copy file name to clipboardExpand all lines: src/backend/access/hash/hashinsert.c+1Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
432 | 432 |
| |
433 | 433 |
| |
434 | 434 |
| |
| 435 | + | |
435 | 436 |
| |
436 | 437 |
| |
437 | 438 |
| |
|
src/backend/access/heap/heapam.c
Copy file name to clipboardExpand all lines: src/backend/access/heap/heapam.c+10-1Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6698 | 6698 |
| |
6699 | 6699 |
| |
6700 | 6700 |
| |
| 6701 | + | |
6701 | 6702 |
| |
6702 | 6703 |
| |
6703 | 6704 |
| |
| |||
8280 | 8281 |
| |
8281 | 8282 |
| |
8282 | 8283 |
| |
| 8284 | + | |
| 8285 | + | |
8283 | 8286 |
| |
8284 | 8287 |
| |
8285 | 8288 |
| |
| |||
8870 | 8873 |
| |
8871 | 8874 |
| |
8872 | 8875 |
| |
| 8876 | + | |
| 8877 | + | |
8873 | 8878 |
| |
8874 | 8879 |
| |
8875 | 8880 |
| |
| |||
8956 | 8961 |
| |
8957 | 8962 |
| |
8958 | 8963 |
| |
| 8964 | + | |
8959 | 8965 |
| |
8960 | 8966 |
| |
8961 | 8967 |
| |
8962 | 8968 |
| |
8963 | 8969 |
| |
| 8970 | + | |
| 8971 | + | |
| 8972 | + | |
8964 | 8973 |
| |
8965 | 8974 |
| |
8966 | 8975 |
| |
| |||
8971 | 8980 |
| |
8972 | 8981 |
| |
8973 | 8982 |
| |
8974 |
| - | |
| 8983 | + | |
8975 | 8984 |
| |
8976 | 8985 |
| |
8977 | 8986 |
| |
|
src/backend/access/heap/pruneheap.c
Copy file name to clipboardExpand all lines: src/backend/access/heap/pruneheap.c+1Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
418 | 418 |
| |
419 | 419 |
| |
420 | 420 |
| |
| 421 | + | |
421 | 422 |
| |
422 | 423 |
| |
423 | 424 |
| |
|
src/backend/access/nbtree/nbtpage.c
Copy file name to clipboardExpand all lines: src/backend/access/nbtree/nbtpage.c+2Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
836 | 836 |
| |
837 | 837 |
| |
838 | 838 |
| |
| 839 | + | |
839 | 840 |
| |
840 | 841 |
| |
841 | 842 |
| |
| |||
1358 | 1359 |
| |
1359 | 1360 |
| |
1360 | 1361 |
| |
| 1362 | + | |
1361 | 1363 |
| |
1362 | 1364 |
| |
1363 | 1365 |
| |
|
src/backend/access/spgist/spgvacuum.c
Copy file name to clipboardExpand all lines: src/backend/access/spgist/spgvacuum.c+1Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
503 | 503 |
| |
504 | 504 |
| |
505 | 505 |
| |
| 506 | + | |
506 | 507 |
| |
507 | 508 |
| |
508 | 509 |
| |
|
src/include/access/gistxlog.h
Copy file name to clipboardExpand all lines: src/include/access/gistxlog.h+8-3Lines changed: 8 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
| 54 | + | |
| 55 | + | |
54 | 56 |
| |
55 |
| - | |
| 57 | + | |
| 58 | + | |
56 | 59 |
| |
57 | 60 |
| |
58 |
| - | |
| 61 | + | |
59 | 62 |
| |
60 | 63 |
| |
61 | 64 |
| |
| |||
98 | 101 |
| |
99 | 102 |
| |
100 | 103 |
| |
| 104 | + | |
| 105 | + | |
101 | 106 |
| |
102 | 107 |
| |
103 |
| - | |
| 108 | + | |
104 | 109 |
| |
105 | 110 |
| |
106 | 111 |
| |
|
src/include/access/hash_xlog.h
Copy file name to clipboardExpand all lines: src/include/access/hash_xlog.h+6-4Lines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
251 | 251 |
| |
252 | 252 |
| |
253 | 253 |
| |
254 |
| - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
255 | 257 |
| |
256 |
| - | |
| 258 | + | |
| 259 | + | |
257 | 260 |
| |
258 | 261 |
| |
259 |
| - | |
260 |
| - | |
| 262 | + | |
261 | 263 |
| |
262 | 264 |
| |
263 | 265 |
| |
|
src/include/access/heapam_xlog.h
Copy file name to clipboardExpand all lines: src/include/access/heapam_xlog.h+6-2Lines changed: 6 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
245 | 245 |
| |
246 | 246 |
| |
247 | 247 |
| |
| 248 | + | |
| 249 | + | |
248 | 250 |
| |
249 | 251 |
| |
250 | 252 |
| |
251 |
| - | |
| 253 | + | |
252 | 254 |
| |
253 | 255 |
| |
254 | 256 |
| |
| |||
344 | 346 |
| |
345 | 347 |
| |
346 | 348 |
| |
| 349 | + | |
| 350 | + | |
347 | 351 |
| |
348 | 352 |
| |
349 | 353 |
| |
350 | 354 |
| |
351 | 355 |
| |
352 | 356 |
| |
353 |
| - | |
| 357 | + | |
354 | 358 |
| |
355 | 359 |
| |
356 | 360 |
| |
|
You can’t perform that action at this time.
0 commit comments