Search in sources :

Example 6 with QueryExecutionKernelException

use of org.neo4j.kernel.impl.query.QueryExecutionKernelException in project neo4j by neo4j.

the class Start method exec.

@Override
protected Continuation exec(AppCommandParser parser, Session session, Output out) throws ShellException, RemoteException {
    String query = parser.getLine().trim();
    if (isComplete(query)) {
        final long startTime = System.currentTimeMillis();
        try {
            Result result = getResult(trimQuery(query), session);
            handleResult(out, result, startTime);
        } catch (QueryExecutionKernelException e) {
            handleException(out, e, startTime);
            return Continuation.EXCEPTION_CAUGHT;
        }
        return Continuation.INPUT_COMPLETE;
    } else {
        return Continuation.INPUT_INCOMPLETE;
    }
}
Also used : QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) Result(org.neo4j.graphdb.Result)

Example 7 with QueryExecutionKernelException

use of org.neo4j.kernel.impl.query.QueryExecutionKernelException in project neo4j by neo4j.

the class TransactionStateMachineSPI method executeQuery.

@Override
public BoltResultHandle executeQuery(BoltQuerySource querySource, SecurityContext securityContext, String statement, Map<String, Object> params, ThrowingAction<KernelException> onFail) throws QueryExecutionKernelException {
    InternalTransaction internalTransaction = queryService.beginTransaction(implicit, securityContext);
    ClientConnectionInfo sourceDetails = new BoltConnectionInfo(querySource.principalName, querySource.clientName, querySource.connectionDescriptor.clientAddress, querySource.connectionDescriptor.serverAddress);
    TransactionalContext transactionalContext = contextFactory.newContext(sourceDetails, internalTransaction, statement, params);
    return new BoltResultHandle() {

        @Override
        public BoltResult start() throws KernelException {
            try {
                Result run = queryExecutionEngine.executeQuery(statement, params, transactionalContext);
                return new CypherAdapterStream(run, clock);
            } catch (KernelException e) {
                onFail.apply();
                throw new QueryExecutionKernelException(e);
            } catch (Throwable e) {
                onFail.apply();
                throw e;
            }
        }

        @Override
        public void terminate() {
            transactionalContext.terminate();
        }
    };
}
Also used : ClientConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo) BoltConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) BoltResultHandle(org.neo4j.bolt.v1.runtime.TransactionStateMachine.BoltResultHandle) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) KernelException(org.neo4j.kernel.api.exceptions.KernelException) BoltResult(org.neo4j.bolt.v1.runtime.spi.BoltResult) Result(org.neo4j.graphdb.Result)

Example 8 with QueryExecutionKernelException

use of org.neo4j.kernel.impl.query.QueryExecutionKernelException in project neo4j by neo4j.

the class Invocation method executeStatement.

private void executeStatement(Statement statement) throws Exception {
    boolean periodicCommit = transactionHandle.isPeriodicCommit(statement.getStatement());
    if (periodicCommit) {
        if (hasPrevious || readStatement() != null) {
            throw new QueryExecutionKernelException(new InvalidSemanticsException("Cannot execute another statement with PERIODIC COMMIT statement in the same transaction", null));
        }
        transactionHandle.closeTransactionForPeriodicCommit();
    }
    hasPrevious = true;
    Result result;
    try {
        result = transactionHandle.executeStatement(statement, periodicCommit);
    } finally {
        if (periodicCommit) {
            transactionHandle.reopenAfterPeriodicCommit();
        }
    }
    writeResult(result, statement);
}
Also used : InvalidSemanticsException(org.neo4j.exceptions.InvalidSemanticsException) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) Result(org.neo4j.graphdb.Result)

Example 9 with QueryExecutionKernelException

use of org.neo4j.kernel.impl.query.QueryExecutionKernelException in project neo4j by neo4j.

the class TransactionImpl method execute.

private Result execute(InternalTransaction transaction, String query, MapValue parameters) throws QueryExecutionException {
    checkInTransaction();
    TransactionalContext context = contextFactory.newContext(transaction, query, parameters);
    try {
        availabilityGuard.assertDatabaseAvailable();
        return executionEngine.executeQuery(query, parameters, context, false);
    } catch (UnavailableException ue) {
        throw new org.neo4j.graphdb.TransactionFailureException(ue.getMessage(), ue);
    } catch (QueryExecutionKernelException e) {
        throw e.asUserException();
    }
}
Also used : QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) UnavailableException(org.neo4j.kernel.availability.UnavailableException) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext)

Example 10 with QueryExecutionKernelException

use of org.neo4j.kernel.impl.query.QueryExecutionKernelException in project neo4j by neo4j.

the class SnapshotExecutionEngineTest method failQueryAfterMaxRetriesReached.

@Test
void failQueryAfterMaxRetriesReached() throws QueryExecutionKernelException {
    when(versionContext.isDirty()).thenReturn(true);
    QueryExecutionKernelException e = assertThrows(QueryExecutionKernelException.class, () -> executionEngine.executeWithRetries("query", transactionalContext, executor));
    assertEquals("Unable to get clean data snapshot for query 'query' after 5 attempts.", e.getMessage());
    verify(executor, times(5)).execute(any());
    verify(versionContext, times(5)).initRead();
}
Also used : QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) Test(org.junit.jupiter.api.Test)

Aggregations

QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)13 Result (org.neo4j.graphdb.Result)5 TransactionalContext (org.neo4j.kernel.impl.query.TransactionalContext)5 Test (org.junit.jupiter.api.Test)4 VersionContext (org.neo4j.io.pagecache.context.VersionContext)2 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)2 KernelException (org.neo4j.kernel.api.exceptions.KernelException)2 QueryExecution (org.neo4j.kernel.impl.query.QueryExecution)2 IOException (java.io.IOException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1 BoltQueryExecution (org.neo4j.bolt.dbapi.BoltQueryExecution)1 BoltResultHandle (org.neo4j.bolt.v1.runtime.TransactionStateMachine.BoltResultHandle)1 BoltResult (org.neo4j.bolt.v1.runtime.spi.BoltResult)1 Config (org.neo4j.configuration.Config)1 GraphDatabaseInternalSettings (org.neo4j.configuration.GraphDatabaseInternalSettings)1 CypherException (org.neo4j.cypher.CypherException)1 InvalidSemanticsException (org.neo4j.cypher.InvalidSemanticsException)1 SyntaxException (org.neo4j.cypher.SyntaxException)1