Edgewall Software
Modify

Opened 16 years ago

Closed 13 years ago

Last modified 13 years ago

#7663 closed defect (fixed)

All Tickets report (on this site): IntegrityError: duplicate key violates unique constraint "session_attribute_pk"

Reported by: anonymous Owned by: Jonas Borgström
Priority: normal Milestone: 0.12.3
Component: general Version: 0.11.7
Severity: major Keywords: session
Cc: Mitar Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Tried to run the All Tickets report and recieved this error.

How to Reproduce

While doing a GET operation on /report/1, Trac issued an internal error.

(please provide additional details here)

Request parameters:

{'id': u'1'}

System Information

Trac 0.11stable-r7537
Python 2.4.3 (#2, Oct 6 2006, 07:49:22)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)]
setuptools 0.6c7
psycopg2 2.0.5.1
Genshi 0.5.2dev-r908
Pygments 0.9
Subversion 1.3.2 (r19776)

Python Traceback

Traceback (most recent call last):
  File "/usr/local/virtualenv/lib/python2.4/site-packages/Trac-0.11stable_r7537-py2.4.egg/trac/web/main.py", line 424, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/virtualenv/lib/python2.4/site-packages/Trac-0.11stable_r7537-py2.4.egg/trac/web/main.py", line 223, in dispatch
    req.session.save()
  File "/usr/local/virtualenv/lib/python2.4/site-packages/Trac-0.11stable_r7537-py2.4.egg/trac/web/session.py", line 102, in save
    "VALUES(%s,%s,%s,%s)", attrs)
  File "/usr/local/virtualenv/lib/python2.4/site-packages/Trac-0.11stable_r7537-py2.4.egg/trac/db/util.py", line 57, in executemany
    return self.cursor.executemany(sql_escape_percent(sql), args)
  File "/usr/local/virtualenv/lib/python2.4/site-packages/Trac-0.11stable_r7537-py2.4.egg/trac/db/util.py", line 57, in executemany
    return self.cursor.executemany(sql_escape_percent(sql), args)
IntegrityError: duplicate key violates unique constraint "session_attribute_pk"


Attachments (1)

session.patch (1.6 KB ) - added by anonymous 14 years ago.
Session.py Patch for Trac .12.1

Download all attachments as: .zip

Change History (10)

comment:1 by Remy Blank, 16 years ago

Keywords: needinfo added

This is very weird. The exception happens while inserting session attributes into the session_attribute table. But:

  • The insertion is preceded by a DELETE of all attributes from the session, so there cannot be any stale records.
  • It should not be possible that the INSERT tries to insert two records with the same primary key, as this would mean that a dict has twice the same key.

Was this a one-time failure, or can it be reproduced?

comment:2 by Remy Blank, 16 years ago

#7302 reported the same error, and was closed as a duplicate. But I cannot find the original ticket, even with the given search string.

comment:3 by Christian Boos, 16 years ago

Component: report systemgeneral
Keywords: session added; needinfo removed
Milestone: 0.11.3
Severity: normalmajor
Version: 0.11-stable

The original ticket is #3563. I think we can use this ticket for the remaining related fixes, instead of reopening the former.

See also googlegroups:trac-users:b2ff1c0036363612

comment:4 by Jonas Borgström, 16 years ago

Owner: set to Jonas Borgström
Status: newassigned

comment:5 by Jonas Borgström, 16 years ago

Milestone: 0.11.30.11.2
Resolution: fixed
Status: assignedclosed

Fixed in [7652] and [7653].

comment:6 by anonymous, 14 years ago

Milestone: 0.11.20.12.3
Resolution: fixed
Status: closedreopened
Version: 0.11-stable0.12.1

We are reopening this ticket because change in #9104 reverted the fix in this defect. Our configuration is indicated below. In our performance tests of Trac 0.12.1, we found the following error occurring very frequently:

2011-03-25 12:28:40,128 Trac[main] ERROR: Internal Server Error: Traceback (most recent call last):

File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 511, in _dispatch_request File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 260, in dispatch File "build/bdist.linux-x86_64/egg/trac/web/session.py", line 88, in save File "build/bdist.linux-x86_64/egg/trac/db/api.py", line 77, in transaction_wrapper File "build/bdist.linux-x86_64/egg/trac/web/session.py", line 113, in delete_session_cookie File "build/bdist.linux-x86_64/egg/trac/db/util.py", line 85, in executemany

IntegrityError?: duplicate key value violates unique constraint "session_attribute_pk" IntegrityError?: duplicate key value violates unique constraint "session_attribute_pk"

We then modified the session.py to include the fix in this defect and it seems to have resolved the frequently occuring error mentioned above.

Rev 9262 was the last time we saw the fix since it was added in revision 7653. After that, in revision 9342, the fix is not present in the trunk. The fix is not present in the tags for .12, .12.1, .12.1rc1, .12.2, .12.2rc1, .12.2b1, ….

Attached is the patch for Trac .12.1 session.py.

by anonymous, 14 years ago

Attachment: session.patch added

Session.py Patch for Trac .12.1

comment:7 by Mitar, 13 years ago

Cc: Mitar added

comment:8 by Remy Blank, 13 years ago

Resolution: fixed
Status: reopenedclosed

I still don't understand how it is possible that a concurrent transaction manages to insert rows into the session_attribute table between the DELETE and the INSERT, which are in a transaction.

Nevertheless, I have re-added the workaround of [7652] in [10823]. On trunk, I catch the more specific IntegrityError ([10824]).

comment:9 by Stefan, 13 years ago

Version: 0.12.10.11.7

issue got reintroduced in 0.11.7 (see r9336 - #9104)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.