[ 
https://issues.apache.org/jira/browse/JENA-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461205#comment-13461205
 ] 

Andy Seaborne commented on JENA-324:
------------------------------------

The code now catches exceptions at the various points of the commit (and abort) 
phase and tries to cleanup tidily.  An exception in the prepare phase will lead 
to an attempt to abort.

There is always a narrow window 9which is now much smaller) when the journal 
commit record is written and sync'ed and if this causes a low level system 
problem (e.g. IOException), the system is broken and the best course of action 
is to stop the app and fix it.

IO problems are more likely during the prepare phase due to the size of data 
written at this point.

A transaction either aborts, or commits.  There is no possibility of visible 
partially committed data.

                
> An exception thrown from commit() leaves the StoreConnection in an 
> inconsistent state.
> --------------------------------------------------------------------------------------
>
>                 Key: JENA-324
>                 URL: https://issues.apache.org/jira/browse/JENA-324
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB
>    Affects Versions: TDB 0.9.1, TDB 0.9.2, TDB 0.9.3, TDB 0.9.4
>            Reporter: Mark Buquor
>
> An exception thrown from commit() leaves the StoreConnection in an 
> inconsistent state.
> Example: After a commit() throws an IOException in prepare() due to 
> insufficient disk space, I see the following behavior:
>     dataset.isInTransaction() == false
>     dataset.abort() throws TDBTransactionException: "Transaction has already 
> committed or aborted"
>     dataset.end() appears OK
>     dataset.begin(ReadWrite.READ) appears OK
>     dataset.begin(ReadWrite.WRITE) blocks on writersWaiting.acquire()
>  
> The debugger shows that the transaction is stuck in limbo: active, closed, 
> and unfinished.
>     TransactionManager.activeWriters: 1
>     TransactionManager.activeTransactions: 1
>         [Transaction: 151 : Mode=WRITE : State=CLOSED : X:\RELM1\]
>             changesPending=true
>             outcome=UNFINISHED
> Short of a fix, it looks like the only option to clear the stuck transaction 
> is StoreConnection.expel(location, true), which has the comment "testing 
> only".
> There's also the indeterminacy of ending a transaction that, as far as I can 
> tell at the Dataset level, may or may not be committed ("Transaction has 
> already committed or aborted").
> Rough outline of a commit:
>     state == TxnState.PREPARING
>     -- commitPrepare()
>     -- journal.write()
>     -- journal.sync() // Commit point.
>     state == TxnState.COMMITED
>     -- noteTxnCommit()
>     -- currentReaderView.set(null)
>     -- writersWaiting.release()
> noteTxnCommit() is called after the commit and performs IO, so it appears 
> that if commit() throws an exception, it's not necessarily true that the 
> transaction is effectively aborted.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to