Should I have to call Sequel.connect in puma's on_worker_boot? #2318
rgalanakis
started this conversation in
General
Replies: 1 comment
-
Disconnecting in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As per https://github.com/jeremyevans/sequel/blob/e0c99f619ab7d8baed1d3aba56b0fadf4b43d930/doc/fork_safety.rdoc#puma-, I am disconnecting my database in before_fork (I need to access the database in the puma parent process to load models).
However, accessing a model database still segfaults in the PG gem, as would happen if before_fork was not being used.
I have ensured the
model.db.pool.size
is zero before making the database call- active connections are not being carried over to the worker.If I replace the model's database in on_worker_boot (
model.db = Sequel.connect(...)
), I do not get a segfault.This is a bit cumbersome because Sequel errors since it cannot replace
model.db
once it's already set/the models were loaded, but I can work around it.I'm wondering if I'm doing something wrong, or there is some stale state in Sequel#Database that isn't being reset on disconnect.
I was trying to create a tiny reproduction case, but cannot force a segfault to happen.
Sequel 5.93.0, sequel_pg 1.17.2, pg 1.5.9
Beta Was this translation helpful? Give feedback.
All reactions