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

Added healthy flag to ConnectionPool #816

Merged
merged 2 commits into from
Mar 8, 2019

Conversation

gshively11
Copy link
Contributor

Branched from #808, as those changes are critical for us. We can rebase/resubmit another PR if/when #808 is merged.

  • ConnectionPool starts out as healthy
  • If the internal pools connections drop to 0, and a createPool call
    fails, then the ConnectionPool will be flagged as unhealthy (healthy =
    false)
  • If an unhealthy ConnectionPool is able to successfully call
    createPool, then the ConnectionPool will be reflagged as healthy
    (healthy = true)
  • This allows applications to decide how to deal with unhealthy
    ConnectionPools (recreate, check for new config, failover, etc).

Copy link
Collaborator

@dhensby dhensby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this healthyPool flag and I think it's implemented well.

lib/base.js Outdated Show resolved Hide resolved
@willmorgan
Copy link
Collaborator

Logic sounds great! 👍

@dhensby dhensby force-pushed the pool-health branch 2 times, most recently from 738458c to 4d3ded2 Compare March 1, 2019 12:54
@dhensby dhensby added this to the 6.0 milestone Mar 4, 2019
@gshively11
Copy link
Contributor Author

I should get back on track with this tomorrow

- ConnectionPool starts out as unhealthy until a connection is established
- If the internal pools connections drop to 0, and a createPool call
fails, then the ConnectionPool will be flagged as unhealthy (healthy =
false)
- If an unhealthy ConnectionPool is able to successfully call
createPool, then the ConnectionPool will be reflagged as healthy
(healthy = true)
- This allows applications to decide how to deal with unhealthy
ConnectionPools (recreate, check for new config, failover, etc).
@dhensby
Copy link
Collaborator

dhensby commented Mar 7, 2019

@gshively11 I've rebased this for you on top of the latest 6.0 work. I've also implemented the feedback and updated the changelog

@gshively11
Copy link
Contributor Author

Appreciate the help! Small piece of feedback though, the force pushing makes things a little rough for collaboration. If squash+merge is used when merging PRs, the history in the PR can be messy and thus doesn't need a force push on the PR branch.

Will test out the changes here shortly...

@dhensby
Copy link
Collaborator

dhensby commented Mar 7, 2019

Thanks for the feedback. My approach is never to squash + merge because you loose the meaningful history of the PR. The PR branches are free for history re-writing because they are a candidate to go in and should be in as clean a state as possible at merge time.

If someone's re-written history on a shared branch you can tell by running a git fetch and then seeing if you're in a diverged state. simply git reset origin/[branchname] to get back in-line and on you go.

Your work was also based on commits that were written out of history so it couldn't have gone in without a rebase anyway or we'd have merged in a bunch of bad commits.

@gshively11
Copy link
Contributor Author

Cursory tests look good, now I need to write up an integration test suite for making sure the healthy/failover detection works in our wrapper, but I think this should be good to merge.

Re: the squash + merge, difference in philosophy I guess, no biggie. I like master having a clean, 1 commit per PR merge, and then you can always go look at the PRs for the detailed, unsquashed history, so you're never really losing the history of the PR. If you force-push/rebase in the PR, you're technically losing the history of the evolution of the PR.

@dhensby
Copy link
Collaborator

dhensby commented Mar 7, 2019

Cursory tests look good, now I need to write up an integration test suite for making sure the healthy/failover detection works in our wrapper, but I think this should be good to merge.

great, you'll need the take the PR out of draft mode - I can't seem to do that!

@gshively11 gshively11 marked this pull request as ready for review March 7, 2019 17:48
@willmorgan willmorgan merged commit e4d3730 into tediousjs:master Mar 8, 2019
@gshively11 gshively11 deleted the pool-health branch March 8, 2019 16:06
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.

3 participants