Greg Troxel wrote:
> Occasionally ticket queries fail with a database error:
>
> Oops#
> Trac detected an internal error:
>
> OperationalError: ERROR: duplicate key violates unique constraint
> "session_attribute_pk"
Hi Greg,
It appears to be a small window of opportunity for two concurrent
requests from a single user to cause this constraint violation in
session.py.
I have attached a patch which I think will fix this which I'm currently
testing. If you have the opportunity please give it a try as well.
/ Jonas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Index: trac/web/session.py
===================================================================
--- trac/web/session.py (revision 7647)
+++ trac/web/session.py (working copy)
@@ -93,8 +93,15 @@
(self.sid, e))
if self._old != self:
attrs = [(self.sid, authenticated, k, v) for k, v in self.items()]
- cursor.execute("DELETE FROM session_attribute WHERE sid=%s",
- (self.sid,))
+ try:
+ cursor.execute("DELETE FROM session_attribute WHERE sid=%s",
+ (self.sid,))
+ # The session variables might already have been updated by a
+ # concurrent request.
+ except Exception, e:
+ db.rollback()
+ self.env.log.warning('Attributes for session %s already
updated: %s' %
+ (self.sid, e))
self._old = dict(self.items())
if attrs:
cursor.executemany("INSERT INTO session_attribute "