加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何确保PostgreSQL驱动器是线程安全的

发布时间:2020-12-17 02:20:40 所属栏目:百科 来源:网络整理
导读:我想使用Sidekiq作为我的后台工作.但要求是gem依赖是线程安全的. 在他们的维基页面中,他们提到: Some gems can be troublesome: * pg (the postgres driver,make sure PG::Connection.isthreadsafe returns true) 我为PostgreSQL使用pg gem. 我的问题是:如
我想使用Sidekiq作为我的后台工作.但要求是gem依赖是线程安全的.

在他们的维基页面中,他们提到:

Some gems can be troublesome:

   * pg (the postgres driver,make sure PG::Connection.isthreadsafe returns true)

我为PostgreSQL使用pg gem.

我的问题是:如何将PG :: Connection.isthreadsafe更改为true?

解决方法

gem调用此c库调用:

PQisthreadsafe();

记录在这里:

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

相关文件是这样的:

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

因此,您需要重新编译libpg(或获取线程安全包,如果可用)以使其实际上是线程安全的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读