@open_transactions initialized with nil

dbreuer
2009-02-13T09:07:28Z

Hi Folks,

while using the Masochism plugin for Master-Slave database setup
(http://github.com/technoweenie/masochism/tree/master) I discovered a
problem
with starting transactions in the ConnectionProxy:

79      def transaction(start_db_transaction = true, &block)
80        with_master(start_db_transaction) do
81          master.transaction(start_db_transaction, &block)
82        end
83      end

Despite there is a problem in Masochism itself I discovered there is
(at least
for me) a strange behavior in the AbstractAdapter within ActiveRecord:

158        def decrement_open_transactions
159          @open_transactions -= 1
160        end

In some cases there is the decrement_open_transactions method called
for
connections with an uninitialized @open_transactions variable (the
value is
nil). I tracked this down to the initialize method in the same class.
Besides
other initializations the @open_transactions variable is not
initialized:

37        def initialize(connection, logger = nil) #:nodoc:
38          @connection, @logger = connection, logger
39          @runtime = 0
40          @last_verification = 0
41          @query_cache_enabled = false
42        end

Is there a reason to init the variable via the attribute accessor?

149        def open_transactions
150          @open_transactions ||= 0
151        end

Thanks in advance!

Dirk


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---