Rename WAL-related functions and views to use "lsn" not "location".
Per discussion, "location" is a rather vague term that could refer to multiple concepts. "LSN" is an unambiguous term for WAL locations and should be preferred. Some function names, view column names, and function output argument names used "lsn" already, but others used "location", as well as yet other terms such as "wal_position". Since we've already renamed a lot of things in this area from "xlog" to "wal" for v10, we may as well incur a bit more compatibility pain and make these names all consistent. David Rowley, minor additional docs hacking by me Discussion: https://postgr.es/m/CAKJS1f8O0njDKe8ePFQ-LK5-EjwThsDws6ohJ-+c6nWK+oUxtg@mail.gmail.com
This commit is contained in:
parent
b66adb7b0c
commit
d10c626de4
@ -16,7 +16,7 @@ sub test_index_replay
|
||||
# Wait for standby to catch up
|
||||
my $applname = $node_standby->name;
|
||||
my $caughtup_query =
|
||||
"SELECT pg_current_wal_location() <= write_location FROM pg_stat_replication WHERE application_name = '$applname';";
|
||||
"SELECT pg_current_wal_lsn() <= write_lsn FROM pg_stat_replication WHERE application_name = '$applname';";
|
||||
$node_master->poll_query_until('postgres', $caughtup_query)
|
||||
or die "Timed out while waiting for standby 1 to catch up";
|
||||
|
||||
|
@ -58,7 +58,7 @@ SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_d
|
||||
SELECT slot_name, plugin, slot_type, active,
|
||||
NOT catalog_xmin IS NULL AS catalog_xmin_set,
|
||||
xmin IS NULl AS data_xmin_not_set,
|
||||
pg_wal_location_diff(restart_lsn, '0/01000000') > 0 AS some_wal
|
||||
pg_wal_lsn_diff(restart_lsn, '0/01000000') > 0 AS some_wal
|
||||
FROM pg_replication_slots;
|
||||
slot_name | plugin | slot_type | active | catalog_xmin_set | data_xmin_not_set | some_wal
|
||||
-----------------+---------------+-----------+--------+------------------+-------------------+----------
|
||||
|
@ -29,7 +29,7 @@ SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_d
|
||||
SELECT slot_name, plugin, slot_type, active,
|
||||
NOT catalog_xmin IS NULL AS catalog_xmin_set,
|
||||
xmin IS NULl AS data_xmin_not_set,
|
||||
pg_wal_location_diff(restart_lsn, '0/01000000') > 0 AS some_wal
|
||||
pg_wal_lsn_diff(restart_lsn, '0/01000000') > 0 AS some_wal
|
||||
FROM pg_replication_slots;
|
||||
|
||||
/*
|
||||
|
@ -17908,17 +17908,17 @@ SELECT collation for ('foo' COLLATE "de_DE");
|
||||
<tbody>
|
||||
|
||||
<row>
|
||||
<entry><literal>checkpoint_location</literal></entry>
|
||||
<entry><literal>checkpoint_lsn</literal></entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal>prior_location</literal></entry>
|
||||
<entry><literal>prior_lsn</literal></entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal>redo_location</literal></entry>
|
||||
<entry><literal>redo_lsn</literal></entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
</row>
|
||||
|
||||
@ -18146,7 +18146,7 @@ SELECT collation for ('foo' COLLATE "de_DE");
|
||||
<tbody>
|
||||
|
||||
<row>
|
||||
<entry><literal>min_recovery_end_location</literal></entry>
|
||||
<entry><literal>min_recovery_end_lsn</literal></entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
</row>
|
||||
|
||||
@ -18156,12 +18156,12 @@ SELECT collation for ('foo' COLLATE "de_DE");
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal>backup_start_location</literal></entry>
|
||||
<entry><literal>backup_start_lsn</literal></entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal>backup_end_location</literal></entry>
|
||||
<entry><literal>backup_end_lsn</literal></entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
</row>
|
||||
|
||||
@ -18404,13 +18404,13 @@ SELECT set_config('log_statement_stats', 'off', false);
|
||||
<primary>pg_create_restore_point</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_current_wal_flush_location</primary>
|
||||
<primary>pg_current_wal_flush_lsn</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_current_wal_insert_location</primary>
|
||||
<primary>pg_current_wal_insert_lsn</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_current_wal_location</primary>
|
||||
<primary>pg_current_wal_lsn</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_start_backup</primary>
|
||||
@ -18434,7 +18434,7 @@ SELECT set_config('log_statement_stats', 'off', false);
|
||||
<primary>pg_walfile_name_offset</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_wal_location_diff</primary>
|
||||
<primary>pg_wal_lsn_diff</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
@ -18442,7 +18442,7 @@ SELECT set_config('log_statement_stats', 'off', false);
|
||||
linkend="functions-admin-backup-table"> assist in making on-line backups.
|
||||
These functions cannot be executed during recovery (except
|
||||
<function>pg_is_in_backup</function>, <function>pg_backup_start_time</function>
|
||||
and <function>pg_wal_location_diff</function>).
|
||||
and <function>pg_wal_lsn_diff</function>).
|
||||
</para>
|
||||
|
||||
<table id="functions-admin-backup-table">
|
||||
@ -18463,21 +18463,21 @@ SELECT set_config('log_statement_stats', 'off', false);
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_current_wal_flush_location()</function></literal>
|
||||
<literal><function>pg_current_wal_flush_lsn()</function></literal>
|
||||
</entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
<entry>Get current transaction log flush location</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_current_wal_insert_location()</function></literal>
|
||||
<literal><function>pg_current_wal_insert_lsn()</function></literal>
|
||||
</entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
<entry>Get current transaction log insert location</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_current_wal_location()</function></literal>
|
||||
<literal><function>pg_current_wal_lsn()</function></literal>
|
||||
</entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
<entry>Get current transaction log write location</entry>
|
||||
@ -18526,21 +18526,21 @@ SELECT set_config('log_statement_stats', 'off', false);
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_walfile_name(<parameter>location</> <type>pg_lsn</>)</function></literal>
|
||||
<literal><function>pg_walfile_name(<parameter>lsn</> <type>pg_lsn</>)</function></literal>
|
||||
</entry>
|
||||
<entry><type>text</type></entry>
|
||||
<entry>Convert transaction log location string to file name</entry>
|
||||
<entry>Convert transaction log location to file name</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_walfile_name_offset(<parameter>location</> <type>pg_lsn</>)</function></literal>
|
||||
<literal><function>pg_walfile_name_offset(<parameter>lsn</> <type>pg_lsn</>)</function></literal>
|
||||
</entry>
|
||||
<entry><type>text</>, <type>integer</></entry>
|
||||
<entry>Convert transaction log location string to file name and decimal byte offset within file</entry>
|
||||
<entry>Convert transaction log location to file name and decimal byte offset within file</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_wal_location_diff(<parameter>location</> <type>pg_lsn</>, <parameter>location</> <type>pg_lsn</>)</function></literal>
|
||||
<literal><function>pg_wal_lsn_diff(<parameter>lsn</> <type>pg_lsn</>, <parameter>lsn</> <type>pg_lsn</>)</function></literal>
|
||||
</entry>
|
||||
<entry><type>numeric</></entry>
|
||||
<entry>Calculate the difference between two transaction log locations</entry>
|
||||
@ -18623,17 +18623,17 @@ postgres=# select pg_start_backup('label_goes_here');
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<function>pg_current_wal_location</> displays the current transaction log write
|
||||
<function>pg_current_wal_lsn</> displays the current transaction log write
|
||||
location in the same format used by the above functions. Similarly,
|
||||
<function>pg_current_wal_insert_location</> displays the current transaction log
|
||||
insertion point and <function>pg_current_wal_flush_location</> displays the
|
||||
current transaction log flush point. The insertion point is the <quote>logical</>
|
||||
<function>pg_current_wal_insert_lsn</> displays the current transaction log
|
||||
insertion location and <function>pg_current_wal_flush_lsn</> displays the
|
||||
current transaction log flush location. The insertion location is the <quote>logical</>
|
||||
end of the transaction log at any instant, while the write location is the end of
|
||||
what has actually been written out from the server's internal buffers and flush
|
||||
location is the location guaranteed to be written to durable storage. The write
|
||||
location is the end of what can be examined from outside the server, and is usually
|
||||
what you want if you are interested in archiving partially-complete transaction log
|
||||
files. The insertion and flush points are made available primarily for server
|
||||
files. The insertion and flush locations are made available primarily for server
|
||||
debugging purposes. These are both read-only operations and do not
|
||||
require superuser permissions.
|
||||
</para>
|
||||
@ -18658,7 +18658,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<function>pg_wal_location_diff</> calculates the difference in bytes
|
||||
<function>pg_wal_lsn_diff</> calculates the difference in bytes
|
||||
between two transaction log locations. It can be used with
|
||||
<structname>pg_stat_replication</structname> or some functions shown in
|
||||
<xref linkend="functions-admin-backup-table"> to get the replication lag.
|
||||
@ -18678,10 +18678,10 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<primary>pg_is_in_recovery</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_last_wal_receive_location</primary>
|
||||
<primary>pg_last_wal_receive_lsn</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_last_wal_replay_location</primary>
|
||||
<primary>pg_last_wal_replay_lsn</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_last_xact_replay_timestamp</primary>
|
||||
@ -18713,7 +18713,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_last_wal_receive_location()</function></literal>
|
||||
<literal><function>pg_last_wal_receive_lsn()</function></literal>
|
||||
</entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
<entry>Get last transaction log location received and synced to disk by
|
||||
@ -18727,7 +18727,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_last_wal_replay_location()</function></literal>
|
||||
<literal><function>pg_last_wal_replay_lsn()</function></literal>
|
||||
</entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
<entry>Get last transaction log location replayed during recovery.
|
||||
@ -18950,7 +18950,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<literal><function>pg_create_physical_replication_slot(<parameter>slot_name</parameter> <type>name</type> <optional>, <parameter>immediately_reserve</> <type>boolean</>, <parameter>temporary</> <type>boolean</></optional>)</function></literal>
|
||||
</entry>
|
||||
<entry>
|
||||
(<parameter>slot_name</parameter> <type>name</type>, <parameter>wal_position</parameter> <type>pg_lsn</type>)
|
||||
(<parameter>slot_name</parameter> <type>name</type>, <parameter>lsn</parameter> <type>pg_lsn</type>)
|
||||
</entry>
|
||||
<entry>
|
||||
Creates a new physical replication slot named
|
||||
@ -18995,7 +18995,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<literal><function>pg_create_logical_replication_slot(<parameter>slot_name</parameter> <type>name</type>, <parameter>plugin</parameter> <type>name</type> <optional>, <parameter>temporary</> <type>boolean</></optional>)</function></literal>
|
||||
</entry>
|
||||
<entry>
|
||||
(<parameter>slot_name</parameter> <type>name</type>, <parameter>wal_position</parameter> <type>pg_lsn</type>)
|
||||
(<parameter>slot_name</parameter> <type>name</type>, <parameter>lsn</parameter> <type>pg_lsn</type>)
|
||||
</entry>
|
||||
<entry>
|
||||
Creates a new logical (decoding) replication slot named
|
||||
@ -19018,7 +19018,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<literal><function>pg_logical_slot_get_changes(<parameter>slot_name</parameter> <type>name</type>, <parameter>upto_lsn</parameter> <type>pg_lsn</type>, <parameter>upto_nchanges</parameter> <type>int</type>, VARIADIC <parameter>options</parameter> <type>text[]</type>)</function></literal>
|
||||
</entry>
|
||||
<entry>
|
||||
(<parameter>location</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>text</type>)
|
||||
(<parameter>lsn</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>text</type>)
|
||||
</entry>
|
||||
<entry>
|
||||
Returns changes in the slot <parameter>slot_name</parameter>, starting
|
||||
@ -19043,7 +19043,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<literal><function>pg_logical_slot_peek_changes(<parameter>slot_name</parameter> <type>name</type>, <parameter>upto_lsn</parameter> <type>pg_lsn</type>, <parameter>upto_nchanges</parameter> <type>int</type>, VARIADIC <parameter>options</parameter> <type>text[]</type>)</function></literal>
|
||||
</entry>
|
||||
<entry>
|
||||
(<parameter>location</parameter> <type>text</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>text</type>)
|
||||
(<parameter>lsn</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>text</type>)
|
||||
</entry>
|
||||
<entry>
|
||||
Behaves just like
|
||||
@ -19061,7 +19061,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<literal><function>pg_logical_slot_get_binary_changes(<parameter>slot_name</parameter> <type>name</type>, <parameter>upto_lsn</parameter> <type>pg_lsn</type>, <parameter>upto_nchanges</parameter> <type>int</type>, VARIADIC <parameter>options</parameter> <type>text[]</type>)</function></literal>
|
||||
</entry>
|
||||
<entry>
|
||||
(<parameter>location</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>bytea</type>)
|
||||
(<parameter>lsn</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>bytea</type>)
|
||||
</entry>
|
||||
<entry>
|
||||
Behaves just like
|
||||
@ -19078,7 +19078,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<literal><function>pg_logical_slot_peek_binary_changes(<parameter>slot_name</parameter> <type>name</type>, <parameter>upto_lsn</parameter> <type>pg_lsn</type>, <parameter>upto_nchanges</parameter> <type>int</type>, VARIADIC <parameter>options</parameter> <type>text[]</type>)</function></literal>
|
||||
</entry>
|
||||
<entry>
|
||||
(<parameter>location</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>bytea</type>)
|
||||
(<parameter>lsn</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>bytea</type>)
|
||||
</entry>
|
||||
<entry>
|
||||
Behaves just like
|
||||
@ -19197,7 +19197,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<type>pg_lsn</type>
|
||||
</entry>
|
||||
<entry>
|
||||
Return the replay position for the replication origin configured in
|
||||
Return the replay location for the replication origin configured in
|
||||
the current session. The parameter <parameter>flush</parameter>
|
||||
determines whether the corresponding local transaction will be
|
||||
guaranteed to have been flushed to disk or not.
|
||||
@ -19244,15 +19244,15 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<indexterm>
|
||||
<primary>pg_replication_origin_advance</primary>
|
||||
</indexterm>
|
||||
<literal>pg_replication_origin_advance<function>(<parameter>node_name</parameter> <type>text</type>, <parameter>pos</parameter> <type>pg_lsn</type>)</function></literal>
|
||||
<literal>pg_replication_origin_advance<function>(<parameter>node_name</parameter> <type>text</type>, <parameter>lsn</parameter> <type>pg_lsn</type>)</function></literal>
|
||||
</entry>
|
||||
<entry>
|
||||
<type>void</>
|
||||
</entry>
|
||||
<entry>
|
||||
Set replication progress for the given node to the given
|
||||
position. This primarily is useful for setting up the initial position
|
||||
or a new position after configuration changes and similar. Be aware
|
||||
location. This primarily is useful for setting up the initial location
|
||||
or a new location after configuration changes and similar. Be aware
|
||||
that careless use of this function can lead to inconsistently
|
||||
replicated data.
|
||||
</entry>
|
||||
@ -19269,7 +19269,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<type>pg_lsn</type>
|
||||
</entry>
|
||||
<entry>
|
||||
Return the replay position for the given replication origin. The
|
||||
Return the replay location for the given replication origin. The
|
||||
parameter <parameter>flush</parameter> determines whether the
|
||||
corresponding local transaction will be guaranteed to have been
|
||||
flushed to disk or not.
|
||||
|
@ -850,9 +850,9 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
|
||||
of WAL records generated in the primary, but not yet applied in the
|
||||
standby. You can calculate this lag by comparing the current WAL write
|
||||
location on the primary with the last WAL location received by the
|
||||
standby. They can be retrieved using
|
||||
<function>pg_current_wal_location</> on the primary and the
|
||||
<function>pg_last_wal_receive_location</> on the standby,
|
||||
standby. These locations can be retrieved using
|
||||
<function>pg_current_wal_lsn</> on the primary and
|
||||
<function>pg_last_wal_receive_lsn</> on the standby,
|
||||
respectively (see <xref linkend="functions-admin-backup-table"> and
|
||||
<xref linkend="functions-recovery-info-table"> for details).
|
||||
The last WAL receive location in the standby is also displayed in the
|
||||
@ -863,10 +863,10 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
|
||||
You can retrieve a list of WAL sender processes via the
|
||||
<link linkend="monitoring-stats-views-table">
|
||||
<literal>pg_stat_replication</></link> view. Large differences between
|
||||
<function>pg_current_wal_location</> and <literal>sent_location</> field
|
||||
<function>pg_current_wal_lsn</> and the view's <literal>sent_lsn</> field
|
||||
might indicate that the master server is under heavy load, while
|
||||
differences between <literal>sent_location</> and
|
||||
<function>pg_last_wal_receive_location</> on the standby might indicate
|
||||
differences between <literal>sent_lsn</> and
|
||||
<function>pg_last_wal_receive_lsn</> on the standby might indicate
|
||||
network delay, or that the standby is under heavy load.
|
||||
</para>
|
||||
</sect3>
|
||||
@ -927,8 +927,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
|
||||
You can create a replication slot like this:
|
||||
<programlisting>
|
||||
postgres=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
|
||||
slot_name | wal_position
|
||||
-------------+---------------
|
||||
slot_name | lsn
|
||||
-------------+-----
|
||||
node_a_slot |
|
||||
|
||||
postgres=# SELECT * FROM pg_replication_slots;
|
||||
|
@ -56,8 +56,8 @@
|
||||
<programlisting>
|
||||
postgres=# -- Create a slot named 'regression_slot' using the output plugin 'test_decoding'
|
||||
postgres=# SELECT * FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
||||
slot_name | wal_position
|
||||
-----------------+---------------
|
||||
slot_name | lsn
|
||||
-----------------+-----------
|
||||
regression_slot | 0/16B1970
|
||||
(1 row)
|
||||
|
||||
@ -69,8 +69,8 @@ postgres=# SELECT slot_name, plugin, slot_type, database, active, restart_lsn, c
|
||||
|
||||
postgres=# -- There are no changes to see yet
|
||||
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
|
||||
location | xid | data
|
||||
----------+-----+------
|
||||
lsn | xid | data
|
||||
-----+-----+------
|
||||
(0 rows)
|
||||
|
||||
postgres=# CREATE TABLE data(id serial primary key, data text);
|
||||
@ -78,17 +78,17 @@ CREATE TABLE
|
||||
|
||||
postgres=# -- DDL isn't replicated, so all you'll see is the transaction
|
||||
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
|
||||
location | xid | data
|
||||
-----------+-----+------------
|
||||
0/16D5D48 | 688 | BEGIN 688
|
||||
0/16E0380 | 688 | COMMIT 688
|
||||
lsn | xid | data
|
||||
-----------+-------+--------------
|
||||
0/BA2DA58 | 10297 | BEGIN 10297
|
||||
0/BA5A5A0 | 10297 | COMMIT 10297
|
||||
(2 rows)
|
||||
|
||||
postgres=# -- Once changes are read, they're consumed and not emitted
|
||||
postgres=# -- in a subsequent call:
|
||||
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
|
||||
location | xid | data
|
||||
----------+-----+------
|
||||
lsn | xid | data
|
||||
-----+-----+------
|
||||
(0 rows)
|
||||
|
||||
postgres=# BEGIN;
|
||||
@ -97,41 +97,41 @@ postgres=# INSERT INTO data(data) VALUES('2');
|
||||
postgres=# COMMIT;
|
||||
|
||||
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
|
||||
location | xid | data
|
||||
-----------+-----+-----------------------------------------------
|
||||
0/16E0478 | 689 | BEGIN 689
|
||||
0/16E0478 | 689 | table public.data: INSERT: id[integer]:1 data[text]:'1'
|
||||
0/16E0580 | 689 | table public.data: INSERT: id[integer]:2 data[text]:'2'
|
||||
0/16E0650 | 689 | COMMIT 689
|
||||
lsn | xid | data
|
||||
-----------+-------+---------------------------------------------------------
|
||||
0/BA5A688 | 10298 | BEGIN 10298
|
||||
0/BA5A6F0 | 10298 | table public.data: INSERT: id[integer]:1 data[text]:'1'
|
||||
0/BA5A7F8 | 10298 | table public.data: INSERT: id[integer]:2 data[text]:'2'
|
||||
0/BA5A8A8 | 10298 | COMMIT 10298
|
||||
(4 rows)
|
||||
|
||||
postgres=# INSERT INTO data(data) VALUES('3');
|
||||
|
||||
postgres=# -- You can also peek ahead in the change stream without consuming changes
|
||||
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL);
|
||||
location | xid | data
|
||||
-----------+-----+-----------------------------------------------
|
||||
0/16E09C0 | 690 | BEGIN 690
|
||||
0/16E09C0 | 690 | table public.data: INSERT: id[integer]:3 data[text]:'3'
|
||||
0/16E0B90 | 690 | COMMIT 690
|
||||
lsn | xid | data
|
||||
-----------+-------+---------------------------------------------------------
|
||||
0/BA5A8E0 | 10299 | BEGIN 10299
|
||||
0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3'
|
||||
0/BA5A990 | 10299 | COMMIT 10299
|
||||
(3 rows)
|
||||
|
||||
postgres=# -- The next call to pg_logical_slot_peek_changes() returns the same changes again
|
||||
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL);
|
||||
location | xid | data
|
||||
-----------+-----+-----------------------------------------------
|
||||
0/16E09C0 | 690 | BEGIN 690
|
||||
0/16E09C0 | 690 | table public.data: INSERT: id[integer]:3 data[text]:'3'
|
||||
0/16E0B90 | 690 | COMMIT 690
|
||||
lsn | xid | data
|
||||
-----------+-------+---------------------------------------------------------
|
||||
0/BA5A8E0 | 10299 | BEGIN 10299
|
||||
0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3'
|
||||
0/BA5A990 | 10299 | COMMIT 10299
|
||||
(3 rows)
|
||||
|
||||
postgres=# -- options can be passed to output plugin, to influence the formatting
|
||||
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-timestamp', 'on');
|
||||
location | xid | data
|
||||
-----------+-----+-----------------------------------------------
|
||||
0/16E09C0 | 690 | BEGIN 690
|
||||
0/16E09C0 | 690 | table public.data: INSERT: id[integer]:3 data[text]:'3'
|
||||
0/16E0B90 | 690 | COMMIT 690 (at 2014-02-27 16:41:51.863092+01)
|
||||
lsn | xid | data
|
||||
-----------+-------+---------------------------------------------------------
|
||||
0/BA5A8E0 | 10299 | BEGIN 10299
|
||||
0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3'
|
||||
0/BA5A990 | 10299 | COMMIT 10299 (at 2017-05-10 12:07:21.272494-04)
|
||||
(3 rows)
|
||||
|
||||
postgres=# -- Remember to destroy a slot you no longer need to stop it consuming
|
||||
|
@ -1699,26 +1699,26 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><structfield>sent_location</></entry>
|
||||
<entry><structfield>sent_lsn</></entry>
|
||||
<entry><type>pg_lsn</></entry>
|
||||
<entry>Last transaction log position sent on this connection</entry>
|
||||
<entry>Last transaction log location sent on this connection</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><structfield>write_location</></entry>
|
||||
<entry><structfield>write_lsn</></entry>
|
||||
<entry><type>pg_lsn</></entry>
|
||||
<entry>Last transaction log position written to disk by this standby
|
||||
<entry>Last transaction log location written to disk by this standby
|
||||
server</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><structfield>flush_location</></entry>
|
||||
<entry><structfield>flush_lsn</></entry>
|
||||
<entry><type>pg_lsn</></entry>
|
||||
<entry>Last transaction log position flushed to disk by this standby
|
||||
<entry>Last transaction log location flushed to disk by this standby
|
||||
server</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><structfield>replay_location</></entry>
|
||||
<entry><structfield>replay_lsn</></entry>
|
||||
<entry><type>pg_lsn</></entry>
|
||||
<entry>Last transaction log position replayed into the database on this
|
||||
<entry>Last transaction log location replayed into the database on this
|
||||
standby server</entry>
|
||||
</row>
|
||||
<row>
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
<programlisting>
|
||||
postgres=# SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'include-xids', '0');
|
||||
location | xid | data
|
||||
lsn | xid | data
|
||||
-----------+-----+--------------------------------------------------
|
||||
0/16D30F8 | 691 | BEGIN
|
||||
0/16D32A0 | 691 | table public.data: INSERT: id[int4]:2 data[text]:'arg'
|
||||
|
@ -351,7 +351,7 @@ pg_create_restore_point(PG_FUNCTION_ARGS)
|
||||
* to the kernel, but is not necessarily synced to disk.
|
||||
*/
|
||||
Datum
|
||||
pg_current_wal_location(PG_FUNCTION_ARGS)
|
||||
pg_current_wal_lsn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
XLogRecPtr current_recptr;
|
||||
|
||||
@ -372,7 +372,7 @@ pg_current_wal_location(PG_FUNCTION_ARGS)
|
||||
* This function is mostly for debugging purposes.
|
||||
*/
|
||||
Datum
|
||||
pg_current_wal_insert_location(PG_FUNCTION_ARGS)
|
||||
pg_current_wal_insert_lsn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
XLogRecPtr current_recptr;
|
||||
|
||||
@ -393,7 +393,7 @@ pg_current_wal_insert_location(PG_FUNCTION_ARGS)
|
||||
* This function is mostly for debugging purposes.
|
||||
*/
|
||||
Datum
|
||||
pg_current_wal_flush_location(PG_FUNCTION_ARGS)
|
||||
pg_current_wal_flush_lsn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
XLogRecPtr current_recptr;
|
||||
|
||||
@ -415,7 +415,7 @@ pg_current_wal_flush_location(PG_FUNCTION_ARGS)
|
||||
* and synced to disk by walreceiver.
|
||||
*/
|
||||
Datum
|
||||
pg_last_wal_receive_location(PG_FUNCTION_ARGS)
|
||||
pg_last_wal_receive_lsn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
XLogRecPtr recptr;
|
||||
|
||||
@ -434,7 +434,7 @@ pg_last_wal_receive_location(PG_FUNCTION_ARGS)
|
||||
* connections during recovery.
|
||||
*/
|
||||
Datum
|
||||
pg_last_wal_replay_location(PG_FUNCTION_ARGS)
|
||||
pg_last_wal_replay_lsn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
XLogRecPtr recptr;
|
||||
|
||||
@ -621,7 +621,7 @@ pg_is_in_recovery(PG_FUNCTION_ARGS)
|
||||
* Compute the difference in bytes between two WAL locations.
|
||||
*/
|
||||
Datum
|
||||
pg_wal_location_diff(PG_FUNCTION_ARGS)
|
||||
pg_wal_lsn_diff(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum result;
|
||||
|
||||
|
@ -724,10 +724,10 @@ CREATE VIEW pg_stat_replication AS
|
||||
S.backend_start,
|
||||
S.backend_xmin,
|
||||
W.state,
|
||||
W.sent_location,
|
||||
W.write_location,
|
||||
W.flush_location,
|
||||
W.replay_location,
|
||||
W.sent_lsn,
|
||||
W.write_lsn,
|
||||
W.flush_lsn,
|
||||
W.replay_lsn,
|
||||
W.write_lag,
|
||||
W.flush_lag,
|
||||
W.replay_lag,
|
||||
@ -1033,7 +1033,7 @@ CREATE OR REPLACE FUNCTION
|
||||
|
||||
CREATE OR REPLACE FUNCTION pg_logical_slot_get_changes(
|
||||
IN slot_name name, IN upto_lsn pg_lsn, IN upto_nchanges int, VARIADIC options text[] DEFAULT '{}',
|
||||
OUT location pg_lsn, OUT xid xid, OUT data text)
|
||||
OUT lsn pg_lsn, OUT xid xid, OUT data text)
|
||||
RETURNS SETOF RECORD
|
||||
LANGUAGE INTERNAL
|
||||
VOLATILE ROWS 1000 COST 1000
|
||||
@ -1041,7 +1041,7 @@ AS 'pg_logical_slot_get_changes';
|
||||
|
||||
CREATE OR REPLACE FUNCTION pg_logical_slot_peek_changes(
|
||||
IN slot_name name, IN upto_lsn pg_lsn, IN upto_nchanges int, VARIADIC options text[] DEFAULT '{}',
|
||||
OUT location pg_lsn, OUT xid xid, OUT data text)
|
||||
OUT lsn pg_lsn, OUT xid xid, OUT data text)
|
||||
RETURNS SETOF RECORD
|
||||
LANGUAGE INTERNAL
|
||||
VOLATILE ROWS 1000 COST 1000
|
||||
@ -1049,7 +1049,7 @@ AS 'pg_logical_slot_peek_changes';
|
||||
|
||||
CREATE OR REPLACE FUNCTION pg_logical_slot_get_binary_changes(
|
||||
IN slot_name name, IN upto_lsn pg_lsn, IN upto_nchanges int, VARIADIC options text[] DEFAULT '{}',
|
||||
OUT location pg_lsn, OUT xid xid, OUT data bytea)
|
||||
OUT lsn pg_lsn, OUT xid xid, OUT data bytea)
|
||||
RETURNS SETOF RECORD
|
||||
LANGUAGE INTERNAL
|
||||
VOLATILE ROWS 1000 COST 1000
|
||||
@ -1057,7 +1057,7 @@ AS 'pg_logical_slot_get_binary_changes';
|
||||
|
||||
CREATE OR REPLACE FUNCTION pg_logical_slot_peek_binary_changes(
|
||||
IN slot_name name, IN upto_lsn pg_lsn, IN upto_nchanges int, VARIADIC options text[] DEFAULT '{}',
|
||||
OUT location pg_lsn, OUT xid xid, OUT data bytea)
|
||||
OUT lsn pg_lsn, OUT xid xid, OUT data bytea)
|
||||
RETURNS SETOF RECORD
|
||||
LANGUAGE INTERNAL
|
||||
VOLATILE ROWS 1000 COST 1000
|
||||
@ -1066,7 +1066,7 @@ AS 'pg_logical_slot_peek_binary_changes';
|
||||
CREATE OR REPLACE FUNCTION pg_create_physical_replication_slot(
|
||||
IN slot_name name, IN immediately_reserve boolean DEFAULT false,
|
||||
IN temporary boolean DEFAULT false,
|
||||
OUT slot_name name, OUT wal_position pg_lsn)
|
||||
OUT slot_name name, OUT lsn pg_lsn)
|
||||
RETURNS RECORD
|
||||
LANGUAGE INTERNAL
|
||||
STRICT VOLATILE
|
||||
@ -1075,7 +1075,7 @@ AS 'pg_create_physical_replication_slot';
|
||||
CREATE OR REPLACE FUNCTION pg_create_logical_replication_slot(
|
||||
IN slot_name name, IN plugin name,
|
||||
IN temporary boolean DEFAULT false,
|
||||
OUT slot_name text, OUT wal_position pg_lsn)
|
||||
OUT slot_name text, OUT lsn pg_lsn)
|
||||
RETURNS RECORD
|
||||
LANGUAGE INTERNAL
|
||||
STRICT VOLATILE
|
||||
|
@ -91,11 +91,11 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
|
||||
* function's pg_proc entry!
|
||||
*/
|
||||
tupdesc = CreateTemplateTupleDesc(19, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "checkpoint_location",
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "checkpoint_lsn",
|
||||
LSNOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "prior_location",
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "prior_lsn",
|
||||
LSNOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "redo_location",
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "redo_lsn",
|
||||
LSNOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "redo_wal_file",
|
||||
TEXTOID, -1, 0);
|
||||
@ -225,13 +225,13 @@ pg_control_recovery(PG_FUNCTION_ARGS)
|
||||
* function's pg_proc entry!
|
||||
*/
|
||||
tupdesc = CreateTemplateTupleDesc(5, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "min_recovery_end_location",
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "min_recovery_end_lsn",
|
||||
LSNOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "min_recovery_end_timeline",
|
||||
INT4OID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "backup_start_location",
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "backup_start_lsn",
|
||||
LSNOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "backup_end_location",
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "backup_end_lsn",
|
||||
LSNOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "end_of_backup_record_required",
|
||||
BOOLOID, -1, 0);
|
||||
|
@ -39,7 +39,7 @@ isnt($slot->{'restart_lsn'}, '', 'restart lsn is defined for new slot');
|
||||
|
||||
$node->psql('postgres', 'CREATE TABLE test_table(x integer)');
|
||||
$node->psql('postgres', 'INSERT INTO test_table(x) SELECT y FROM generate_series(1, 10) a(y);');
|
||||
my $nextlsn = $node->safe_psql('postgres', 'SELECT pg_current_wal_insert_location()');
|
||||
my $nextlsn = $node->safe_psql('postgres', 'SELECT pg_current_wal_insert_lsn()');
|
||||
chomp($nextlsn);
|
||||
|
||||
$node->command_ok(['pg_recvlogical', '-S', 'test', '-d', $node->connstr('postgres'), '--start', '--endpos', "$nextlsn", '--no-loop', '-f', '-'],
|
||||
|
@ -156,7 +156,7 @@ sub promote_standby
|
||||
|
||||
# Wait for the standby to receive and write all WAL.
|
||||
my $wal_received_query =
|
||||
"SELECT pg_current_wal_location() = write_location FROM pg_stat_replication WHERE application_name = 'rewind_standby';";
|
||||
"SELECT pg_current_wal_lsn() = write_lsn FROM pg_stat_replication WHERE application_name = 'rewind_standby';";
|
||||
$node_master->poll_query_until('postgres', $wal_received_query)
|
||||
or die "Timed out while waiting for standby to receive and write WAL";
|
||||
|
||||
|
@ -120,7 +120,7 @@ run_simple_query(const char *sql)
|
||||
}
|
||||
|
||||
/*
|
||||
* Calls pg_current_wal_insert_location() function
|
||||
* Calls pg_current_wal_insert_lsn() function
|
||||
*/
|
||||
XLogRecPtr
|
||||
libpqGetCurrentXlogInsertLocation(void)
|
||||
@ -130,7 +130,7 @@ libpqGetCurrentXlogInsertLocation(void)
|
||||
uint32 lo;
|
||||
char *val;
|
||||
|
||||
val = run_simple_query("SELECT pg_current_wal_insert_location()");
|
||||
val = run_simple_query("SELECT pg_current_wal_insert_lsn()");
|
||||
|
||||
if (sscanf(val, "%X/%X", &hi, &lo) != 2)
|
||||
pg_fatal("unrecognized result \"%s\" for current WAL insert location\n", val);
|
||||
|
@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201705091
|
||||
#define CATALOG_VERSION_NO 201705111
|
||||
|
||||
#endif
|
||||
|
@ -2830,7 +2830,7 @@ DATA(insert OID = 2022 ( pg_stat_get_activity PGNSP PGUID 12 1 100 0 0 f f f
|
||||
DESCR("statistics: information about currently active backends");
|
||||
DATA(insert OID = 3318 ( pg_stat_get_progress_info PGNSP PGUID 12 1 100 0 0 f f f f t t s r 1 0 2249 "25" "{25,23,26,26,20,20,20,20,20,20,20,20,20,20}" "{i,o,o,o,o,o,o,o,o,o,o,o,o,o}" "{cmdtype,pid,datid,relid,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10}" _null_ _null_ pg_stat_get_progress_info _null_ _null_ _null_ ));
|
||||
DESCR("statistics: information about progress of backends running maintenance command");
|
||||
DATA(insert OID = 3099 ( pg_stat_get_wal_senders PGNSP PGUID 12 1 10 0 0 f f f f f t s r 0 0 2249 "" "{23,25,3220,3220,3220,3220,1186,1186,1186,23,25}" "{o,o,o,o,o,o,o,o,o,o,o}" "{pid,state,sent_location,write_location,flush_location,replay_location,write_lag,flush_lag,replay_lag,sync_priority,sync_state}" _null_ _null_ pg_stat_get_wal_senders _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3099 ( pg_stat_get_wal_senders PGNSP PGUID 12 1 10 0 0 f f f f f t s r 0 0 2249 "" "{23,25,3220,3220,3220,3220,1186,1186,1186,23,25}" "{o,o,o,o,o,o,o,o,o,o,o}" "{pid,state,sent_lsn,write_lsn,flush_lsn,replay_lsn,write_lag,flush_lag,replay_lag,sync_priority,sync_state}" _null_ _null_ pg_stat_get_wal_senders _null_ _null_ _null_ ));
|
||||
DESCR("statistics: information about currently active replication");
|
||||
DATA(insert OID = 3317 ( pg_stat_get_wal_receiver PGNSP PGUID 12 1 0 0 0 f f f f f f s r 0 0 2249 "" "{23,25,3220,23,3220,23,1184,1184,3220,1184,25,25}" "{o,o,o,o,o,o,o,o,o,o,o,o}" "{pid,status,receive_start_lsn,receive_start_tli,received_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,conninfo}" _null_ _null_ pg_stat_get_wal_receiver _null_ _null_ _null_ ));
|
||||
DESCR("statistics: information about WAL receiver");
|
||||
@ -3215,18 +3215,18 @@ DATA(insert OID = 2848 ( pg_switch_wal PGNSP PGUID 12 1 0 0 0 f f f f t f v s
|
||||
DESCR("switch to new wal file");
|
||||
DATA(insert OID = 3098 ( pg_create_restore_point PGNSP PGUID 12 1 0 0 0 f f f f t f v s 1 0 3220 "25" _null_ _null_ _null_ _null_ _null_ pg_create_restore_point _null_ _null_ _null_ ));
|
||||
DESCR("create a named restore point");
|
||||
DATA(insert OID = 2849 ( pg_current_wal_location PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_location _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 2849 ( pg_current_wal_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_lsn _null_ _null_ _null_ ));
|
||||
DESCR("current wal write location");
|
||||
DATA(insert OID = 2852 ( pg_current_wal_insert_location PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_insert_location _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 2852 ( pg_current_wal_insert_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_insert_lsn _null_ _null_ _null_ ));
|
||||
DESCR("current wal insert location");
|
||||
DATA(insert OID = 3330 ( pg_current_wal_flush_location PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_flush_location _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3330 ( pg_current_wal_flush_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_flush_lsn _null_ _null_ _null_ ));
|
||||
DESCR("current wal flush location");
|
||||
DATA(insert OID = 2850 ( pg_walfile_name_offset PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2249 "3220" "{3220,25,23}" "{i,o,o}" "{wal_location,file_name,file_offset}" _null_ _null_ pg_walfile_name_offset _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 2850 ( pg_walfile_name_offset PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2249 "3220" "{3220,25,23}" "{i,o,o}" "{lsn,file_name,file_offset}" _null_ _null_ pg_walfile_name_offset _null_ _null_ _null_ ));
|
||||
DESCR("wal filename and byte offset, given a wal location");
|
||||
DATA(insert OID = 2851 ( pg_walfile_name PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 25 "3220" _null_ _null_ _null_ _null_ _null_ pg_walfile_name _null_ _null_ _null_ ));
|
||||
DESCR("wal filename, given a wal location");
|
||||
|
||||
DATA(insert OID = 3165 ( pg_wal_location_diff PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 1700 "3220 3220" _null_ _null_ _null_ _null_ _null_ pg_wal_location_diff _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3165 ( pg_wal_lsn_diff PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 1700 "3220 3220" _null_ _null_ _null_ _null_ _null_ pg_wal_lsn_diff _null_ _null_ _null_ ));
|
||||
DESCR("difference in bytes, given two wal locations");
|
||||
|
||||
DATA(insert OID = 3809 ( pg_export_snapshot PGNSP PGUID 12 1 0 0 0 f f f f t f v u 0 0 25 "" _null_ _null_ _null_ _null_ _null_ pg_export_snapshot _null_ _null_ _null_ ));
|
||||
@ -3235,9 +3235,9 @@ DESCR("export a snapshot");
|
||||
DATA(insert OID = 3810 ( pg_is_in_recovery PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 16 "" _null_ _null_ _null_ _null_ _null_ pg_is_in_recovery _null_ _null_ _null_ ));
|
||||
DESCR("true if server is in recovery");
|
||||
|
||||
DATA(insert OID = 3820 ( pg_last_wal_receive_location PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_last_wal_receive_location _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3820 ( pg_last_wal_receive_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_last_wal_receive_lsn _null_ _null_ _null_ ));
|
||||
DESCR("current wal flush location");
|
||||
DATA(insert OID = 3821 ( pg_last_wal_replay_location PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_last_wal_replay_location _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3821 ( pg_last_wal_replay_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_last_wal_replay_lsn _null_ _null_ _null_ ));
|
||||
DESCR("last wal replay location");
|
||||
DATA(insert OID = 3830 ( pg_last_xact_replay_timestamp PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 1184 "" _null_ _null_ _null_ _null_ _null_ pg_last_xact_replay_timestamp _null_ _null_ _null_ ));
|
||||
DESCR("timestamp of last replay xact");
|
||||
@ -5285,21 +5285,21 @@ DATA(insert OID = 5016 ( spg_box_quad_leaf_consistent PGNSP PGUID 12 1 0 0 0 f
|
||||
DESCR("SP-GiST support for quad tree over box");
|
||||
|
||||
/* replication slots */
|
||||
DATA(insert OID = 3779 ( pg_create_physical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f t f v u 3 0 2249 "19 16 16" "{19,16,16,19,3220}" "{i,i,i,o,o}" "{slot_name,immediately_reserve,temporary,slot_name,wal_position}" _null_ _null_ pg_create_physical_replication_slot _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3779 ( pg_create_physical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f t f v u 3 0 2249 "19 16 16" "{19,16,16,19,3220}" "{i,i,i,o,o}" "{slot_name,immediately_reserve,temporary,slot_name,lsn}" _null_ _null_ pg_create_physical_replication_slot _null_ _null_ _null_ ));
|
||||
DESCR("create a physical replication slot");
|
||||
DATA(insert OID = 3780 ( pg_drop_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f t f v u 1 0 2278 "19" _null_ _null_ _null_ _null_ _null_ pg_drop_replication_slot _null_ _null_ _null_ ));
|
||||
DESCR("drop a replication slot");
|
||||
DATA(insert OID = 3781 ( pg_get_replication_slots PGNSP PGUID 12 1 10 0 0 f f f f f t s s 0 0 2249 "" "{19,19,25,26,16,16,23,28,28,3220,3220}" "{o,o,o,o,o,o,o,o,o,o,o}" "{slot_name,plugin,slot_type,datoid,temporary,active,active_pid,xmin,catalog_xmin,restart_lsn,confirmed_flush_lsn}" _null_ _null_ pg_get_replication_slots _null_ _null_ _null_ ));
|
||||
DESCR("information about replication slots currently in use");
|
||||
DATA(insert OID = 3786 ( pg_create_logical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f t f v u 3 0 2249 "19 19 16" "{19,19,16,25,3220}" "{i,i,i,o,o}" "{slot_name,plugin,temporary,slot_name,wal_position}" _null_ _null_ pg_create_logical_replication_slot _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3786 ( pg_create_logical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f t f v u 3 0 2249 "19 19 16" "{19,19,16,25,3220}" "{i,i,i,o,o}" "{slot_name,plugin,temporary,slot_name,lsn}" _null_ _null_ pg_create_logical_replication_slot _null_ _null_ _null_ ));
|
||||
DESCR("set up a logical replication slot");
|
||||
DATA(insert OID = 3782 ( pg_logical_slot_get_changes PGNSP PGUID 12 1000 1000 25 0 f f f f f t v u 4 0 2249 "19 3220 23 1009" "{19,3220,23,1009,3220,28,25}" "{i,i,i,v,o,o,o}" "{slot_name,upto_lsn,upto_nchanges,options,location,xid,data}" _null_ _null_ pg_logical_slot_get_changes _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3782 ( pg_logical_slot_get_changes PGNSP PGUID 12 1000 1000 25 0 f f f f f t v u 4 0 2249 "19 3220 23 1009" "{19,3220,23,1009,3220,28,25}" "{i,i,i,v,o,o,o}" "{slot_name,upto_lsn,upto_nchanges,options,lsn,xid,data}" _null_ _null_ pg_logical_slot_get_changes _null_ _null_ _null_ ));
|
||||
DESCR("get changes from replication slot");
|
||||
DATA(insert OID = 3783 ( pg_logical_slot_get_binary_changes PGNSP PGUID 12 1000 1000 25 0 f f f f f t v u 4 0 2249 "19 3220 23 1009" "{19,3220,23,1009,3220,28,17}" "{i,i,i,v,o,o,o}" "{slot_name,upto_lsn,upto_nchanges,options,location,xid,data}" _null_ _null_ pg_logical_slot_get_binary_changes _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3783 ( pg_logical_slot_get_binary_changes PGNSP PGUID 12 1000 1000 25 0 f f f f f t v u 4 0 2249 "19 3220 23 1009" "{19,3220,23,1009,3220,28,17}" "{i,i,i,v,o,o,o}" "{slot_name,upto_lsn,upto_nchanges,options,lsn,xid,data}" _null_ _null_ pg_logical_slot_get_binary_changes _null_ _null_ _null_ ));
|
||||
DESCR("get binary changes from replication slot");
|
||||
DATA(insert OID = 3784 ( pg_logical_slot_peek_changes PGNSP PGUID 12 1000 1000 25 0 f f f f f t v u 4 0 2249 "19 3220 23 1009" "{19,3220,23,1009,3220,28,25}" "{i,i,i,v,o,o,o}" "{slot_name,upto_lsn,upto_nchanges,options,location,xid,data}" _null_ _null_ pg_logical_slot_peek_changes _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3784 ( pg_logical_slot_peek_changes PGNSP PGUID 12 1000 1000 25 0 f f f f f t v u 4 0 2249 "19 3220 23 1009" "{19,3220,23,1009,3220,28,25}" "{i,i,i,v,o,o,o}" "{slot_name,upto_lsn,upto_nchanges,options,lsn,xid,data}" _null_ _null_ pg_logical_slot_peek_changes _null_ _null_ _null_ ));
|
||||
DESCR("peek at changes from replication slot");
|
||||
DATA(insert OID = 3785 ( pg_logical_slot_peek_binary_changes PGNSP PGUID 12 1000 1000 25 0 f f f f f t v u 4 0 2249 "19 3220 23 1009" "{19,3220,23,1009,3220,28,17}" "{i,i,i,v,o,o,o}" "{slot_name,upto_lsn,upto_nchanges,options,location,xid,data}" _null_ _null_ pg_logical_slot_peek_binary_changes _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3785 ( pg_logical_slot_peek_binary_changes PGNSP PGUID 12 1000 1000 25 0 f f f f f t v u 4 0 2249 "19 3220 23 1009" "{19,3220,23,1009,3220,28,17}" "{i,i,i,v,o,o,o}" "{slot_name,upto_lsn,upto_nchanges,options,lsn,xid,data}" _null_ _null_ pg_logical_slot_peek_binary_changes _null_ _null_ _null_ ));
|
||||
DESCR("peek at binary changes from replication slot");
|
||||
DATA(insert OID = 3577 ( pg_logical_emit_message PGNSP PGUID 12 1 0 0 0 f f f f t f v u 3 0 3220 "16 25 25" _null_ _null_ _null_ _null_ _null_ pg_logical_emit_message_text _null_ _null_ _null_ ));
|
||||
DESCR("emit a textual logical decoding message");
|
||||
@ -5447,10 +5447,10 @@ DESCR("pg_config binary as a function");
|
||||
DATA(insert OID = 3441 ( pg_control_system PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 2249 "" "{23,23,20,1184}" "{o,o,o,o}" "{pg_control_version,catalog_version_no,system_identifier,pg_control_last_modified}" _null_ _null_ pg_control_system _null_ _null_ _null_ ));
|
||||
DESCR("pg_controldata general state information as a function");
|
||||
|
||||
DATA(insert OID = 3442 ( pg_control_checkpoint PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 2249 "" "{3220,3220,3220,25,23,23,16,25,26,28,28,28,26,28,28,26,28,28,1184}" "{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}" "{checkpoint_location,prior_location,redo_location,redo_wal_file,timeline_id,prev_timeline_id,full_page_writes,next_xid,next_oid,next_multixact_id,next_multi_offset,oldest_xid,oldest_xid_dbid,oldest_active_xid,oldest_multi_xid,oldest_multi_dbid,oldest_commit_ts_xid,newest_commit_ts_xid,checkpoint_time}" _null_ _null_ pg_control_checkpoint _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3442 ( pg_control_checkpoint PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 2249 "" "{3220,3220,3220,25,23,23,16,25,26,28,28,28,26,28,28,26,28,28,1184}" "{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}" "{checkpoint_lsn,prior_lsn,redo_lsn,redo_wal_file,timeline_id,prev_timeline_id,full_page_writes,next_xid,next_oid,next_multixact_id,next_multi_offset,oldest_xid,oldest_xid_dbid,oldest_active_xid,oldest_multi_xid,oldest_multi_dbid,oldest_commit_ts_xid,newest_commit_ts_xid,checkpoint_time}" _null_ _null_ pg_control_checkpoint _null_ _null_ _null_ ));
|
||||
DESCR("pg_controldata checkpoint state information as a function");
|
||||
|
||||
DATA(insert OID = 3443 ( pg_control_recovery PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 2249 "" "{3220,23,3220,3220,16}" "{o,o,o,o,o}" "{min_recovery_end_location,min_recovery_end_timeline,backup_start_location,backup_end_location,end_of_backup_record_required}" _null_ _null_ pg_control_recovery _null_ _null_ _null_ ));
|
||||
DATA(insert OID = 3443 ( pg_control_recovery PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 2249 "" "{3220,23,3220,3220,16}" "{o,o,o,o,o}" "{min_recovery_end_lsn,min_recovery_end_timeline,backup_start_lsn,backup_end_lsn,end_of_backup_record_required}" _null_ _null_ pg_control_recovery _null_ _null_ _null_ ));
|
||||
DESCR("pg_controldata recovery state information as a function");
|
||||
|
||||
DATA(insert OID = 3444 ( pg_control_init PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 2249 "" "{23,23,23,23,23,23,23,23,23,16,16,23}" "{o,o,o,o,o,o,o,o,o,o,o,o}" "{max_data_alignment,database_block_size,blocks_per_segment,wal_block_size,bytes_per_wal_segment,max_identifier_length,max_index_columns,max_toast_chunk_size,large_object_chunk_size,float4_pass_by_value,float8_pass_by_value,data_page_checksum_version}" _null_ _null_ pg_control_init _null_ _null_ _null_ ));
|
||||
|
@ -31,9 +31,9 @@ my $master_ts = $master->safe_psql('postgres',
|
||||
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
|
||||
);
|
||||
my $master_lsn =
|
||||
$master->safe_psql('postgres', 'select pg_current_wal_location()');
|
||||
$master->safe_psql('postgres', 'select pg_current_wal_lsn()');
|
||||
$standby->poll_query_until('postgres',
|
||||
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_location()})
|
||||
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
|
||||
or die "slave never caught up";
|
||||
|
||||
my $standby_ts = $standby->safe_psql('postgres',
|
||||
@ -45,9 +45,9 @@ $master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
|
||||
$master->restart;
|
||||
$master->safe_psql('postgres', 'checkpoint');
|
||||
$master_lsn =
|
||||
$master->safe_psql('postgres', 'select pg_current_wal_location()');
|
||||
$master->safe_psql('postgres', 'select pg_current_wal_lsn()');
|
||||
$standby->poll_query_until('postgres',
|
||||
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_location()})
|
||||
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
|
||||
or die "slave never caught up";
|
||||
$standby->safe_psql('postgres', 'checkpoint');
|
||||
|
||||
|
@ -30,9 +30,9 @@ $master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
|
||||
$master->restart;
|
||||
$master->safe_psql('postgres', 'checkpoint');
|
||||
my $master_lsn =
|
||||
$master->safe_psql('postgres', 'select pg_current_wal_location()');
|
||||
$master->safe_psql('postgres', 'select pg_current_wal_lsn()');
|
||||
$standby->poll_query_until('postgres',
|
||||
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_location()})
|
||||
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
|
||||
or die "slave never caught up";
|
||||
|
||||
$standby->safe_psql('postgres', 'checkpoint');
|
||||
|
@ -1347,13 +1347,13 @@ sub run_log
|
||||
|
||||
=item $node->lsn(mode)
|
||||
|
||||
Look up WAL positions on the server:
|
||||
Look up WAL locations on the server:
|
||||
|
||||
* insert position (master only, error on replica)
|
||||
* write position (master only, error on replica)
|
||||
* flush position (master only, error on replica)
|
||||
* receive position (always undef on master)
|
||||
* replay position (always undef on master)
|
||||
* insert location (master only, error on replica)
|
||||
* write location (master only, error on replica)
|
||||
* flush location (master only, error on replica)
|
||||
* receive location (always undef on master)
|
||||
* replay location (always undef on master)
|
||||
|
||||
mode must be specified.
|
||||
|
||||
@ -1362,11 +1362,11 @@ mode must be specified.
|
||||
sub lsn
|
||||
{
|
||||
my ($self, $mode) = @_;
|
||||
my %modes = ('insert' => 'pg_current_wal_insert_location()',
|
||||
'flush' => 'pg_current_wal_flush_location()',
|
||||
'write' => 'pg_current_wal_location()',
|
||||
'receive' => 'pg_last_wal_receive_location()',
|
||||
'replay' => 'pg_last_wal_replay_location()');
|
||||
my %modes = ('insert' => 'pg_current_wal_insert_lsn()',
|
||||
'flush' => 'pg_current_wal_flush_lsn()',
|
||||
'write' => 'pg_current_wal_lsn()',
|
||||
'receive' => 'pg_last_wal_receive_lsn()',
|
||||
'replay' => 'pg_last_wal_replay_lsn()');
|
||||
|
||||
$mode = '<undef>' if !defined($mode);
|
||||
die "unknown mode for 'lsn': '$mode', valid modes are " . join(', ', keys %modes)
|
||||
@ -1389,10 +1389,10 @@ sub lsn
|
||||
=item $node->wait_for_catchup(standby_name, mode, target_lsn)
|
||||
|
||||
Wait for the node with application_name standby_name (usually from node->name)
|
||||
until its replication position in pg_stat_replication equals or passes the
|
||||
until its replication location in pg_stat_replication equals or passes the
|
||||
upstream's WAL insert point at the time this function is called. By default
|
||||
the replay_location is waited for, but 'mode' may be specified to wait for any
|
||||
of sent|write|flush|replay.
|
||||
the replay_lsn is waited for, but 'mode' may be specified to wait for any of
|
||||
sent|write|flush|replay.
|
||||
|
||||
If there is no active replication connection from this peer, waits until
|
||||
poll_query_until timeout.
|
||||
@ -1417,10 +1417,10 @@ sub wait_for_catchup
|
||||
$standby_name = $standby_name->name;
|
||||
}
|
||||
die 'target_lsn must be specified' unless defined($target_lsn);
|
||||
print "Waiting for replication conn " . $standby_name . "'s " . $mode . "_location to pass " . $target_lsn . " on " . $self->name . "\n";
|
||||
my $query = qq[SELECT '$target_lsn' <= ${mode}_location FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name';];
|
||||
print "Waiting for replication conn " . $standby_name . "'s " . $mode . "_lsn to pass " . $target_lsn . " on " . $self->name . "\n";
|
||||
my $query = qq[SELECT '$target_lsn' <= ${mode}_lsn FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name';];
|
||||
$self->poll_query_until('postgres', $query)
|
||||
or die "timed out waiting for catchup, current position is " . ($self->safe_psql('postgres', $query) || '(unknown)');
|
||||
or die "timed out waiting for catchup, current location is " . ($self->safe_psql('postgres', $query) || '(unknown)');
|
||||
print "done\n";
|
||||
}
|
||||
|
||||
@ -1429,7 +1429,7 @@ sub wait_for_catchup
|
||||
=item $node->wait_for_slot_catchup(slot_name, mode, target_lsn)
|
||||
|
||||
Wait for the named replication slot to equal or pass the supplied target_lsn.
|
||||
The position used is the restart_lsn unless mode is given, in which case it may
|
||||
The location used is the restart_lsn unless mode is given, in which case it may
|
||||
be 'restart' or 'confirmed_flush'.
|
||||
|
||||
Requires that the 'postgres' db exists and is accessible.
|
||||
@ -1456,7 +1456,7 @@ sub wait_for_slot_catchup
|
||||
print "Waiting for replication slot " . $slot_name . "'s " . $mode . "_lsn to pass " . $target_lsn . " on " . $self->name . "\n";
|
||||
my $query = qq[SELECT '$target_lsn' <= ${mode}_lsn FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name';];
|
||||
$self->poll_query_until('postgres', $query)
|
||||
or die "timed out waiting for catchup, current position is " . ($self->safe_psql('postgres', $query) || '(unknown)');
|
||||
or die "timed out waiting for catchup, current location is " . ($self->safe_psql('postgres', $query) || '(unknown)');
|
||||
print "done\n";
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ $node_standby->start;
|
||||
$node_master->safe_psql('postgres',
|
||||
"CREATE TABLE tab_int AS SELECT generate_series(1,1000) AS a");
|
||||
my $current_lsn =
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_location();");
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
|
||||
|
||||
# Force archiving of WAL file to make it present on master
|
||||
$node_master->safe_psql('postgres', "SELECT pg_switch_wal()");
|
||||
@ -42,7 +42,7 @@ $node_master->safe_psql('postgres',
|
||||
|
||||
# Wait until necessary replay has been done on standby
|
||||
my $caughtup_query =
|
||||
"SELECT '$current_lsn'::pg_lsn <= pg_last_wal_replay_location()";
|
||||
"SELECT '$current_lsn'::pg_lsn <= pg_last_wal_replay_lsn()";
|
||||
$node_standby->poll_query_until('postgres', $caughtup_query)
|
||||
or die "Timed out while waiting for standby to catch up";
|
||||
|
||||
|
@ -30,7 +30,7 @@ sub test_recovery_standby
|
||||
|
||||
# Wait until standby has replayed enough data
|
||||
my $caughtup_query =
|
||||
"SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_location()";
|
||||
"SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_lsn()";
|
||||
$node_standby->poll_query_until('postgres', $caughtup_query)
|
||||
or die "Timed out while waiting for standby to catch up";
|
||||
|
||||
@ -55,7 +55,7 @@ $node_master->start;
|
||||
$node_master->safe_psql('postgres',
|
||||
"CREATE TABLE tab_int AS SELECT generate_series(1,1000) AS a");
|
||||
my $lsn1 =
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_location();");
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
|
||||
|
||||
# Take backup from which all operations will be run
|
||||
$node_master->backup('my_backup');
|
||||
@ -65,14 +65,14 @@ $node_master->backup('my_backup');
|
||||
$node_master->safe_psql('postgres',
|
||||
"INSERT INTO tab_int VALUES (generate_series(1001,2000))");
|
||||
my $ret = $node_master->safe_psql('postgres',
|
||||
"SELECT pg_current_wal_location(), txid_current();");
|
||||
"SELECT pg_current_wal_lsn(), txid_current();");
|
||||
my ($lsn2, $recovery_txid) = split /\|/, $ret;
|
||||
|
||||
# More data, with recovery target timestamp
|
||||
$node_master->safe_psql('postgres',
|
||||
"INSERT INTO tab_int VALUES (generate_series(2001,3000))");
|
||||
$ret = $node_master->safe_psql('postgres',
|
||||
"SELECT pg_current_wal_location(), now();");
|
||||
"SELECT pg_current_wal_lsn(), now();");
|
||||
my ($lsn3, $recovery_time) = split /\|/, $ret;
|
||||
|
||||
# Even more data, this time with a recovery target name
|
||||
@ -80,16 +80,16 @@ $node_master->safe_psql('postgres',
|
||||
"INSERT INTO tab_int VALUES (generate_series(3001,4000))");
|
||||
my $recovery_name = "my_target";
|
||||
my $lsn4 =
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_location();");
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
|
||||
$node_master->safe_psql('postgres',
|
||||
"SELECT pg_create_restore_point('$recovery_name');");
|
||||
|
||||
# And now for a recovery target LSN
|
||||
$node_master->safe_psql('postgres',
|
||||
"INSERT INTO tab_int VALUES (generate_series(4001,5000))");
|
||||
my $recovery_lsn = $node_master->safe_psql('postgres', "SELECT pg_current_wal_location()");
|
||||
my $recovery_lsn = $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()");
|
||||
my $lsn5 =
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_location();");
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
|
||||
|
||||
$node_master->safe_psql('postgres',
|
||||
"INSERT INTO tab_int VALUES (generate_series(5001,6000))");
|
||||
|
@ -42,7 +42,7 @@ $node_master->safe_psql('postgres',
|
||||
# Now wait for replay to complete on standby. We're done waiting when the
|
||||
# slave has replayed up to the previously saved master LSN.
|
||||
my $until_lsn =
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_location()");
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()");
|
||||
|
||||
my $remaining = 90;
|
||||
while ($remaining-- > 0)
|
||||
@ -50,7 +50,7 @@ while ($remaining-- > 0)
|
||||
|
||||
# Done waiting?
|
||||
my $replay_status = $node_standby->safe_psql('postgres',
|
||||
"SELECT (pg_last_wal_replay_location() - '$until_lsn'::pg_lsn) >= 0"
|
||||
"SELECT (pg_last_wal_replay_lsn() - '$until_lsn'::pg_lsn) >= 0"
|
||||
);
|
||||
last if $replay_status eq 't';
|
||||
|
||||
|
@ -53,7 +53,7 @@ COMMIT};
|
||||
my $stdout_sql = $node_master->safe_psql('postgres', qq[SELECT data FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');]);
|
||||
is($stdout_sql, $expected, 'got expected output from SQL decoding session');
|
||||
|
||||
my $endpos = $node_master->safe_psql('postgres', "SELECT location FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY location DESC LIMIT 1;");
|
||||
my $endpos = $node_master->safe_psql('postgres', "SELECT lsn FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;");
|
||||
print "waiting to replay $endpos\n";
|
||||
|
||||
my $stdout_recv = $node_master->pg_recvlogical_upto('postgres', 'test_slot', $endpos, 10, 'include-xids' => '0', 'skip-empty-xacts' => '1');
|
||||
@ -66,7 +66,7 @@ is($stdout_recv, '', 'pg_recvlogical acknowledged changes, nothing pending on sl
|
||||
|
||||
$node_master->safe_psql('postgres', 'CREATE DATABASE otherdb');
|
||||
|
||||
is($node_master->psql('otherdb', "SELECT location FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY location DESC LIMIT 1;"), 3,
|
||||
is($node_master->psql('otherdb', "SELECT lsn FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"), 3,
|
||||
'replaying logical slot from another database fails');
|
||||
|
||||
$node_master->safe_psql('otherdb', qq[SELECT pg_create_logical_replication_slot('otherdb_slot', 'test_decoding');]);
|
||||
|
@ -68,11 +68,11 @@ vacuum verbose testtab;
|
||||
|
||||
$node_master->psql('postgres', 'checkpoint');
|
||||
my $until_lsn =
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_location();");
|
||||
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
|
||||
|
||||
# Wait long enough for standby to receive and apply all WAL
|
||||
my $caughtup_query =
|
||||
"SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_location()";
|
||||
"SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_lsn()";
|
||||
$node_standby->poll_query_until('postgres', $caughtup_query)
|
||||
or die "Timed out while waiting for standby to catch up";
|
||||
|
||||
|
@ -169,7 +169,7 @@ is($stderr, '', 'replay from slot before_basebackup produces no stderr');
|
||||
# pg_recvlogical we should get complete results. First, find out the commit lsn
|
||||
# of the last transaction. There's no max(pg_lsn), so:
|
||||
|
||||
my $endpos = $node_replica->safe_psql('postgres', "SELECT location FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL) ORDER BY location DESC LIMIT 1;");
|
||||
my $endpos = $node_replica->safe_psql('postgres', "SELECT lsn FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL) ORDER BY lsn DESC LIMIT 1;");
|
||||
|
||||
# now use the walsender protocol to peek the slot changes and make sure we see
|
||||
# the same results.
|
||||
|
@ -1851,17 +1851,17 @@ pg_stat_replication| SELECT s.pid,
|
||||
s.backend_start,
|
||||
s.backend_xmin,
|
||||
w.state,
|
||||
w.sent_location,
|
||||
w.write_location,
|
||||
w.flush_location,
|
||||
w.replay_location,
|
||||
w.sent_lsn,
|
||||
w.write_lsn,
|
||||
w.flush_lsn,
|
||||
w.replay_lsn,
|
||||
w.write_lag,
|
||||
w.flush_lag,
|
||||
w.replay_lag,
|
||||
w.sync_priority,
|
||||
w.sync_state
|
||||
FROM ((pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, sslclientdn)
|
||||
JOIN pg_stat_get_wal_senders() w(pid, state, sent_location, write_location, flush_location, replay_location, write_lag, flush_lag, replay_lag, sync_priority, sync_state) ON ((s.pid = w.pid)))
|
||||
JOIN pg_stat_get_wal_senders() w(pid, state, sent_lsn, write_lsn, flush_lsn, replay_lsn, write_lag, flush_lag, replay_lag, sync_priority, sync_state) ON ((s.pid = w.pid)))
|
||||
LEFT JOIN pg_authid u ON ((s.usesysid = u.oid)));
|
||||
pg_stat_ssl| SELECT s.pid,
|
||||
s.ssl,
|
||||
|
@ -52,7 +52,7 @@ $node_subscriber->safe_psql('postgres',
|
||||
|
||||
# Wait for subscriber to finish initialization
|
||||
my $caughtup_query =
|
||||
"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';";
|
||||
"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';";
|
||||
$node_publisher->poll_query_until('postgres', $caughtup_query)
|
||||
or die "Timed out while waiting for subscriber to catch up";
|
||||
|
||||
|
@ -107,7 +107,7 @@ $node_subscriber->safe_psql('postgres',
|
||||
|
||||
# Wait for subscriber to finish initialization
|
||||
my $caughtup_query =
|
||||
"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';";
|
||||
"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';";
|
||||
$node_publisher->poll_query_until('postgres', $caughtup_query)
|
||||
or die "Timed out while waiting for subscriber to catch up";
|
||||
|
||||
|
@ -38,7 +38,7 @@ $node_subscriber->safe_psql('postgres',
|
||||
|
||||
# Wait for subscriber to finish initialization
|
||||
my $caughtup_query =
|
||||
"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';";
|
||||
"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';";
|
||||
$node_publisher->poll_query_until('postgres', $caughtup_query)
|
||||
or die "Timed out while waiting for subscriber to catch up";
|
||||
|
||||
|
@ -37,7 +37,7 @@ $node_subscriber->safe_psql('postgres',
|
||||
|
||||
# Wait for subscriber to finish initialization
|
||||
my $caughtup_query =
|
||||
"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';";
|
||||
"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';";
|
||||
$node_publisher->poll_query_until('postgres', $caughtup_query)
|
||||
or die "Timed out while waiting for subscriber to catch up";
|
||||
|
||||
|
@ -10,7 +10,7 @@ sub wait_for_caught_up
|
||||
my ($node, $appname) = @_;
|
||||
|
||||
$node->poll_query_until('postgres',
|
||||
"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';")
|
||||
"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';")
|
||||
or die "Timed out while waiting for subscriber to catch up";
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user