Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b50558

Browse files
committed
Don't use Asserts to check for violations of replication protocol.
Using an Assert to check the validity of incoming messages is anextremely poor decision. In a debug build, it should not be that easyfor a broken or malicious remote client to crash the logrep worker.The consequences could be even worse in non-debug builds, which willfail to make such checks at all, leading to who-knows-what misbehavior.Hence, promote every Assert that could possibly be triggered by wrongor out-of-order replication messages to a full test-and-ereport.To avoid bloating the set of messages the translation team has to copewith, establish a policy that replication protocol violation errorreports don't need to be translated. Hence, all the new messages hereuse errmsg_internal(). A couple of old messages are changed likewisefor consistency.Along the way, fix some non-idiomatic or outright wrong uses ofhash_search().Most of these mistakes are new with the "streaming replication"patch (commit4648243), but a couple go back a long way.Back-patch as appropriate.Discussion:https://postgr.es/m/1719083.1623351052@sss.pgh.pa.us
1 parent45322bd commit8b50558

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎src/backend/replication/logical/reorderbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ ReorderBufferBuildTupleCidHash(ReorderBuffer *rb, ReorderBufferTXN *txn)
13801380
ent= (ReorderBufferTupleCidEnt*)
13811381
hash_search(txn->tuplecid_hash,
13821382
(void*)&key,
1383-
HASH_ENTER |HASH_FIND,
1383+
HASH_ENTER,
13841384
&found);
13851385
if (!found)
13861386
{

‎src/backend/replication/logical/worker.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,14 @@ apply_handle_commit(StringInfo s)
559559

560560
logicalrep_read_commit(s,&commit_data);
561561

562-
Assert(commit_data.commit_lsn==remote_final_lsn);
562+
if (commit_data.commit_lsn!=remote_final_lsn)
563+
ereport(ERROR,
564+
(errcode(ERRCODE_PROTOCOL_VIOLATION),
565+
errmsg_internal("incorrect commit LSN %X/%X in commit message (expected %X/%X)",
566+
(uint32) (commit_data.commit_lsn >>32),
567+
(uint32)commit_data.commit_lsn,
568+
(uint32) (remote_final_lsn >>32),
569+
(uint32)remote_final_lsn)));
563570

564571
/* The synchronization worker runs in single transaction. */
565572
if (IsTransactionState()&& !am_tablesync_worker())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp