0

I noticed that PostgreSQL >= 10 does not generate WAL if there are no transactions. In previous versions, PostgreSQL generated WAL at the expiration of archive_timout, because it wrote some empty transactions.

I want PostgreSQL to still generate WAL if no one writes to it. Does anyone know how to do this in versions starting from 10?

2
  • Why would you want that? Jun 27, 2019 at 14:12
  • @a_horse_with_no_name to monitor streaming replication lag. Which is critical point to monitor in RDBMS. Mar 16, 2020 at 2:19

1 Answer 1

1

That must be because of commit 6ef2eba3f:

Skip checkpoints, archiving on idle systems.

Some background activity (like checkpoints, archive timeout, standby snapshots) is not supposed to happen on an idle system. Unfortunately so far it was not easy to determine when a system is idle, which defeated some of the attempts to avoid redundant activity on an idle system.

If you really need to have regular WAL activity, the cheapest way is to have a cron job that runs SELECT txid_current() regularly.

If you want to monitor replication, it is better to measure the lag in bytes, that is immune to this problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.