Don’t try to connect to blacklisted resources #202
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.
Hello! Here is the PR for not trying to connect to a blacklisted host.
Here is some background:
When using makara with a master/slave setup and the master goes down, we would like to have the connection timeout and the master blacklisted for a period of time. Just handle reads from the slave and writes will fail. This is useful when AWS or other db providers decide to cycle machines; for instance applying meltdown patch. Another use case for this is to be able to resize your master db at any point without significant down time, assuming you are read heavy. We are 90% reads in this case and cannot go down for a db resize. We would like to continue reading from the slave and serving 90% of our requests.
Our database.yml file looks like this with this patch:
The first request to hit the DB will take 1 second, for client connection timeout from postgres, plus the normal request time to return. The problem seems to occur when calling https://github.com/taskrabbit/makara/blob/master/lib/makara/pool.rb#L131
connection_made?
That calls_makara_connected?
which will call_makara_connection
which will try to connect to the db even if it is blacklisted already.