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

Commit9eecea7

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 parent8b9e127 commit9eecea7

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
@@ -1323,7 +1323,7 @@ ReorderBufferBuildTupleCidHash(ReorderBuffer *rb, ReorderBufferTXN *txn)
13231323
ent= (ReorderBufferTupleCidEnt*)
13241324
hash_search(txn->tuplecid_hash,
13251325
(void*)&key,
1326-
HASH_ENTER |HASH_FIND,
1326+
HASH_ENTER,
13271327
&found);
13281328
if (!found)
13291329
{

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

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

521521
logicalrep_read_commit(s,&commit_data);
522522

523-
Assert(commit_data.commit_lsn==remote_final_lsn);
523+
if (commit_data.commit_lsn!=remote_final_lsn)
524+
ereport(ERROR,
525+
(errcode(ERRCODE_PROTOCOL_VIOLATION),
526+
errmsg_internal("incorrect commit LSN %X/%X in commit message (expected %X/%X)",
527+
(uint32) (commit_data.commit_lsn >>32),
528+
(uint32)commit_data.commit_lsn,
529+
(uint32) (remote_final_lsn >>32),
530+
(uint32)remote_final_lsn)));
524531

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp