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

Commitfe7bbc4

Browse files
committed
Fix remote position tracking in logical replication
We need to set the origin remote position to end_lsn, not commit_lsn, ascommit_lsn is the start of commit record, and we use the origin remoteposition as start position when restarting replication stream. If we'duse commit_lsn, we could request data that we already received from theremote server after a crash of a downstream server.Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
1 parentb38006e commitfe7bbc4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,6 @@ apply_handle_begin(StringInfo s)
421421

422422
logicalrep_read_begin(s,&begin_data);
423423

424-
replorigin_session_origin_timestamp=begin_data.committime;
425-
replorigin_session_origin_lsn=begin_data.final_lsn;
426-
427424
remote_final_lsn=begin_data.final_lsn;
428425

429426
in_remote_transaction= true;
@@ -443,14 +440,18 @@ apply_handle_commit(StringInfo s)
443440

444441
logicalrep_read_commit(s,&commit_data);
445442

446-
Assert(commit_data.commit_lsn==replorigin_session_origin_lsn);
447-
Assert(commit_data.committime==replorigin_session_origin_timestamp);
448-
449443
Assert(commit_data.commit_lsn==remote_final_lsn);
450444

451445
/* The synchronization worker runs in single transaction. */
452446
if (IsTransactionState()&& !am_tablesync_worker())
453447
{
448+
/*
449+
* Update origin state so we can restart streaming from correct
450+
* position in case of crash.
451+
*/
452+
replorigin_session_origin_lsn=commit_data.end_lsn;
453+
replorigin_session_origin_timestamp=commit_data.committime;
454+
454455
CommitTransactionCommand();
455456

456457
store_flush_position(commit_data.end_lsn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp