Re:Odyssey – Scalable PostgreSQL connection pooler
by needusername on Wednesday May 30, 2018 @02:49PM
(#17190485)
How does this work? I always assumed that you can have only one transaction open per session/connection (yes there are subtransaction but I don't see how these could be used for multiplexing independent transaction over the same session.).
[ Parent
| on HN ]
Re:Odyssey – Scalable PostgreSQL connection pooler
by sudhirj on Wednesday May 30, 2018 @03:20PM
(#17190807)
Can't multiplex transactions, but if you're doing long running work inside transactions you have bigger problems.
The Rails will checkout a connection for you, but it won't necessarily start a transaction if you don't ask it to. Think there's some magic involved there, but generally transactions don't start unless necessary or they're initiated by code.
Re:Odyssey – Scalable PostgreSQL connection pooler
by needusername on Thursday May 31, 2018 @12:24AM
(#17193937)
Uh oh. I naturally assumed Rails runs every request in a transaction because that's obviously the default you want.
Re:Odyssey – Scalable PostgreSQL connection pooler
by sudhirj on Thursday May 31, 2018 @01:24AM
(#17194159)
Not really. Though this should be trivial to do - just start and commit in the base controller life cycle hooks - I would never want or recommend it as he default. Too many things can go wrong with out of hand work, sequencing, assuming that hooks will happen when you do call save methods etc.
Re:Odyssey – Scalable PostgreSQL connection pooler
by needusername on Friday June 01, 2018 @01:14AM
(#17202772)
Why would you not have that as a default? What things can go wrong? Not having it means you have to think about transactions in every method or you accept database inconsistency.