How to make sure PostgreSQL is thread safe

I would like to use Sidekiq for my background work. But the requirement is that gem dependencies are thread safe.

In their wiki page, they mention:

  Some gems can be troublesome: * pg (the postgres driver, make sure PG::Connection.isthreadsafe returns true) 

I am using pg gem for PostgreSQL.

My question is: how do I change PG :: Connection.isthreadsafe to true?

+4
source share
1 answer

Gem calls this c library call:

PQisthreadsafe();

Documented here:

http://www.postgresql.org/docs/8.2/static/libpq-threading.html

The relevant documentation is as follows:

libpq is reentrant and thread safe if the configure command the --enable-thread-safety option was used when the PostgreSQL distribution was built.

So, you will need to recompile libpg (or get the threadafe package, if one is available) to make it virtually unsafe.

+3
source

Source: https://habr.com/ru/post/1469059/


All Articles