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

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

概述我想使用Sidekiq作为我的后台工作.但要求是gem依赖是线程安全的. 在他们的维基页面中,他们提到: Some gems can be troublesome: * pg (the postgres driver, make sure PG::Connection.isthreadsafe returns true) 我为PostgreSQL使用pg gem. 我的问题是:如何将PG 我想使用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(或获取线程安全包,如果可用)以使其实际上是线程安全的.

总结

以上是内存溢出为你收集整理的ruby-on-rails – 如何确保PostgreSQL驱动器是线程安全的全部内容,希望文章能够帮你解决ruby-on-rails – 如何确保PostgreSQL驱动器是线程安全的所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1275217.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-08
下一篇2022-06-08

发表评论

登录后才能评论

评论列表(0条)

    保存