Re: [Mailman-Developers] [Mailman-checkins] SF.net SVN: mailman: [8184] trunk/mailman/Mailman
Hi Barry, bwarsaw@users.sourceforge.net wrote:
Revision: 8184 http://svn.sourceforge.net/mailman/?rev=8184&view=rev Author: bwarsaw Date: 2007-03-29 22:09:36 -0700 (Thu, 29 Mar 2007)
Log Message: ----------- api_lock(): When locking the MailList object, tell the SQLAlchemy session to expire the object. This way, when the MailList attributes are next accessed, the ORM will reload them from the database, getting any new values possibly set in other processes.
This works better than trying to use always_refresh=True on the mapper, or trying to do a reload() because both of those approaches blow away locks. I'm not sure why this, but I suspect that it's because the identity map is handing us back a different object, rather than invalidating the object's attributes.
Modified Paths: -------------- trunk/mailman/Mailman/database/dbcontext.py trunk/mailman/Mailman/testing/test_handlers.py
Modified: trunk/mailman/Mailman/database/dbcontext.py =================================================================== --- trunk/mailman/Mailman/database/dbcontext.py 2007-03-27 06:35:12 UTC (rev 8183) +++ trunk/mailman/Mailman/database/dbcontext.py 2007-03-30 05:09:36 UTC (rev 8184) @@ -129,6 +129,7 @@
# Higher level interface def api_lock(self, mlist): + self.session.expire(mlist) # Don't try to re-lock a list if mlist.fqdn_listname in self._mlist_txns: return
Wow! Fix is so simple. I've done a test with this using two terminals: terminal A terminal B $ bin/withlist test $ bin/withlist test
m.description u'' m.Lock() m.description = 'test' m.Save() >>> m.Load() >>> m.description u'' m.Unlock() >>> m.Lock() >>> m.description u'test'
Mere Load() can't refresh the list attributes but needs Lock() to get them. A few problem remains like decorating the message where OutgoingRunner is used. This runner don't update the database so it doesn't use Lock() but only Load(). We should fix them to use Lock() (and Unlock()) to reload data. -- Tokio Kikuchi, tkikuchi@is.kochi-u.ac.jp http://weather.is.kochi-u.ac.jp/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Tokio,
On Mar 30, 2007, at 7:16 AM, Tokio Kikuchi wrote:
Wow! Fix is so simple.
I know! I was shocked too. :)
Mere Load() can't refresh the list attributes but needs Lock() to get them. A few problem remains like decorating the message where OutgoingRunner is used. This runner don't update the database so it doesn't use Lock() but only Load(). We should fix them to use Lock() (and Unlock()) to reload data.
Funny, I did probably the exact same test as you did. :)
You're right that the Lock() is necessary to refresh state, so it my
indeed be better to put this change on Load(), or to fix those few
other places to use Lock() to refresh. But I also worry that this
isn't a full solution ultimately.
The problem is that this will only refresh MailList objects. I'm
still trying to find time to port my PyCon changes back into the
trunk, and part of those changes begins to exchange the PickleType
columns for real tables. Refreshing the MailList I suspect won't
refresh those tables so we'll need to add each related table to the
refresh set. I'm going to try to contact the SQLAlchemy folks to see
if there isn't a more general, or better way, of doing what we're
trying to do here. There may not be though because istm that an
application still needs a way of clearly defining such reload
boundaries. Mailman's way is through MailList.Load()/.Lock()/.Unlock
(), which is tied to that class.
Still, it's important to be aware of this issue, so I'd like to get
the SA folks take on it.
Thanks for testing this out!
- -Barry
P.S. I'm still getting 3 failures in the test suite. You mentioned
it's because we're using different email packages. I'll try to
figure that out this weekend.
Cheers!
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin)
iQCVAwUBRgz+LnEjvBPtnXfVAQLVtgQAkKY2mK7SdiDVn587oM2O6N68MvvxohZv 7wFYZ7uOOt40gKT7YGTySstzuHe3tHC2V1LnxV0/jgQRQ4Qz73jhvQYaYnGO34qn kgUcBza8OmjxsOM466SjhG5aPRl0GcxENGP1t46+XrocqL4lE95jAdCn96BLz6lx FsO7lYpJIVw= =8mRh -----END PGP SIGNATURE-----
participants (2)
-
Barry Warsaw
-
Tokio Kikuchi