Rails 2.2.2: ActiveRecordの並列性 - 2.2.2の場合(失敗)

Rails 2.2.2でActiveRecordを並列に動かしてみる。
BarControllerは2.0.1の場合と同じ。
environment.rbにはconfig.threadsafe!を追加。

mongrelの出力


Expected C:/home/sugawara/work/foo/app/models/user.rb to define User
Expected C:/home/sugawara/work/foo/app/models/user.rb to define User
Expected C:/home/sugawara/work/foo/app/models/user.rb to define User
Expected C:/home/sugawara/work/foo/app/models/user.rb to define User
Expected C:/home/sugawara/work/foo/app/models/user.rb to define User
Expected C:/home/sugawara/work/foo/app/models/user.rb to define User


A copy of BarController has been removed from the module tree but is still active!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.-
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.-
You have a nil object when you didn't expect it!
You might have expected an instance of Array.

あ、やり方がまずかったかも…
Userクラスの読み込み関係のエラーはともかく、「A copy of BarController has…」はスレッドのコンテキストが死んだコントローラを参照しているんだろうなー。

うーん、並列にリクエストを送信しないと検証にならないかも。
あとはdevelopmentモードもまずかったかなぁ。


(追記)
productionモードだと、エラーが少し変わった。
SQLが発行されている様子もないけど…


Mysql::Error: Lock wait timeout exceeded; try restarting transaction: UPDATE `users` SET `updated_at` = '2008-11-26 04:05:55', `name` = '#: Yamada Hanako' WHERE `id` = 2could not obtain a database connection within 5 seconds. The max pool size is currently 5; consider increasing it.could not obtain a database connection within 5 seconds. The max pool size is currently 5; consider increasing it.could not obtain a database connection within 5 seconds. The max pool size is currently 5; consider increasing it.

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

あと2回目のリクエストが異様に遅い。MySQLまわりでロックがかかっているのかなぁ?
pool sizeを増やしたら動作変わるかなぁ?もう少し追ってみないと。