Rails 3.1 线程安全被破坏

发布于 2024-12-07 03:35:55 字数 577 浏览 0 评论 0原文

或者类似的东西。我已将多个应用程序从 Rails 3.0 升级到 Rails 3.1。它们在启用多线程选项的 Thin 上运行,它们都配置了线程安全!。在 Rails 3.0 中工作得很好。但在 3.1 中,经过几次请求后,速度开始变慢。经过几次请求后,页面挂起 N 秒(其中 N 是我的数据库超时),并且我收到此错误:

ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5 seconds.  The max pool size is currently 5; consider increasing it.):

过去已经找到了 5 和 5 的默认值,并且应该仍然没问题。增加它们并不能解决问题,尽管需要更长的时间才能显现出来。我应该强调,在这些时间里,我是唯一访问这些应用程序的人。当我将 Thin 降为单线程模式时,一切都按预期工作。

MySQL、SQLite、Ruby 1.8.7 和 Ruby 1.9.2 会出现这种情况。薄不变。我能找到的唯一变量是升级到 Rails 3.1。我能做些什么吗,或者这是 Rails 中的回归?

Or something like that. I've upgraded several apps from Rails 3.0 to Rails 3.1. They are are running on Thin with the multithreaded option enabled, they are all configured with threadsafe!. Worked great in Rails 3.0. But in 3.1, after a few requests, things start slowing down. After a few more requests, the pages hangs for N seconds (where N is my db timeout) and I get this error:

ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5 seconds.  The max pool size is currently 5; consider increasing it.):

Those default values of 5 and 5 have been find in the past and should still be fine. Also increasing them does not fix the problem, though it takes a little longer to manifest. I should stress that during these times I have been the only one accessing the apps. When I drop Thin down to single-threaded mode, everything works as expected.

This occurs with MySQL, SQLite, Ruby 1.8.7 and Ruby 1.9.2. Thin is unchanged. The only variable I can find is the upgrade to Rails 3.1. Is there anything I can do, or is this a regression in Rails?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的心境我的脸 2024-12-14 03:35:56

看起来这是一个错误。有一个补丁和拉取请求。希望 Rails 能够将其合并进来。在那之前,多线程 Rails 应用程序将无法在 Thin 上运行。

https://github.com/rails/rails/pull/1670

Looks like this is a bug. There's a patch and pull request for it. Hopefully Rails will merge it in. Until then, multi-threaded Rails apps won't work on Thin.

https://github.com/rails/rails/pull/1670

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文