Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Background worker not starting on replicas #48

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

tacho
Copy link
Contributor

@tacho tacho commented Oct 24, 2024

The background worker that's responsible for log rotation doesn't start on the replica nodes, which results in all audit messages going to a single file until the server is restarted.

According to the PostgreSQL documentation, ConsistentState and RecoveryFinished are equivalent on the leader, and ConsistentState is enough on the hot replicas, meaning it should work for both node roles.

Excerpt from https://www.postgresql.org/docs/current/bgworker.html

bgw_start_time is the server state during which postgres should start the process; it can be one of BgWorkerStart_PostmasterStart (start as soon as postgres itself has finished its own initialization; processes requesting this are not eligible for database connections), BgWorkerStart_ConsistentState (start as soon as a consistent state has been reached in a hot standby, allowing processes to connect to databases and run read-only queries), and BgWorkerStart_RecoveryFinished (start as soon as the system has entered normal read-write state). Note the last two values are equivalent in a server that's not a hot standby. Note that this setting only indicates when the processes are to be started; they do not stop when a different state is reached.

The background worker that's responsible for log rotation doesn't start
on the replica nodes, which results in all audit messages going to a
single file until the server is restarted.

According to the PostgreSQL documentation, ConsistentState and
RecoveryFinished are equivalent on the leader, and ConsistentState is
enough on the hot replicas, meaning it should work for both node roles.
@fmbiete fmbiete merged commit 0ceae2e into fmbiete:main Oct 25, 2024
@tacho tacho deleted the fix-replica-bgw branch October 25, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants