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

Commit3f811c2

Browse files
committed
Add confirmed_flush column to pg_replication_slots.
There's no reason not to expose both restart_lsn and confirmed_flushsince they have rather distinct meanings. The former is the oldest WALstill required and valid for both physical and logical slots, whereasthe latter is the location up to which a logical slot's consumer hasconfirmed receiving data. Most of the time a slot will require olderWAL (i.e. restart_lsn) than the confirmedposition (i.e. confirmed_flush_lsn).Author: Marko Tiikkaja, editorialized by meDiscussion: 559D110B.1020109@joh.to
1 parent5c4b25a commit3f811c2

File tree

9 files changed

+35
-15
lines changed

9 files changed

+35
-15
lines changed

‎contrib/test_decoding/expected/ddl.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ SELECT pg_drop_replication_slot('regression_slot');
673673

674674
/* check that the slot is gone */
675675
SELECT * FROM pg_replication_slots;
676-
slot_name | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn
677-
-----------+--------+-----------+--------+----------+--------+------------+------+--------------+-------------
676+
slot_name | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn| confirmed_flush_lsn
677+
-----------+--------+-----------+--------+----------+--------+------------+------+--------------+-------------+---------------------
678678
(0 rows)
679679

‎doc/src/sgml/catalogs.sgml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5577,6 +5577,17 @@
55775577
automatically removed during checkpoints.
55785578
</entry>
55795579
</row>
5580+
5581+
<row>
5582+
<entry><structfield>confirmed_flush</structfield></entry>
5583+
<entry><type>pg_lsn</type></entry>
5584+
<entry></entry>
5585+
<entry>The address (<literal>LSN</literal>) up to which the logical
5586+
slot's consumer has confirmed receiving data. Data older than this is
5587+
not available anymore. <literal>NULL</> for physical slots.
5588+
</entry>
5589+
</row>
5590+
55805591
</tbody>
55815592
</tgroup>
55825593
</table>

‎doc/src/sgml/high-availability.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,9 @@ postgres=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
934934
node_a_slot |
935935

936936
postgres=# SELECT * FROM pg_replication_slots;
937-
slot_name | slot_type | datoid | database | active | xmin | restart_lsn
938-
-------------+-----------+--------+----------+--------+------+-------------
939-
node_a_slot | physical | | | f | |
937+
slot_name | slot_type | datoid | database | active | xmin | restart_lsn | confirmed_flush_lsn
938+
-------------+-----------+--------+----------+--------+------+-------------+---------------------
939+
node_a_slot | physical | | | f | | |
940940
(1 row)
941941
</programlisting>
942942
To configure the standby to use this slot, <varname>primary_slot_name</>

‎doc/src/sgml/logicaldecoding.sgml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ postgres=# SELECT * FROM pg_create_logical_replication_slot('regression_slot', '
6262
regression_slot | 0/16B1970
6363
(1 row)
6464

65-
postgres=# SELECT slot_name, plugin, slot_type, database, active, restart_lsn FROM pg_replication_slots;
66-
slot_name | plugin | slot_type | database | active | restart_lsn
67-
-----------------+---------------+-----------+----------+--------+-------------
68-
regression_slot | test_decoding | logical | postgres | f | 0/16A4408
65+
postgres=# SELECT slot_name, plugin, slot_type, database, active, restart_lsn, confirmed_flush_lsn FROM pg_replication_slots;
66+
slot_name | plugin | slot_type | database | active | restart_lsn | confirmed_flush_lsn
67+
-----------------+---------------+-----------+----------+--------+-------------+-----------------
68+
regression_slot | test_decoding | logical | postgres | f | 0/16A4408 | 0/16A4440
6969
(1 row)
7070

7171
postgres=# -- There are no changes to see yet

‎src/backend/catalog/system_views.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,8 @@ CREATE VIEW pg_replication_slots AS
676676
L.active_pid,
677677
L.xmin,
678678
L.catalog_xmin,
679-
L.restart_lsn
679+
L.restart_lsn,
680+
L.confirmed_flush_lsn
680681
FROM pg_get_replication_slots()AS L
681682
LEFT JOIN pg_database DON (L.datoid=D.oid);
682683

