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

Commit772faaf

Browse files
committed
Revert: Implement pg_wal_replay_wait() stored procedure
This commit reverts06c418e,e37662f,bf1e650,25f4242,ee79928, and74eaf66 per review by Heikki Linnakangas.Discussion:https://postgr.es/m/b155606b-e744-4218-bda5-29379779da1a%40iki.fi
1 parent922c4c4 commit772faaf

File tree

20 files changed

+4
-694
lines changed

20 files changed

+4
-694
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -28770,119 +28770,6 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
2877028770
the pause, the rate of WAL generation and available disk space.
2877128771
</para>
2877228772

28773-
<para>
28774-
There are also procedures to control the progress of recovery.
28775-
They are shown in <xref linkend="procedures-recovery-control-table"/>.
28776-
These procedures may be executed only during recovery.
28777-
</para>
28778-
28779-
<table id="procedures-recovery-control-table">
28780-
<title>Recovery Control Procedures</title>
28781-
<tgroup cols="1">
28782-
<thead>
28783-
<row>
28784-
<entry role="func_table_entry"><para role="func_signature">
28785-
Procedure
28786-
</para>
28787-
<para>
28788-
Description
28789-
</para></entry>
28790-
</row>
28791-
</thead>
28792-
28793-
<tbody>
28794-
<row>
28795-
<entry role="func_table_entry"><para role="func_signature">
28796-
<indexterm>
28797-
<primary>pg_wal_replay_wait</primary>
28798-
</indexterm>
28799-
<function>pg_wal_replay_wait</function> (
28800-
<parameter>target_lsn</parameter> <type>pg_lsn</type>,
28801-
<parameter>timeout</parameter> <type>bigint</type> <literal>DEFAULT</literal> <literal>0</literal>)
28802-
<returnvalue>void</returnvalue>
28803-
</para>
28804-
<para>
28805-
If <parameter>timeout</parameter> is not specified or zero, this
28806-
procedure returns once WAL is replayed upto
28807-
<literal>target_lsn</literal>.
28808-
If the <parameter>timeout</parameter> is specified (in
28809-
milliseconds) and greater than zero, the procedure waits until the
28810-
server actually replays the WAL upto <literal>target_lsn</literal> or
28811-
until the given time has passed. On timeout, an error is emitted.
28812-
</para></entry>
28813-
</row>
28814-
</tbody>
28815-
</tgroup>
28816-
</table>
28817-
28818-
<para>
28819-
<function>pg_wal_replay_wait</function> waits till
28820-
<parameter>target_lsn</parameter> to be replayed on standby.
28821-
That is, after this function execution, the value returned by
28822-
<function>pg_last_wal_replay_lsn</function> should be greater or equal
28823-
to the <parameter>target_lsn</parameter> value. This is useful to achieve
28824-
read-your-writes-consistency, while using async replica for reads and
28825-
primary for writes. In that case <acronym>lsn</acronym> of the last
28826-
modification should be stored on the client application side or the
28827-
connection pooler side.
28828-
</para>
28829-
28830-
<para>
28831-
You can use <function>pg_wal_replay_wait</function> to wait for
28832-
the <type>pg_lsn</type> value. For example, an application could update
28833-
the <literal>movie</literal> table and get the <acronym>lsn</acronym> after
28834-
changes just made. This example uses <function>pg_current_wal_insert_lsn</function>
28835-
on primary server to get the <acronym>lsn</acronym> given that
28836-
<varname>synchronous_commit</varname> could be set to
28837-
<literal>off</literal>.
28838-
28839-
<programlisting>
28840-
postgres=# UPDATE movie SET genre = 'Dramatic' WHERE genre = 'Drama';
28841-
UPDATE 100
28842-
postgres=# SELECT pg_current_wal_insert_lsn();
28843-
pg_current_wal_insert_lsn
28844-
--------------------
28845-
0/306EE20
28846-
(1 row)
28847-
</programlisting>
28848-
28849-
Then an application could run <function>pg_wal_replay_wait</function>
28850-
with the <acronym>lsn</acronym> obtained from primary. After that the
28851-
changes made of primary should be guaranteed to be visible on replica.
28852-
28853-
<programlisting>
28854-
postgres=# CALL pg_wal_replay_wait('0/306EE20');
28855-
CALL
28856-
postgres=# SELECT * FROM movie WHERE genre = 'Drama';
28857-
genre
28858-
-------
28859-
(0 rows)
28860-
</programlisting>
28861-
28862-
It may also happen that target <acronym>lsn</acronym> is not achieved
28863-
within the timeout. In that case the error is thrown.
28864-
28865-
<programlisting>
28866-
postgres=# CALL pg_wal_replay_wait('0/306EE20', 100);
28867-
ERROR: timed out while waiting for target LSN 0/306EE20 to be replayed; current replay LSN 0/306EA60
28868-
</programlisting>
28869-
28870-
</para>
28871-
28872-
<para>
28873-
<function>pg_wal_replay_wait</function> can't be used within
28874-
the transaction, another procedure or function. Any of them holds a
28875-
snapshot, which could prevent the replay of WAL records.
28876-
28877-
<programlisting>
28878-
postgres=# BEGIN;
28879-
BEGIN
28880-
postgres=*# CALL pg_wal_replay_wait('0/306EE20');
28881-
ERROR: pg_wal_replay_wait() must be only called in non-atomic context
28882-
DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction, another procedure, or a function.
28883-
</programlisting>
28884-
28885-
</para>
2888628773
</sect2>
2888728774

