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"

  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.

Thanks; I have installed the patch.

I don't quite understand what is going on.  I think the error happened
on the INSERT, but on reflection this is because of two similar
transactions:

  delete foo if foo is there
  insert bar

and the point is that the delete doesn't fail.  Your patch is to try to
catch the delete failing, and skip the insert.  But I would expect the
delete to return DELETE 0, which doesn't seem like an error:

trac-redacted2=# delete from session_attribute where sid = 'no-such-user';
DELETE 0


Is this because we are running read committed instead of full
transactions?  We are having the second transaction to do the insert see
database state from before the first insert is committed.

Attachment: pgpsSJDde0o4y.pgp
Description: PGP signature

Reply via email to