‎src/backend/replication/slotfuncs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pg_drop_replication_slot(PG_FUNCTION_ARGS)
158158
Datum
159159
pg_get_replication_slots(PG_FUNCTION_ARGS)
160160
{
161-
#definePG_GET_REPLICATION_SLOTS_COLS9
161+
#definePG_GET_REPLICATION_SLOTS_COLS10
162162
ReturnSetInfo*rsinfo= (ReturnSetInfo*)fcinfo->resultinfo;
163163
TupleDesctupdesc;
164164
Tuplestorestate*tupstore;
@@ -206,6 +206,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
206206
TransactionIdxmin;
207207
TransactionIdcatalog_xmin;
208208
XLogRecPtrrestart_lsn;
209+
XLogRecPtrconfirmed_flush_lsn;
209210
pid_tactive_pid;
210211
Oiddatabase;
211212
NameDataslot_name;
@@ -224,6 +225,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
224225
catalog_xmin=slot->data.catalog_xmin;
225226
database=slot->data.database;
226227
restart_lsn=slot->data.restart_lsn;
228+
confirmed_flush_lsn=slot->data.confirmed_flush;
227229
namecpy(&slot_name,&slot->data.name);
228230
namecpy(&plugin,&slot->data.plugin);
229231

@@ -273,6 +275,11 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
273275
else
274276
nulls[i++]= true;
275277

278+
if (confirmed_flush_lsn!=InvalidXLogRecPtr)
279+
values[i++]=LSNGetDatum(confirmed_flush_lsn);
280+
else
281+
nulls[i++]= true;
282+
276283
tuplestore_putvalues(tupstore,tupdesc,values,nulls);
277284
}
278285

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201508062
56+
#defineCATALOG_VERSION_NO201508101
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5197,7 +5197,7 @@ DATA(insert OID = 3779 ( pg_create_physical_replication_slot PGNSP PGUID 12 1 0
51975197
DESCR("create a physical replication slot");
51985198
DATA(insert OID = 3780 ( pg_drop_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 2278 "19" _null_ _null_ _null_ _null_ _null_ pg_drop_replication_slot _null_ _null_ _null_ ));
51995199
DESCR("drop a replication slot");
5200-
DATA(insert OID = 3781 ( pg_get_replication_slotsPGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{19,19,25,26,16,23,28,28,3220}" "{o,o,o,o,o,o,o,o,o}" "{slot_name,plugin,slot_type,datoid,active,active_pid,xmin,catalog_xmin,restart_lsn}" _null_ _null_ pg_get_replication_slots _null_ _null_ _null_ ));
5200+
DATA(insert OID = 3781 ( pg_get_replication_slotsPGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{19,19,25,26,16,23,28,28,3220,3220}" "{o,o,o,o,o,o,o,o,o,o}" "{slot_name,plugin,slot_type,datoid,active,active_pid,xmin,catalog_xmin,restart_lsn,confirmed_flush_lsn}" _null_ _null_ pg_get_replication_slots _null_ _null_ _null_ ));
52015201
DESCR("information about replication slots currently in use");
52025202
DATA(insert OID = 3786 ( pg_create_logical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 2 0 2249 "19 19" "{19,19,25,3220}" "{i,i,o,o}" "{slot_name,plugin,slot_name,xlog_position}" _null_ _null_ pg_create_logical_replication_slot _null_ _null_ _null_ ));
52035203
DESCR("set up a logical replication slot");

‎src/test/regress/expected/rules.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,8 +1416,9 @@ pg_replication_slots| SELECT l.slot_name,
14161416
l.active_pid,
14171417
l.xmin,
14181418
l.catalog_xmin,
1419-
l.restart_lsn
1420-
FROM (pg_get_replication_slots() l(slot_name, plugin, slot_type, datoid, active, active_pid, xmin, catalog_xmin, restart_lsn)
1419+
l.restart_lsn,
1420+
l.confirmed_flush_lsn
1421+
FROM (pg_get_replication_slots() l(slot_name, plugin, slot_type, datoid, active, active_pid, xmin, catalog_xmin, restart_lsn, confirmed_flush_lsn)
14211422
LEFT JOIN pg_database d ON ((l.datoid = d.oid)));
14221423
pg_roles| SELECT pg_authid.rolname,
14231424
pg_authid.rolsuper,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp