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

Emit queue event #716

Closed
wants to merge 5 commits into from
Closed

Emit queue event #716

wants to merge 5 commits into from

Conversation

rwky
Copy link
Contributor

@rwky rwky commented Jan 18, 2014

When a connection pool has to queue a connection then emit a queue event with the number of connections in the queue as the first argument.

When a connection pool has to queue a connection then emit a queue event with the number of connections in the queue as the first argument
@felixge
Copy link
Collaborator

felixge commented Jan 19, 2014

Thx. Needs docs. Also curious to hear what the use case is.

@rwky
Copy link
Contributor Author

rwky commented Jan 20, 2014

I've added docs to the readme, let me know if you need more.
There are two use cases I found this useful for.

  1. I was running some batch queries every 0.5 seconds, some of the batches would take longer than 0.5 seconds to run so the connection pool would be used. This was causing a bottle neck when the queue hit the default 10. Listening for the queue event made it easy to find out when I was hitting the limit and then increase it.

  2. This was really just me being forgetful, but I forgot to release the connections which caused the queue to fill up and then the batch process would just hang. Watching the queue event makes it easy to see why it's hanging and go 'oops I'm not releasing connections'

@sidorares
Copy link
Member

does it have to be an event? Maybe have some public pool methods like 'queueSise', 'numActiveConnections' etc?

@rwky
Copy link
Contributor Author

rwky commented Jan 20, 2014

I find the event the most useful, otherwise I'd have to check the queue periodically at specific points in the app or with some hacky setInterval.

@pwlmaciejewski
Copy link

👍

@dougwilson dougwilson added this to the 2.5 milestone Jul 14, 2014
@dougwilson dougwilson closed this in 6413790 Sep 7, 2014
seangarner pushed a commit to seangarner/node-mysql that referenced this pull request May 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

5 participants