Skip to content

Commit

Permalink
Merge pull request apache#714 from afs/jena1868_tdb2_concurrent
Browse files Browse the repository at this point in the history
JENA-1868: Fix for B+Tree read-abort
  • Loading branch information
afs authored Mar 26, 2020
2 parents 9d06896 + 1b0f27e commit f01d4ba
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,14 @@ protected void _commitEnd(TxnId txnId, BptTxnState state) {

@Override
protected void _abort(TxnId txnId, BptTxnState state) {
rootIdx = state.initialroot;
// Truncate - logically in block manager space.
nodeManager.resetAlloc(state.boundaryBlocksNode);
recordsMgr.resetAlloc(state.boundaryBlocksRecord);
stateManager.setState(state.initialroot, state.boundaryBlocksNode, state.boundaryBlocksRecord);
stateManager.sync();
if ( isWriteTxn() ) {
rootIdx = state.initialroot;
// Truncate - logically in block manager space.
nodeManager.resetAlloc(state.boundaryBlocksNode);
recordsMgr.resetAlloc(state.boundaryBlocksRecord);
stateManager.setState(state.initialroot, state.boundaryBlocksNode, state.boundaryBlocksRecord);
stateManager.sync();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.jena.dboe.index.test.AbstractTestRangeIndex;
import org.apache.jena.dboe.sys.SystemIndex;
import org.apache.jena.dboe.test.RecordLib;
import org.apache.jena.dboe.trans.bplustree.BPlusTree;
import org.junit.AfterClass;
import org.junit.BeforeClass;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ private TxnState getTrackTxn() {
}
// -- Access object members.

// XXX Align to javadoc in TransactionalComponent.

/* There are two lifecycles, one for write transaction, one
* for read transactions. This affects how transaction end so
* when/if promoted read->write transactions happen, a promoted
Expand All @@ -281,31 +279,39 @@ private TxnState getTrackTxn() {
*
* Read lifecycle:
* A read transaction be be just begin(READ)-end() but may also
* have commit or abort before end. The _commitRead and _abortRead
* have commit or abort before end. The _commit and _abort
* calls note if an explicit commit or abort occurs but may not be
* called. _endRead is always called exactly once.
*
* _commitRead
* _abortRead
* _endRead
* _commit
* _abort
* _end
* _complete
*
* Promote:
*
* _promote
*
* and the ReadWrite mode becomes "WRITE".
* The transaction system manages whether the "promote " is legal,
* components do not have to check.
*
* Write lifecycle:
* A write transaction must have a commit() or abort() before end().
* The fraemwork will check this.
* The framework will check this.
*
* If the transaction commits:
* _commitPrepareWrite
* _commitWrite -- The transaction is
* _commit -- The transaction is committed
* _commitEndWrite
*
* If the transaction aborts:
* _abortWrite
* _abort
*
* After any lifecycle, a final call of
* _complete()
*
* indicates ths transaction has fully finished.
* indicates that the transaction has fully finished.
*
* Typically, an implementation does not need to take action in every call.
*/
Expand All @@ -319,6 +325,7 @@ private TxnState getTrackTxn() {
protected abstract void _complete(TxnId txnId, X state);
protected abstract void _shutdown();

/** Current READ/WRITE mode. */
protected ReadWrite getReadWriteMode() {
Transaction txn = getTransaction();
return txn.getMode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

import org.apache.jena.atlas.iterator.Iter ;
import org.apache.jena.atlas.lib.Bytes ;
import org.apache.jena.tdb.base.record.Record ;
import org.apache.jena.tdb.base.record.RecordFactory ;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.apache.jena.atlas.junit.BaseTest ;
import org.apache.jena.tdb.base.record.Record ;
import org.apache.jena.tdb.base.record.RecordLib ;
import org.apache.jena.tdb.index.Index ;

public class IndexTestLib
{
Expand Down

0 comments on commit f01d4ba

Please sign in to comment.