Skip to content

Commit 18e8613

Browse files
committed
Address points made in post-commit review of replication origins.
Amit reviewed the replication origins patch and made some good points. Address them. This fixes typos in error messages, docs and comments and adds a missing error check (although in a should-never-happen scenario). Discussion: CAA4eK1JqUBVeWWKwUmBPryFaje4190ug0y-OAUHWQ6tD83V4xg@mail.gmail.com Backpatch: 9.5, where replication origins were introduced.
1 parent d6a8c94 commit 18e8613

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5450,10 +5450,11 @@
54505450
<entry><structfield>local_lsn</structfield></entry>
54515451
<entry><type>pg_lsn</type></entry>
54525452
<entry></entry>
5453-
<entry>This node's LSN that at
5454-
which <literal>remote_lsn</literal> has been replicated. Used to
5455-
flush commit records before persisting data to disk when using
5456-
asynchronous commits.</entry>
5453+
<entry>
5454+
This node's LSN at which <literal>remote_lsn</literal> has
5455+
been replicated. Used to flush commit records before persisting
5456+
data to disk when using asynchronous commits.
5457+
</entry>
54575458
</row>
54585459
</tbody>
54595460
</tgroup>

doc/src/sgml/func.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17441,7 +17441,7 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1744117441
<indexterm>
1744217442
<primary>pg_replication_origin_session_progress</primary>
1744317443
</indexterm>
17444-
<literal><function>pg_replication_origin_progress(<parameter>flush</parameter> <type>bool</type>)</function></literal>
17444+
<literal><function>pg_replication_origin_session_progress(<parameter>flush</parameter> <type>bool</type>)</function></literal>
1744517445
</entry>
1744617446
<entry>
1744717447
pg_lsn

doc/src/sgml/replication-origins.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
Using the replication origin infrastructure a session can be
5858
marked as replaying from a remote node (using the
5959
<link linkend="pg-replication-origin-session-setup"><function>pg_replication_origin_session_setup()</function></link>
60-
function. Additionally the <acronym>LSN</acronym> and commit
60+
function). Additionally the <acronym>LSN</acronym> and commit
6161
timestamp of every source transaction can be configured on a per
6262
transaction basis using
6363
<link linkend="pg-replication-origin-xact-setup"><function>pg_replication_origin_xact_setup()</function></link>.

src/backend/access/transam/xloginsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static XLogRecData *mainrdata_head;
7373
static XLogRecData *mainrdata_last = (XLogRecData *) &mainrdata_head;
7474
static uint32 mainrdata_len; /* total # of bytes in chain */
7575

76-
/* Should te in-progress insertion log the origin */
76+
/* Should the in-progress insertion log the origin? */
7777
static bool include_origin = false;
7878

7979
/*

src/backend/replication/logical/origin.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ replorigin_create(char *roname)
313313
if (tuple == NULL)
314314
ereport(ERROR,
315315
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
316-
errmsg("no free replication oid could be found")));
316+
errmsg("no free replication origin oid could be found")));
317317

318318
heap_freetuple(tuple);
319319
return roident;
@@ -375,6 +375,10 @@ replorigin_drop(RepOriginId roident)
375375
LWLockRelease(ReplicationOriginLock);
376376

377377
tuple = SearchSysCache1(REPLORIGIDENT, ObjectIdGetDatum(roident));
378+
if (!HeapTupleIsValid(tuple))
379+
elog(ERROR, "cache lookup failed for replication origin with oid %u",
380+
roident);
381+
378382
simple_heap_delete(rel, &tuple->t_self);
379383
ReleaseSysCache(tuple);
380384

@@ -437,7 +441,7 @@ ReplicationOriginShmemSize(void)
437441
Size size = 0;
438442

439443
/*
440-
* XXX: max_replication_slots is arguablethe wrong thing to use here, here
444+
* XXX: max_replication_slots is arguably the wrong thing to use, as here
441445
* we keep the replay state of *remote* transactions. But for now it seems
442446
* sufficient to reuse it, lest we introduce a separate guc.
443447
*/
@@ -523,7 +527,7 @@ CheckPointReplicationOrigin(void)
523527
ereport(PANIC,
524528
(errcode_for_file_access(),
525529
errmsg("could not remove file \"%s\": %m",
526-
path)));
530+
tmppath)));
527531

528532
/*
529533
* no other backend can perform this at the same time, we're protected by
@@ -799,12 +803,12 @@ replorigin_redo(XLogReaderState *record)
799803
* Tell the replication origin progress machinery that a commit from 'node'
800804
* that originated at the LSN remote_commit on the remote node was replayed
801805
* successfully and that we don't need to do so again. In combination with
802-
* setting up replorigin_sesssion_origin_lsn and replorigin_sesssion_origin that ensures we
803-
* won't loose knowledge about that after a crash if the transaction had a
804-
* persistent effect (think of asynchronous commits).
806+
* setting up replorigin_sesssion_origin_lsn and replorigin_sesssion_origin
807+
* that ensures we won't loose knowledge about that after a crash if the
808+
* transaction had a persistent effect (think of asynchronous commits).
805809
*
806810
* local_commit needs to be a local LSN of the commit so that we can make sure
807-
* uppon a checkpoint that enough WAL has been persisted to disk.
811+
* upon a checkpoint that enough WAL has been persisted to disk.
808812
*
809813
* Needs to be called with a RowExclusiveLock on pg_replication_origin,
810814
* unless running in recovery.
@@ -1249,7 +1253,6 @@ pg_replication_origin_session_reset(PG_FUNCTION_ARGS)
12491253

12501254
replorigin_session_reset();
12511255

1252-
/* FIXME */
12531256
replorigin_sesssion_origin = InvalidRepOriginId;
12541257
replorigin_sesssion_origin_lsn = InvalidXLogRecPtr;
12551258
replorigin_sesssion_origin_timestamp = 0;

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