2888828775
<sect2 id="functions-snapshot-synchronization">

‎src/backend/access/transam/xact.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include"commands/async.h"
3939
#include"commands/tablecmds.h"
4040
#include"commands/trigger.h"
41-
#include"commands/waitlsn.h"
4241
#include"common/pg_prng.h"
4342
#include"executor/spi.h"
4443
#include"libpq/be-fsstubs.h"
@@ -2772,11 +2771,6 @@ AbortTransaction(void)
27722771
*/
27732772
LWLockReleaseAll();
27742773

2775-
/*
2776-
* Cleanup waiting for LSN if any.
2777-
*/
2778-
WaitLSNCleanup();
2779-
27802774
/* Clear wait information and command progress indicator */
27812775
pgstat_report_wait_end();
27822776
pgstat_progress_end_command();

‎src/backend/access/transam/xlog.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
#include"catalog/catversion.h"
6767
#include"catalog/pg_control.h"
6868
#include"catalog/pg_database.h"
69-
#include"commands/waitlsn.h"
7069
#include"common/controldata_utils.h"
7170
#include"common/file_utils.h"
7271
#include"executor/instrument.h"
@@ -6130,12 +6129,6 @@ StartupXLOG(void)
61306129
UpdateControlFile();
61316130
LWLockRelease(ControlFileLock);
61326131

6133-
/*
6134-
* Wake up all waiters for replay LSN. They need to report an error that
6135-
* recovery was ended before achieving the target LSN.
6136-
*/
6137-
WaitLSNSetLatches(InvalidXLogRecPtr);
6138-
61396132
/*
61406133
* Shutdown the recovery environment. This must occur after
61416134
* RecoverPreparedTransactions() (see notes in lock_twophase_recover())

‎src/backend/access/transam/xlogrecovery.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include"backup/basebackup.h"
4444
#include"catalog/pg_control.h"
4545
#include"commands/tablespace.h"
46-
#include"commands/waitlsn.h"
4746
#include"common/file_utils.h"
4847
#include"miscadmin.h"
4948
#include"pgstat.h"
@@ -1829,16 +1828,6 @@ PerformWalRecovery(void)
18291828
break;
18301829
}
18311830

1832-
/*
1833-
* If we replayed an LSN that someone was waiting for then walk
1834-
* over the shared memory array and set latches to notify the
1835-
* waiters.
1836-
*/
1837-
if (waitLSN&&
1838-
(XLogRecoveryCtl->lastReplayedEndRecPtr >=
1839-
pg_atomic_read_u64(&waitLSN->minWaitedLSN)))
1840-
WaitLSNSetLatches(XLogRecoveryCtl->lastReplayedEndRecPtr);
1841-
18421831
/* Else, try to fetch the next WAL record */
18431832
record=ReadRecord(xlogprefetcher,LOG, false,replayTLI);
18441833
}while (record!=NULL);

‎src/backend/catalog/system_functions.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,6 @@ CREATE OR REPLACE FUNCTION
414414
json_populate_recordset(base anyelement, from_json json, use_json_as_textboolean DEFAULT false)
415415
RETURNS SETOF anyelement LANGUAGE internal STABLE ROWS100AS'json_populate_recordset' PARALLEL SAFE;
416416

417-
CREATEOR REPLACE PROCEDURE pg_wal_replay_wait(target_lsn pg_lsn, timeout int8 DEFAULT0)
418-
LANGUAGE internalAS'pg_wal_replay_wait';
419-
420417
CREATE OR REPLACEFUNCTIONpg_logical_slot_get_changes(
421418
IN slot_name name,IN upto_lsn pg_lsn,IN upto_nchangesint, VARIADIC optionstext[] DEFAULT'{}',
422419
OUT lsn pg_lsn, OUT xid xid, OUT datatext)

‎src/backend/commands/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ OBJS = \
6161
vacuum.o\
6262
vacuumparallel.o\
6363
variable.o\
64-
view.o\
65-
waitlsn.o
64+
view.o
6665

6766
include$(top_srcdir)/src/backend/common.mk

‎src/backend/commands/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,4 @@ backend_sources += files(
5050
'vacuumparallel.c',
5151
'variable.c',
5252
'view.c',
53-
'waitlsn.c',
5453
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp