|
30 | 30 |
|
31 | 31 | #include "access/xact.h"
|
32 | 32 | #include "access/xlogutils.h"
|
| 33 | +#include "access/xlog_internal.h" |
33 | 34 | #include "fmgr.h"
|
34 | 35 | #include "miscadmin.h"
|
35 | 36 | #include "pgstat.h"
|
|
41 | 42 | #include "storage/proc.h"
|
42 | 43 | #include "storage/procarray.h"
|
43 | 44 | #include "utils/builtins.h"
|
| 45 | +#include "utils/injection_point.h" |
44 | 46 | #include "utils/inval.h"
|
45 | 47 | #include "utils/memutils.h"
|
46 | 48 |
|
@@ -1825,9 +1827,13 @@ LogicalConfirmReceivedLocation(XLogRecPtr lsn)
|
1825 | 1827 | {
|
1826 | 1828 | bool updated_xmin = false;
|
1827 | 1829 | bool updated_restart = false;
|
| 1830 | + XLogRecPtr restart_lsn pg_attribute_unused(); |
1828 | 1831 |
|
1829 | 1832 | SpinLockAcquire(&MyReplicationSlot->mutex);
|
1830 | 1833 |
|
| 1834 | + /* remember the old restart lsn */ |
| 1835 | + restart_lsn = MyReplicationSlot->data.restart_lsn; |
| 1836 | + |
1831 | 1837 | MyReplicationSlot->data.confirmed_flush = lsn;
|
1832 | 1838 |
|
1833 | 1839 | /* if we're past the location required for bumping xmin, do so */
|
@@ -1869,6 +1875,18 @@ LogicalConfirmReceivedLocation(XLogRecPtr lsn)
|
1869 | 1875 | /* first write new xmin to disk, so we know what's up after a crash */
|
1870 | 1876 | if (updated_xmin || updated_restart)
|
1871 | 1877 | {
|
| 1878 | +#ifdef USE_INJECTION_POINTS |
| 1879 | + XLogSegNo seg1, |
| 1880 | + seg2; |
| 1881 | + |
| 1882 | + XLByteToSeg(restart_lsn, seg1, wal_segment_size); |
| 1883 | + XLByteToSeg(MyReplicationSlot->data.restart_lsn, seg2, wal_segment_size); |
| 1884 | + |
| 1885 | + /* trigger injection point, but only if segment changes */ |
| 1886 | + if (seg1 != seg2) |
| 1887 | + INJECTION_POINT("logical-replication-slot-advance-segment"); |
| 1888 | +#endif |
| 1889 | + |
1872 | 1890 | ReplicationSlotMarkDirty();
|
1873 | 1891 | ReplicationSlotSave();
|
1874 | 1892 | elog(DEBUG1, "updated xmin: %u restart: %u", updated_xmin, updated_restart);
|
|
0 commit comments