Bug #48
update results incorrect when autocommit on and multiple sessions are used
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
fixed
Description
The following sequence illustrates the problem:
<br/>
<br/>
In first db session:
<br/>
<br/>
insert <a:foo> <a:bar> 'hi' into <<a href="local:///topazproject#foo">local:///topazproject#foo</a>> ;
<br/>
insert <a:foo> <a:bar> 'bye' into <<a href="local:///topazproject#foo">local:///topazproject#foo</a>> ;
<br/>
delete select $s <a:bar> $o from <<a href="local:///topazproject#foo">local:///topazproject#foo</a>> where $s <a:bar> $o from <<a href="local:///topazproject#foo">local:///topazproject#foo</a>> ;
<br/>
insert <a:foo> <a:bar> 'blah' into <<a href="local:///topazproject#foo">local:///topazproject#foo</a>> ;
<br/>
<br/>
Then in second db session:
<br/>
<br/>
select $s <a:bar> $o from <<a href="local:///topazproject#foo">local:///topazproject#foo</a>> where $s <a:bar> $o ;
<br/>
<br/>
The final select should return a single result:
<br/>
<br/>
a:foo a:bar "blah"
<br/>
<br/>
but really returns
<br/>
<br/>
a:foo a:bar "blah"
<br/>
a:foo a:bar "hi"
<br/>
a:foo a:bar "bye"
<br/>
<br/>
If the 'delete select' or the last 'insert' is followed by a 'set
<br/>
autocommit on' then the result is correct. Also, if the query is done
<br/>
in the same db session then the result is correct.
<br/>
<br/>
I'm attaching two patches. The first actually does three things:
<br/>
<br/>
- it adds a log message when the [[TransactionalAnswer]] is cloned so
<br/>
that all instance creations are logged (this bug was leading to
<br/>
'TransactionalAnswer not closed' warnings for these cloned
<br/>
instances)
<br/>
<br/>
- it makes sure the query answer in a 'delete select' or 'insert
<br/>
select' is properly closed.
<br/>
<br/>
- it makes sure the query answers are properly closed in
<br/>
RelationalResolution - I noticed these while searching the code
<br/>
for other [[LocalizedTuples]] usage after finding the above problem.
<br/>
<br/>
The second patch is a test case for this problem: it fails with stock
<br/>
rev <a href="http://mulgara.org/trac/changeset/192">192</a>, but that succeeds with the first patch applied.
<br/>
<br/>
I'm not 100% convinced that the first patch is the true solution, but
<br/>
it does fix numerous 'TransactionalAnswer not closed' warnings and
<br/>
does seem to work. I.e. I think it should probably be applied, but
<br/>
something else is probably also needed.
<br/>
Updated by Andrae Muys - over 16 years ago
This is due to the stale answers holding open the transaction. There are two solutions to this, both are required.
<br/>
<br/>
1) Close stale answers so the transaction is closed properly.
<br/>
<br/>
2) Detect the existence of an uncommitted transaction that has leaked and commit it while emitting the appropriate ERROR log message.
Updated by Andrae Muys - over 16 years ago
Fixed in revision <a href="http://mulgara.org/trac/changeset/208">208</a>