diff options
author | Pavan Deolasee | 2018-05-18 09:30:36 +0000 |
---|---|---|
committer | Pavan Deolasee | 2018-05-21 06:28:47 +0000 |
commit | 9a2505daa86a2e4c3525daca0d8e95d0a6a27a31 (patch) | |
tree | 880151a0c2c3ded68a87aaf694daca8d1fc05058 | |
parent | d2e36d864699c8b43e0205bfcc04f7ffb8cd6f14 (diff) |
Fix broken implementation of recovery to barrier.
Per report from Hengbing, the current implementation of PITR recovery to a
BARRIER failed to correctly stop at the given recovery_target_barrier. It seems
there are two bugs here. 1) we failed to write the XLOG record correctly and 2)
we also failed to mark the end-of-recovery upon seeing the XLOG record during
the recovery.
Fix both these problems and also fix pg_xlogdump in passing to ensure we can
dump the BARRIER XLOG records correctly.
-rw-r--r-- | src/backend/access/transam/xlog.c | 27 | ||||
-rw-r--r-- | src/backend/pgxc/barrier/barrier.c | 4 |
2 files changed, 16 insertions, 15 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d43ff75575..cde89f80a2 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5754,8 +5754,9 @@ recoveryStopsBefore(XLogReaderState *record) (record_info == XLOG_BARRIER_CREATE)) { ereport(DEBUG2, - (errmsg("checking if barrier record matches the target " - "barrier"))); + (errmsg("checking if barrier record (%s) matches the target " + "barrier (%s)", + recordBarrierId, recoveryTargetBarrierId))); if (strcmp(recoveryTargetBarrierId, recordBarrierId) == 0) stopsAtThisBarrier = true; } @@ -5791,17 +5792,6 @@ recoveryStopsBefore(XLogReaderState *record) recoveryStopXid, timestamptz_to_str(recoveryStopTime)))); } -#ifdef PGXC - else if (stopsAtThisBarrier) - { - recoveryStopTime = recordXtime; - ereport(LOG, - (errmsg("recovery stopping at barrier %s, time %s", - recoveryTargetBarrierId, - timestamptz_to_str(recoveryStopTime)))); - return true; - } -#endif else { ereport(LOG, @@ -5810,6 +5800,17 @@ recoveryStopsBefore(XLogReaderState *record) timestamptz_to_str(recoveryStopTime)))); } } +#ifdef PGXC + else if (stopsAtThisBarrier) + { + recoveryStopTime = recordXtime; + ereport(LOG, + (errmsg("recovery stopping at barrier %s, time %s", + recoveryTargetBarrierId, + timestamptz_to_str(recoveryStopTime)))); + return true; + } +#endif return stopsHere; } diff --git a/src/backend/pgxc/barrier/barrier.c b/src/backend/pgxc/barrier/barrier.c index 0fe377a4a4..a06b2d9590 100644 --- a/src/backend/pgxc/barrier/barrier.c +++ b/src/backend/pgxc/barrier/barrier.c @@ -120,7 +120,7 @@ ProcessCreateBarrierExecute(const char *id) XLogRecPtr recptr; XLogBeginInsert(); - XLogRegisterData((char *) &id, strlen(id) + 1); + XLogRegisterData((char *) id, strlen(id) + 1); recptr = XLogInsert(RM_BARRIER_ID, XLOG_BARRIER_CREATE); XLogFlush(recptr); } @@ -413,7 +413,7 @@ ExecuteBarrier(const char *id) XLogRecPtr recptr; XLogBeginInsert(); - XLogRegisterData((char *) &id, strlen(id) + 1); + XLogRegisterData((char *) id, strlen(id) + 1); recptr = XLogInsert(RM_BARRIER_ID, XLOG_BARRIER_CREATE); XLogFlush(recptr); |