Ticket #9104 (closed defect: fixed)
Opened 2 years ago
Last modified 4 months ago
reuse of a closed cursor
| Reported by: | cboos | Owned by: | cboos |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.11.7 |
| Component: | web frontend | Version: | 0.11-stable |
| Severity: | normal | Keywords: | pysqlite |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
At least with PySqlite, it's not possible to reuse a cursor after a rollback has been performed on the connection it was created from.
2010-01-08 04:57:04,395 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
File "/usr/local/virtualenv-0.11/lib/python2.5/site-packages/Trac-0.11.7stable_r8997-py2.5.egg/trac/web/main.py", line 450, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/local/virtualenv-0.11/lib/python2.5/site-packages/Trac-0.11.7stable_r8997-py2.5.egg/trac/web/main.py", line 229, in dispatch
req.session.save()
File "/usr/local/virtualenv-0.11/lib/python2.5/site-packages/Trac-0.11.7stable_r8997-py2.5.egg/trac/web/session.py", line 100, in save
(self.sid,))
File "/usr/local/virtualenv-0.11/lib/python2.5/site-packages/Trac-0.11.7stable_r8997-py2.5.egg/trac/db/util.py", line 64, in execute
return self.cursor.execute(sql_escape_percent(sql), args)
File "/usr/local/virtualenv-0.11/lib/python2.5/site-packages/Trac-0.11.7stable_r8997-py2.5.egg/trac/db/sqlite_backend.py", line 80, in execute
result = PyFormatCursor.execute(self, *args)
File "/usr/local/virtualenv-0.11/lib/python2.5/site-packages/Trac-0.11.7stable_r8997-py2.5.egg/trac/db/sqlite_backend.py", line 59, in execute
args or [])
File "/usr/local/virtualenv-0.11/lib/python2.5/site-packages/Trac-0.11.7stable_r8997-py2.5.egg/trac/db/sqlite_backend.py", line 51, in _rollback_on_error
return function(self, *args, **kwargs)
ProgrammingError: Cannot operate on a closed cursor.
0.12 version of the same error:
2010-03-02 11:10:25,782 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 499, in _dispatch_request
dispatcher.dispatch(req)
File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 255, in dispatch
req.session.save()
File "build/bdist.linux-x86_64/egg/trac/web/session.py", line 88, in save
@with_transaction(self.env)
File "build/bdist.linux-x86_64/egg/trac/db/util.py", line 36, in transaction_wrapper
fn(dbtmp)
File "build/bdist.linux-x86_64/egg/trac/web/session.py", line 108, in delete_session_cookie
(self.sid,))
File "build/bdist.linux-x86_64/egg/trac/db/util.py", line 90, in execute
return self.cursor.execute(sql_escape_percent(sql), args)
File "build/bdist.linux-x86_64/egg/trac/db/sqlite_backend.py", line 77, in execute
result = PyFormatCursor.execute(self, *args)
File "build/bdist.linux-x86_64/egg/trac/db/sqlite_backend.py", line 56, in execute
args or [])
File "build/bdist.linux-x86_64/egg/trac/db/sqlite_backend.py", line 48, in _rollback_on_error
return function(self, *args, **kwargs)
ProgrammingError: Cannot operate on a closed cursor.
As discussed in ticket:9077#comment:4 point 2.
Attachments
Change History
Changed 2 years ago by cboos
- Attachment t9104-fix-operate-closed-cursor-r9282.diff added
comment:1 Changed 2 years ago by cboos
Please test and review the above patch.
For some background on the problem, see also ticket:9077#comment:10.
comment:2 Changed 2 years ago by cboos
Or alternatively, we could just return when a concurrent save was detected (#3563), see t9104-fix-operate-closed-cursor-r9282.2.diff.
Changed 2 years ago by cboos
- Attachment t9104-fix-operate-closed-cursor-r9282.2.diff added
alternative solution, returning earlier
comment:3 Changed 2 years ago by cboos
- Resolution set to fixed
- Status changed from new to closed
First alternative picked for 0.11-stable in r9336, on trunk I'll do the second one.
comment:4 Changed 2 years ago by cboos
Ported to trunk in r9342, using the second alternative.
comment:5 Changed 11 months ago by anonymous
Looks like the changes that closed #7663 were removed in the changes that fixed this ticket. I noticed this because I now have .12.1 and am getting the "IntegrityError?: duplicate key violates unique constraint "session_attribute_pk"" logged in #7663 during Performance Testing. It actually causes the performance testing to stop due to the high volume of errors (repeating the one below). There are plans to log a defect.
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"
comment:6 Changed 4 months ago by rblank
The fix has been re-introduced in [10823].



web: avoid using a cursor after the connection from which it depends has been rollbacked