Skip to content

Commit 0f404c5

Browse files
Fix assertion failure in snapshot building
Clear any potential stale next_phase_at value from the snapshot builder which otherwise may trip an assertion check ensuring that there is no next_phase_at value. This can be reproduced by running 80 concurrent sessions like the below where $c is a loop counter (assumes there has been 1..$c databases created) : echo " CREATE TABLE replication_example(id SERIAL PRIMARY KEY, somedata int, text varchar(120)); SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot_$c', 'test_decoding'); SELECT data FROM pg_logical_slot_get_changes('regression_slot_$c', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); " | psql -d regress_$c >>psql.log & This was originally committed as 48efb23 and backpatched down to v16, but since then there have been reports of this happening on v14 and v15 as well so this is a backpatch of 48efb23 down to 14. Bug: #17695 Author: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Alexander Lakhin <exclusion@gmail.com> Reported-by: bowenshi <zxwsbg@qq.com> Reported-by: Alexander Pyhalov <a.pyhalov@postgrespro.ru> Reported-by: Teja Mupparti Discussion: https://postgr.es/m/17695-6be9277c9295985f@postgresql.org Backpatch-through: v14
1 parent a144cf1 commit 0f404c5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/replication/logical/snapbuild.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,8 +2028,12 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn)
20282028
if (TransactionIdPrecedes(ondisk.builder.xmin, builder->initial_xmin_horizon))
20292029
goto snapshot_not_interesting;
20302030

2031-
/* consistent snapshots have no next phase */
2031+
/*
2032+
* Consistent snapshots have no next phase. Reset next_phase_at as it is
2033+
* possible that an old value may remain.
2034+
*/
20322035
Assert(ondisk.builder.next_phase_at == InvalidTransactionId);
2036+
builder->next_phase_at = InvalidTransactionId;
20332037

20342038
/* ok, we think the snapshot is sensible, copy over everything important */
20352039
builder->xmin = ondisk.builder.xmin;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy