Search in sources :

Example 1 with EntryUnavailableException

use of io.questdb.cairo.EntryUnavailableException in project questdb by bluestreak01.

the class JsonQueryProcessor method execute0.

public void execute0(JsonQueryProcessorState state) throws PeerDisconnectedException, PeerIsSlowToReadException, ServerDisconnectException {
    metrics.jsonQuery().markStart();
    state.startExecutionTimer();
    final HttpConnectionContext context = state.getHttpConnectionContext();
    // do not set random for new request to avoid copying random from previous request into next one
    // the only time we need to copy random from state is when we resume request execution
    sqlExecutionContext.with(context.getCairoSecurityContext(), null, null, context.getFd(), interruptor.of(context.getFd()));
    state.info().$("exec [q='").utf8(state.getQuery()).$("']").$();
    final RecordCursorFactory factory = QueryCache.getInstance().poll(state.getQuery());
    try {
        if (factory != null) {
            try {
                sqlExecutionContext.storeTelemetry(CompiledQuery.SELECT, Telemetry.ORIGIN_HTTP_JSON);
                executeCachedSelect(state, factory, configuration.getKeepAliveHeader());
            } catch (ReaderOutOfDateException e) {
                LOG.info().$(e.getFlyweightMessage()).$();
                Misc.free(factory);
                compileQuery(state);
            }
        } else {
            // new query
            compileQuery(state);
        }
    } catch (SqlException e) {
        syntaxError(context.getChunkedResponseSocket(), e, state, configuration.getKeepAliveHeader());
        readyForNextRequest(context);
    } catch (EntryUnavailableException e) {
        LOG.info().$("[fd=").$(context.getFd()).$("] Resource busy, will retry").$();
        throw RetryOperationException.INSTANCE;
    } catch (CairoError | CairoException e) {
        internalError(context.getChunkedResponseSocket(), e.getFlyweightMessage(), e, state);
        readyForNextRequest(context);
    } catch (PeerIsSlowToReadException | PeerDisconnectedException e) {
        // re-throw the exception
        throw e;
    } catch (Throwable e) {
        state.error().$("Uh-oh. Error!").$(e).$();
        throw ServerDisconnectException.INSTANCE;
    }
}
Also used : RecordCursorFactory(io.questdb.cairo.sql.RecordCursorFactory) CairoError(io.questdb.cairo.CairoError) PeerIsSlowToReadException(io.questdb.network.PeerIsSlowToReadException) CairoException(io.questdb.cairo.CairoException) EntryUnavailableException(io.questdb.cairo.EntryUnavailableException) ReaderOutOfDateException(io.questdb.cairo.sql.ReaderOutOfDateException) PeerDisconnectedException(io.questdb.network.PeerDisconnectedException)

Aggregations

CairoError (io.questdb.cairo.CairoError)1 CairoException (io.questdb.cairo.CairoException)1 EntryUnavailableException (io.questdb.cairo.EntryUnavailableException)1 ReaderOutOfDateException (io.questdb.cairo.sql.ReaderOutOfDateException)1 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)1 PeerDisconnectedException (io.questdb.network.PeerDisconnectedException)1 PeerIsSlowToReadException (io.questdb.network.PeerIsSlowToReadException)1