Skip to content

Commit

Permalink
Revert REST transactional endpoint handling of periodic commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Aug 21, 2018
1 parent 8e7a46b commit 8e87831
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Expand Up @@ -320,7 +320,9 @@ private void executeStatements( StatementDeserializer statements, ExecutionResul
hasPrevious = true; hasPrevious = true;
TransactionalContext tc = txManagerFacade.create( request, queryService, type, loginContext, TransactionalContext tc = txManagerFacade.create( request, queryService, type, loginContext,
statement.statement(), statement.parameters() ); statement.statement(), statement.parameters() );
safelyExecute( statement, hasPeriodicCommit, tc, output ); Result result = safelyExecute( statement, hasPeriodicCommit, tc );
output.statementResult( result, statement.includeStats(), statement.resultDataContents() );
output.notifications( result.getNotifications() );
} }
catch ( KernelException | CypherException | AuthorizationViolationException | catch ( KernelException | CypherException | AuthorizationViolationException |
WriteOperationsNotAllowedException e ) WriteOperationsNotAllowedException e )
Expand Down Expand Up @@ -361,16 +363,13 @@ private void executeStatements( StatementDeserializer statements, ExecutionResul
} }
} }


private void safelyExecute( Statement statement, private Result safelyExecute( Statement statement,
boolean hasPeriodicCommit, boolean hasPeriodicCommit,
TransactionalContext tc, TransactionalContext tc ) throws QueryExecutionKernelException, IOException
ExecutionResultSerializer output ) throws QueryExecutionKernelException, IOException
{ {
try try
{ {
Result result = engine.executeQuery( statement.statement(), ValueUtils.asMapValue( statement.parameters() ), tc ); return engine.executeQuery( statement.statement(), ValueUtils.asMapValue( statement.parameters() ), tc );
output.statementResult( result, statement.includeStats(), statement.resultDataContents() );
output.notifications( result.getNotifications() );
} }
finally finally
{ {
Expand Down
Expand Up @@ -21,6 +21,7 @@


import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


import org.neo4j.graphdb.NotInTransactionException;
import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.internal.kernel.api.exceptions.TransactionFailureException; import org.neo4j.internal.kernel.api.exceptions.TransactionFailureException;
import org.neo4j.internal.kernel.api.security.LoginContext; import org.neo4j.internal.kernel.api.security.LoginContext;
Expand Down Expand Up @@ -96,6 +97,10 @@ public void commit()
kernelTransactionBoundToThisThread.success(); kernelTransactionBoundToThisThread.success();
kernelTransactionBoundToThisThread.close(); kernelTransactionBoundToThisThread.close();
} }
catch ( NotInTransactionException e )
{
// if the transaction was already terminated there is nothing more to do
}
catch ( TransactionFailureException e ) catch ( TransactionFailureException e )
{ {
throw new RuntimeException( e ); throw new RuntimeException( e );
Expand Down
Expand Up @@ -325,7 +325,7 @@ public void begin_and_execute_periodic_commit_that_returns_data_and_commit() thr
Response response = http.POST( Response response = http.POST(
"db/data/transaction/commit", "db/data/transaction/commit",
quotedJson( "{ 'statements': [ { 'statement': 'USING PERIODIC COMMIT " + batchSize + " LOAD CSV FROM " + quotedJson( "{ 'statements': [ { 'statement': 'USING PERIODIC COMMIT " + batchSize + " LOAD CSV FROM " +
"\\\"" + url + "\\\" AS line CREATE (n {id: 23}) RETURN n' } ] }" ) "\\\"" + url + "\\\" AS line CREATE (n {id1: 23}) RETURN n' } ] }" )
); );
long txIdAfter = resolveDependency( TransactionIdStore.class ).getLastClosedTransactionId(); long txIdAfter = resolveDependency( TransactionIdStore.class ).getLastClosedTransactionId();


Expand Down

0 comments on commit 8e87831

Please sign in to comment.