This project is archived and is in readonly mode.
PostgreSQL escape methods aren't thread-safe (in Ruby 1.8)
Reported by Eugene Pimenov | September 20th, 2009 @ 11:39 AM | in 3.0.2
PostgreSQL adapter has code like that
def query_string(s)
self.class.instance_eval do
define_method(:query_string) do |s|
@connection.query_string(s)
end
end
query_string(s)
end
In ruby 1.8 it's not thread-safe because block's argument is bound to method's argument. So when you call this method in several threads it could return value you aren't expecting.
- http://pastie.org/623434 triggers the bug instantaneously (attached as wierd_test.rb)
- http://pastie.org/623444 triggers the bug with ActiveRecord (attached as test.rb).
Patch renames methods' arguments original_value, so blocks' arguments are no longer bound to them.
Comments and changes to this ticket
-
CancelProfileIsBroken September 25th, 2009 @ 11:58 AM
- Tag changed from ruby 1.8.7, 1.8.6, activerecord, adapters, patch, postgres, postgresql to ruby 1.8.7, 1.8.6, activerecord, adapters, bugmash, patch, postgres, postgresql
- Assigned user cleared.
-
Rizwan Reza January 20th, 2010 @ 11:51 AM
- Milestone cleared.
- Tag changed from ruby 1.8.7, 1.8.6, activerecord, adapters, bugmash, patch, postgres, postgresql to ruby 1.8.7, 1.8.6, activerecord, adapters, patch, postgres, postgresql
- State changed from new to verified
- Assigned user set to Pratik
Applies cleanly to master and 2-3-stable.
-
Rizwan Reza March 27th, 2010 @ 01:31 PM
- Assigned user changed from Pratik to Yehuda Katz (wycats)
Can be applied to master cleanly. All tests pass on AR suite.
-
Repository March 29th, 2010 @ 02:04 AM
- State changed from verified to resolved
(from [fc6746fc3f102029020e3893cde5480a58470d59]) PostgreSQL adapter: escape_bytea, quote_string and unescape_bytea aren't thread-safe in Ruby 1.8 [#3237 state:resolved]
Signed-off-by: wycats wycats@gmail.com
http://github.com/rails/rails/commit/fc6746fc3f102029020e3893cde548... -
Repository April 24th, 2010 @ 11:03 PM
(from [cec44f58388755dec8d4e739e0a3bc3263a7fe3f]) PostgreSQL adapter: escape_bytea, quote_string and unescape_bytea aren't thread-safe in Ruby 1.8 [#3237 state:resolved]
Signed-off-by: wycats wycats@gmail.com
http://github.com/rails/rails/commit/cec44f58388755dec8d4e739e0a3bc...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 3237 PostgreSQL escape methods aren't thread-safe (in Ruby 1.8) (from [cec44f58388755dec8d4e739e0a3bc3263a7fe3f]) Postgre...
- 3237 PostgreSQL escape methods aren't thread-safe (in Ruby 1.8) (from [fc6746fc3f102029020e3893cde5480a58470d59]) Postgre...