diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index c3ec97a0a6..0d2930c4b5 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -1631,28 +1631,27 @@ update_progress_txn_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, OutputPluginUpdateProgress(ctx, false); /* Pop the error context stack */ error_context_stack = errcallback.previous; } /* * Set the required catalog xmin horizon for historic snapshots in the current * replication slot. * - * Note that in the most cases, we won't be able to immediately use the xmin + * Note that we won't be able to immediately use the xmin * to increase the xmin horizon: we need to wait till the client has confirmed * receiving current_lsn with LogicalConfirmReceivedLocation(). */ void LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin) { - bool updated_xmin = false; ReplicationSlot *slot; bool got_new_xmin = false; slot = MyReplicationSlot; Assert(slot != NULL); SpinLockAcquire(&slot->mutex); /* @@ -1665,23 +1664,20 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin) /* * If the client has already confirmed up to this lsn, we directly can * mark this as accepted. This can happen if we restart decoding in a * slot. */ else if (current_lsn <= slot->data.confirmed_flush) { slot->candidate_catalog_xmin = xmin; slot->candidate_xmin_lsn = current_lsn; - - /* our candidate can directly be used */ - updated_xmin = true; } /* * Only increase if the previous values have been applied, otherwise we * might never end up updating if the receiver acks too slowly. */ else if (slot->candidate_xmin_lsn == InvalidXLogRecPtr) { slot->candidate_catalog_xmin = xmin; slot->candidate_xmin_lsn = current_lsn; @@ -1690,37 +1686,32 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin) * Log new xmin at an appropriate log level after releasing the * spinlock. */ got_new_xmin = true; } SpinLockRelease(&slot->mutex); if (got_new_xmin) elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin, LSN_FORMAT_ARGS(current_lsn)); - - /* candidate already valid with the current flush position, apply */ - if (updated_xmin) - LogicalConfirmReceivedLocation(slot->data.confirmed_flush); } /* * Mark the minimal LSN (restart_lsn) we need to read to replay all * transactions that have not yet committed at current_lsn. * * Just like LogicalIncreaseXminForSlot this only takes effect when the * client has confirmed to have received current_lsn. */ void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart_lsn) { - bool updated_lsn = false; ReplicationSlot *slot; slot = MyReplicationSlot; Assert(slot != NULL); Assert(restart_lsn != InvalidXLogRecPtr); Assert(current_lsn != InvalidXLogRecPtr); SpinLockAcquire(&slot->mutex); @@ -1730,23 +1721,20 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart } /* * We might have already flushed far enough to directly accept this lsn, * in this case there is no need to check for existing candidate LSNs */ else if (current_lsn <= slot->data.confirmed_flush) { slot->candidate_restart_valid = current_lsn; slot->candidate_restart_lsn = restart_lsn; - - /* our candidate can directly be used */ - updated_lsn = true; } /* * Only increase if the previous values have been applied, otherwise we * might never end up updating if the receiver acks too slowly. A missed * value here will just cause some extra effort after reconnecting. */ if (slot->candidate_restart_valid == InvalidXLogRecPtr) { slot->candidate_restart_valid = current_lsn; @@ -1768,24 +1756,20 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart confirmed_flush = slot->data.confirmed_flush; SpinLockRelease(&slot->mutex); elog(DEBUG1, "failed to increase restart lsn: proposed %X/%X, after %X/%X, current candidate %X/%X, current after %X/%X, flushed up to %X/%X", LSN_FORMAT_ARGS(restart_lsn), LSN_FORMAT_ARGS(current_lsn), LSN_FORMAT_ARGS(candidate_restart_lsn), LSN_FORMAT_ARGS(candidate_restart_valid), LSN_FORMAT_ARGS(confirmed_flush)); } - - /* candidates are already valid with the current flush position, apply */ - if (updated_lsn) - LogicalConfirmReceivedLocation(slot->data.confirmed_flush); } /* * Handle a consumer's confirmation having received all changes up to lsn. */ void LogicalConfirmReceivedLocation(XLogRecPtr lsn) { Assert(lsn != InvalidXLogRecPtr);