有没有办法增加 ActiveRecord 的连接超时?
当我有超过 25 个线程且池大小为 5 时,我不断收到此错误。
(ActiveRecord::ConnectionTimeoutError) "could not obtain a database connection within 5 seconds (waited 5.000144774 seconds). The max pool size is currently 3; consider increasing it."
如果没有增加连接超时的方法,确保线程尽快使用连接的最佳方法是什么?
最佳答案
根据 docs您应该在数据库配置文件中设置“checkout_timeout”选项。
checkout_timeout: number of seconds to block and wait for a connection before giving up and raising a timeout error (default 5 seconds).
关于ruby-on-rails - 如何增加 ActiveRecord 连接超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16028121/