Comments (3)
Can you provide a sample for this? We are facing a similar issue and wanted to tackle this also with better connection handling when running our own daemon with threaded workers. Thanks.
from queue_classic.
This results in this single connection adapter being re-used across all threads for all subsequent enqueue calls.
Is this a problem? pg
gem is quite thread-safe, as its underlying libpq
, connections created in one thread can be reused in another. AFAIK, activerecord pool works this way: thread returns connection to pool, another thread can take it. Moreover, queue_classic has mutex for queries.
There's possibility of building libpq
without thread safety, you can check PG::Connection.isthreadsafe
, but AFAIK this is rare.
Second, it is not the connection for the active thread and may actually be being used by another thread if that thread has checked the same one out of the pool.
What's the problem with pool? Queue_classic takes one connection from the pool and never checks out it back. Connections can be safely reused across threads.
What error messages you get? I encountered protocol errors because of reused PG connections, but in forked web server, because there were multiple PG::Connection
instances in different processes using single underlying socket created prior to to forking.
from queue_classic.
Closing as this is stale; @gfodor if you can share the code, I'd def check it out.
from queue_classic.
Related Issues (20)
- Wishlist for the next major revision HOT 2
- Using SKIP LOCKED on Postgres 9.5 HOT 16
- Recommended worker implementation HOT 1
- Missing queue_class:install generator HOT 6
- Passwords sometimes need to be URI encoded (and decoded!) HOT 1
- Add AR versions to generators for migrations HOT 2
- PG::ConnectionBadqc:work PQconsumeInput() connection not open HOT 13
- No Implicit coversion of Time into String HOT 1
- Is there anything like que-scheduler for queue_classic? HOT 1
- ActiveRecord connection sharing: connection is returned to the pool HOT 4
- [FAQ] queue classic and classic plus for production HOT 1
- ActiveRecord connection sharing: queue_classic cause rails application hang HOT 2
- Queue Classic crashes regularly with "PG::ConnectionBad: connection is closed"
- precompile fails with ruby 2.7 HOT 1
- PG::ConnectionBad: invalid connection option "tty" when using libpq5 from PostgreSQL 14 HOT 4
- Possibility of a release version? HOT 2
- Support for OracleSQL HOT 2
- Investigate PG 12+ CTE materialization
- How does `FOR NO KEY UPDATE SKIP LOCKED` handle workers running on different machines? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from queue_classic.