#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)
Change History (10)
comment:1 by , 16 years ago
Keywords: | needinfo added |
---|
comment:2 by , 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 , 16 years ago
Component: | report system → general |
---|---|
Keywords: | session added; needinfo removed |
Milestone: | → 0.11.3 |
Severity: | normal → major |
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.
comment:4 by , 16 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:5 by , 16 years ago
Milestone: | 0.11.3 → 0.11.2 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
comment:6 by , 14 years ago
Milestone: | 0.11.2 → 0.12.3 |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
Version: | 0.11-stable → 0.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.
comment:7 by , 14 years ago
Cc: | added |
---|
comment:8 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
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 , 13 years ago
Version: | 0.12.1 → 0.11.7 |
---|
This is very weird. The exception happens while inserting session attributes into the
session_attribute
table. But:DELETE
of all attributes from the session, so there cannot be any stale records.INSERT
tries to insert two records with the same primary key, as this would mean that adict
has twice the same key.Was this a one-time failure, or can it be reproduced?