Add query_wait_timeout to user settings #481
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
Add
query_wait_timeout
to user settings.Why
Given two (2) or more read replicas, we want to force the client to failover to a different replica if the replica it's currently trying to use is unresponsive.
This is added because PostgreSQL protocol does not support read timeouts: the client will wait forever until the server answers or TCP keep-alive will break the connection.
Why not use the global
query_wait_timeout
setting? We have two different kind of users, foreground traffic user and background traffic user. The foreground traffic user needs to failover as quickly as is reasonable/possible. The background user can and should wait until replica recovers. The background user tends to run heavier queries as well, so we don't want to move all that expensive traffic to a different read replica: we are prioritizing the foreground traffic.Why not implement
query_timeout
as well/instead? The assumption is if we can assign a query to a server, the server is healthy and will eventually return a result.Tests
Will write tests if proposed change is acceptable.