-
Notifications
You must be signed in to change notification settings - Fork 180
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
PQsetClientEncoding() called without releasing the GVL during initialization #245
Comments
Original comment by danielnc (Bitbucket: danielnc, GitHub: danielnc). Hi @larskanis I'm not too familiar with bitbucket(I mostly use GitHub) Is there an easy way to install a gem directly from you commit or branch? Thanks |
Original comment by Lars Kanis (Bitbucket: larskanis, GitHub: larskanis). @danielnc You can use the latest gem prerelease either by:
or with bundler:
It's also possible now, to fetch and build the gem from a git repository:
|
Original comment by danielnc (Bitbucket: danielnc, GitHub: danielnc). Hi @larskanis Our process is still stuck Not sure if related to this issue or not Here is GDB thread dump Any ideas what might be causing this? https://gist.github.com/danielnc/58734c5673fa0da8d3d02eddf2184c36 |
Original comment by Michael Granger (Bitbucket: ged, GitHub: ged). @danielnc it looks like it's now giving up the GVL in both threads that are trying to connect, so when you say "Our process is still stuck" do you mean that it still blocks other Ruby threads? If you need the connect to be asynchronous from Ruby, you can use You can also set your own connection timeout using the |
Original comment by danielnc (Bitbucket: danielnc, GitHub: danielnc). @ged when I say our process is still stuck it still block other Ruby Threads. We don't need it to be async because we are using PgBouncer as a middleman Clients are able to connect but are stuck in the middle of running queries so I'm not 100% if this is another issue with pg |
Original comment by Chris Bandy (Bitbucket: cbandy, GitHub: cbandy). I see a |
Original comment by Lars Kanis (Bitbucket: larskanis, GitHub: larskanis). @danielnc I've changed the part for setting the default_encoding to use the asynchronous libpq interface: a646a1394e Therefore if a thread opens a new connection and blocks at "SET client_encoding", it will still respond to signals (Process.kill) and exception events (Thread#raise). Previously the blocking threads did not respond to such events (but all other threads did respond). You should also make sure, that when working with signals, you're using I've pushed another pre-release on rubygems.org with the latest change. Could you please try it out? |
Original comment by danielnc (Bitbucket: danielnc, GitHub: danielnc). @larskanis this did not fix the issue where our connections just lingers on pgbouncer(although threads are now responsive to signals) I've opened an issue(pgbouncer/pgbouncer#143) to try to understand why I'm getting FATAL and WARNING messages. I'm assuming that this might be the cause of clients being stuck while waiting to receive results from pgbouncer I think we can close this issue since at least now threads are responsive I'll have to try to investigate further since we cannot find a reason why our clients cannot work well with pgbouncer Thanks |
PQsetClientEncoding() is also called within PG::Connection.new which could block due to network delay. This fixes bitbucket issue ged#245 .
Original report by danielnc (Bitbucket: danielnc, GitHub: danielnc).
I think I've spotted a bug with 0.18.4
We are scaling out our database and using several sidekiq workers.
We are currently using postgresql 9.4 with pgbouncer to allow more light-weight connections
Rails 3.2 + Latest version of Sidekiq + pg 0.18.4
Whenever we exhaust pgbouncer real connections Sidekiq just hangs and wont even respond to TTIN commands. I have to force kill sidekiq process with -9
This happens on our production environment whenever we reach our 250 real connections and hit our database really heavy
An easy way to reproduce locally is to create 1 sidekiq process with 25 threads and 1 real(server connection) pgbouncer connection(50000 client connections allowed)
Here is my local gdb output(osx) our production environments(centos) behave the same way
https://gist.github.com/danielnc/81e27b8b4012a41bc795e01a5b36db99
Here is my pgbouncer.ini config to make it easy to reproduce
https://gist.github.com/danielnc/3ce76c8a8957e8a52f65c9224839e670
I've created a minimal rails 4.2 app with sidekiq and I'm able to reproduce the same behaviour so this is doesn't seems to be a rails specific version issue
pg is not releasing the GVL before making a network call.
PQsetClientEncoding()
is currently called without releasing the GVL while the PG::Connection initialisation. It should either be GVL aware or use the asynchronous libpq interface.Thanks
The text was updated successfully, but these errors were encountered: