I am experiencing perplexing page level locking problems when using Rails/Windows/MSSQL
The following code results in piles ( ~80 in this case ) of active page locks which then prevent any updates on the table until the mssql process is killed. I have another part of the application that uses find_by_sql with several joins and it exhibits similar problems. I have run the code under WebBrick/Mongrel/FastCGI and it happens in each case.
Here is the code ( models and rails environment listed at the bottom )
Registration.find( :all, :conditions => [ "trip.dateStart > ? ", '2007-01-01' ] , :include => [ :trip, :constituent ] )
The pertinent lock info for one of the locks is:
Type: PAG Resource: 1:1033 ( each lock has a different fileid:pagenumber here ) Mode: IS Status: GRANT ObjName: con IndID: 0 IndName: con
If i tweak the statement a bit - there are NO locks:
In this case get rid of the second associated model and there are no locks Registration.find( :all, :conditions => [ "trip.dateStart > ? ", '2007-01-01' ] , :include => [ :trip ] )
In this case get rid of the conditions and there are no locks Registration.find( :all, :include => [ :trip, :constituent ] )
Here are the models:
class Registration < ActiveRecord::Base set_table_name "register" set_primary_key "regID" belongs_to :constituent, :foreign_key => "conID" belongs_to :trip, :foreign_key => "tripID" end
class Constituent < ActiveRecord::Base set_table_name "con" set_primary_key "conID" end
class Trip < ActiveRecord::Base set_table_name "trip" set_primary_key "tripID" end
The only thing that is probably out of the ordinary is that we are dealing with a legacy DB and have to manually set all the table names and primary keys.
Rails Environment: Ruby version 1.8.4 (i386-mswin32) RubyGems version 0.8.11 Rails version 1.1.6 Active Record version 1.14.4 Action Pack version 1.12.5 Action Web Service version 1.1.6 Action Mailer version 1.2.5 Active Support version 1.3.1
Thanks for any help.
Dan