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

Commit7ba6e4f

Browse files
committed
Add monitoring function pg_last_xact_replay_timestamp.
Fujii Masao, with a little wordsmithing by me.
1 parent844ed5d commit7ba6e4f

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13551,6 +13551,9 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1355113551
<indexterm>
1355213552
<primary>pg_last_xlog_replay_location</primary>
1355313553
</indexterm>
13554+
<indexterm>
13555+
<primary>pg_last_xact_replay_timestamp</primary>
13556+
</indexterm>
1355413557

1355513558
<para>
1355613559
The functions shown in <xref
@@ -13605,6 +13608,22 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1360513608
the function returns NULL.
1360613609
</entry>
1360713610
</row>
13611+
<row>
13612+
<entry>
13613+
<literal><function>pg_last_xact_replay_timestamp()</function></literal>
13614+
</entry>
13615+
<entry><type>timestamp with time zone</type></entry>
13616+
<entry>Get timestamp of last transaction replayed during recovery.
13617+
This is the time at which the commit or abort WAL record for that
13618+
transaction was generated.
13619+
If no transactions have been replayed during recovery, this function
13620+
returns NULL. Otherwise, if recovery is still in progress this will
13621+
increase monotonically. If recovery has completed then this value will
13622+
remain static at the value of the last transaction applied during that
13623+
recovery. When the server has been started normally without recovery
13624+
the function returns NULL.
13625+
</entry>
13626+
</row>
1360813627
</tbody>
1360913628
</tgroup>
1361013629
</table>

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5604,6 +5604,24 @@ GetLatestXTime(void)
56045604
returnxtime;
56055605
}
56065606

5607+
/*
5608+
* Returns timestamp of latest processed commit/abort record.
5609+
*
5610+
* When the server has been started normally without recovery the function
5611+
* returns NULL.
5612+
*/
5613+
Datum
5614+
pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS)
5615+
{
5616+
TimestampTzxtime;
5617+
5618+
xtime=GetLatestXTime();
5619+
if (xtime==0)
5620+
PG_RETURN_NULL();
5621+
5622+
PG_RETURN_TIMESTAMPTZ(xtime);
5623+
}
5624+
56075625
/*
56085626
* Returns bool with current recovery mode, a global state.
56095627
*/

‎src/include/access/xlog_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ extern Datum pg_current_xlog_location(PG_FUNCTION_ARGS);
271271
externDatumpg_current_xlog_insert_location(PG_FUNCTION_ARGS);
272272
externDatumpg_last_xlog_receive_location(PG_FUNCTION_ARGS);
273273
externDatumpg_last_xlog_replay_location(PG_FUNCTION_ARGS);
274+
externDatumpg_last_xact_replay_timestamp(PG_FUNCTION_ARGS);
274275
externDatumpg_xlogfile_name_offset(PG_FUNCTION_ARGS);
275276
externDatumpg_xlogfile_name(PG_FUNCTION_ARGS);
276277
externDatumpg_is_in_recovery(PG_FUNCTION_ARGS);

‎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_NO201010301
56+
#defineCATALOG_VERSION_NO201011091
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3383,6 +3383,8 @@ DATA(insert OID = 3820 ( pg_last_xlog_receive_locationPGNSP PGUID 12 1 0 0 f f
33833383
DESCR("current xlog flush location");
33843384
DATA(insertOID=3821 (pg_last_xlog_replay_locationPGNSPPGUID12100ffftfv0025""_null__null__null__null_pg_last_xlog_replay_location_null__null__null_ ));
33853385
DESCR("last xlog replay location");
3386+
DATA(insertOID=3830 (pg_last_xact_replay_timestampPGNSPPGUID12100ffftfv001184""_null__null__null__null_pg_last_xact_replay_timestamp_null__null__null_ ));
3387+
DESCR("timestamp of last replay xact");
33863388

33873389
DATA(insertOID=2621 (pg_reload_confPGNSPPGUID12100ffftfv0016""_null__null__null__null_pg_reload_conf_null__null__null_ ));
33883390
DESCR("reload configuration files");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp