October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

PostgreSQL Reporting Replica: Stop Cleanup Cancellations Without Ignoring Primary Bloat

On a PostgreSQL reporting replica, hot_standby_feedback can prevent cleanup-related query cancellations at the cost of delayed dead-row cleanup and possible primary bloat. Replay-delay settings offer a different trade-off: more time for queries, slower WAL replay, and staler standby data.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

hot_standby_feedback can prevent PostgreSQL reporting queries from being canceled when vacuum cleanup conflicts with WAL replay, but it does so by delaying dead-row cleanup on the primary—which can cause table bloat. It is a targeted trade-off, not a way to prevent every standby cancellation. Whether to enable it depends on how your workload weighs completed reports against replica freshness, failover readiness, and primary-side storage.

Why PostgreSQL cancels queries on a reporting replica

The primary does not wait for standby queries before making and recording changes. The standby must replay those changes from write-ahead log (WAL), and a WAL record can conflict with a query running against the standby. For example, vacuum cleanup may remove a row version that a standby query’s snapshot could still need, or affect a page the query is accessing. PostgreSQL can delay replay for a configured period; if the conflict remains, it cancels the query so replay can proceed. PostgreSQL’s hot-standby documentation describes these conflicts and the available delay behavior.

As an Amazon Associate I earn from qualifying purchases.

Vacuum cleanup is a common cause, but not the only one. Primary-side DDL that needs an access-exclusive lock, dropping a database, or dropping a tablespace can also conflict with standby activity. Vacuum can also produce visibility-map conflicts affecting index-only scans, even when no old row versions need cleanup. The PostgreSQL documentation lists these conflict types.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What hot_standby_feedback changes

Set hot_standby_feedback on the standby. When enabled, the standby sends information about queries in progress to its upstream server so that cleanup does not remove row versions those queries may need. In cascading replication, feedback is forwarded upstream. PostgreSQL 18 documents the setting as off by default, and says feedback is sent no more frequently than the configured wal_receiver_status_interval. Confirm the documentation for your deployed major version before relying on that default. PostgreSQL 18 replication settings

The benefit is specific: feedback can prevent cancellations caused by cleanup records. The cost is that cleanup of dead rows can be delayed on the primary, which may cause bloat for some workloads. It does not prevent cancellations caused by DDL or every other conflicting WAL action. The PostgreSQL 18 parameter reference describes this trade-off.

How replay-delay settings differ

max_standby_streaming_delay controls how long a standby may delay applying streamed WAL before canceling conflicting queries. PostgreSQL 18 documents a default of 30 seconds; -1 permits indefinite waiting. This is an allowance for applying WAL received from the primary, not a separate maximum runtime for each query. If earlier replay work has already used the allowance, a later conflicting query may have less time.

For WAL read from an archive, the corresponding setting is max_standby_archive_delay, also documented with a 30-second default in PostgreSQL 18. These are version-specific documented defaults, not universal recommendations. Check the reference for the PostgreSQL major version you run before changing settings. PostgreSQL 18 replication settings

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Longer delay settings can give long-running decision-support queries more time, but WAL replay stalls while the conflict is being tolerated. Other standby sessions may consequently see older data. For a standby whose main purpose is high availability, PostgreSQL advises relatively short delay settings so query-related stalls do not let the standby fall far behind. Hot-standby documentation

Choose based on reports, freshness, and primary cleanup

There is no universally correct setting. Assess the role of this specific standby and the cost of each failure mode:

  • Report completion: How disruptive are canceled reports? Can clients safely retry them, or do cancellations interrupt work that is expensive to restart?
  • Freshness and recovery: How stale can reporting data become while replay waits? Does the standby also need to remain ready for high availability?
  • Primary cleanup and storage: Can the primary tolerate delayed removal of dead row versions? How will operators detect whether table bloat is increasing?

If cleanup-related cancellations are the dominant problem and the primary can tolerate delayed cleanup, test hot_standby_feedback and monitor primary table behavior. If freshness or failover readiness matters more, keep replay delays appropriately constrained and accept or reduce exposure to long-running conflicts. If reports need more time, tune the relevant streaming or archive delay with the understanding that it slows replay; it does not grant every query its own runtime allowance. PostgreSQL’s hot-standby guidance recommends shorter delays for high-availability standbys.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Monitor cancellations alongside lag and table growth

On the standby, inspect pg_stat_database_conflicts for cancellation counts and conflict reasons. PostgreSQL also identifies pg_stat_database as a source of summary information. Evaluate a configuration change by correlating changes in standby conflicts with replica replay freshness and primary-side table growth; fewer cancellations alone do not show whether the overall trade-off is acceptable. PostgreSQL monitoring statistics

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.