Git Product home page Git Product logo

Comments (3)

dup2 avatar dup2 commented on August 25, 2024

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.

kolen avatar kolen commented on August 25, 2024

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.

ukd1 avatar ukd1 commented on August 25, 2024

Closing as this is stale; @gfodor if you can share the code, I'd def check it out.

from queue_classic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.