[openstack-dev] [Neutron] DB: transaction isolation and related questions
enikanorov at mirantis.com
Fri Nov 21 20:53:07 UTC 2014
> *You are 100% correct that setting the transaction isolation level to READ
> COMMITTED works in the retry loop*.
> I stand corrected, and humbled :) Please accept my apologies.
Thanks for letting me know :)
> One thing I did note, though, is that changing the isolation level of an
> *already-started transaction* does not change the current transaction's
> isolation level -- the new isolation level only takes effect once the
> previously started transaction is committed or rolled back. So, on line 107
> in your proposed patch here:
> From what I could find out in my research, the setting of the isolation
> level needs to be done *outside* of the session.begin() call, otherwise the
> isolation level will not take effect until that transaction is committed or
> rolled back.
You're right. Apparently I've misread sqlalchemy docs at some point. Now I
see I've understood them incorrectly.
Also, from some sqlalchemy code inspection I thought that default engine
isolation level is restored after current transaction is committed, but
it's not so as well.
> Of course, if SQLAlchemy is doing some auto-commit or something in the
> session, then you may not see this affect, but I certainly was able to see
> this in my testing in mysql client sessions... so I'm a little perplexed as
> to how your code works on already-started transactions. The documentation
> on the MySQL site backs up what I observed:
> "...the statement sets the default transaction level for all subsequent
> transactions performed within the current session."
That basically means that my patch effectively changes isolation level of
every connection that happens to be used for the session.
> All the best, and thanks for the informative lesson of the week!
Thank you for getting to the very bottom of it! :)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the OpenStack-dev