Search in sources :

Example 1 with QueryError

use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.

the class QueryMetadataImpl method setCorruptionQueryError.

public void setCorruptionQueryError() {
    final QueryError corruptionQueryError = new QueryError(System.currentTimeMillis(), "Query not started due to corruption in the command topic.", Type.USER);
    listener.onError(this, corruptionQueryError);
    queryErrors.add(corruptionQueryError);
    corruptionCommandTopic = true;
}
Also used : QueryError(io.confluent.ksql.query.QueryError)

Example 2 with QueryError

use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.

the class QueryMetadataImpl method uncaughtHandler.

protected StreamsUncaughtExceptionHandler.StreamThreadExceptionResponse uncaughtHandler(final Throwable e) {
    QueryError.Type errorType = Type.UNKNOWN;
    try {
        QueryLogger.error(String.format("Uncaught exception in query %s", e), this.statementString);
        errorType = errorClassifier.classify(e);
    } catch (final Exception classificationException) {
        LOG.error("Error classifying unhandled exception", classificationException);
    } finally {
        // If error classification throws then we consider the error to be an UNKNOWN error.
        // We notify listeners and add the error to the errors queue in the finally block to ensure
        // all listeners and consumers of the error queue (e.g. the API) can see the error. Similarly,
        // log in finally block to make sure that if there's ever an error in the classification
        // we still get this in our logs.
        final QueryError queryError = new QueryError(System.currentTimeMillis(), Throwables.getStackTraceAsString(e), errorType);
        listener.onError(this, queryError);
        queryErrors.add(queryError);
        LOG.error("Unhandled exception caught in streams thread {}. ({})", Thread.currentThread().getName(), errorType, e);
    }
    retryEvent.backOff();
    return StreamsUncaughtExceptionHandler.StreamThreadExceptionResponse.REPLACE_THREAD;
}
Also used : QueryError(io.confluent.ksql.query.QueryError) Type(io.confluent.ksql.query.QueryError.Type) StreamsException(org.apache.kafka.streams.errors.StreamsException)

Example 3 with QueryError

use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.

the class BinPackedPersistentQueryMetadataImpl method setCorruptionQueryError.

@Override
public void setCorruptionQueryError() {
    final QueryError corruptionQueryError = new QueryError(System.currentTimeMillis(), "Query not started due to corruption in the command topic.", QueryError.Type.USER);
    setQueryError(corruptionQueryError);
    corruptionCommandTopic = true;
}
Also used : QueryError(io.confluent.ksql.query.QueryError)

Example 4 with QueryError

use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.

the class QueryStateMetricsReportingListenerTest method shouldUpdateOnError.

@Test
public void shouldUpdateOnError() {
    // When:
    listener.onCreate(serviceContext, metaStore, query);
    listener.onError(query, new QueryError(1, "foo", Type.USER));
    // Then:
    assertThat(currentGaugeValue(METRIC_NAME_2), is("USER"));
}
Also used : QueryError(io.confluent.ksql.query.QueryError) Test(org.junit.Test)

Example 5 with QueryError

use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.

the class ConsoleTest method shouldPrintExplainQueryWithError.

@Test
public void shouldPrintExplainQueryWithError() {
    final long timestamp = 1596644936314L;
    // Given:
    final QueryDescriptionEntity queryEntity = new QueryDescriptionEntity("statement", new QueryDescription(new QueryId("id"), "statement", Optional.empty(), ImmutableList.of(new FieldInfo("name", new SchemaInfo(SqlBaseType.STRING, ImmutableList.of(), null), Optional.empty())), ImmutableSet.of("source"), ImmutableSet.of("sink"), "topology", "executionPlan", ImmutableMap.of("overridden.prop", 42), ImmutableMap.of(new KsqlHostInfoEntity("foo", 123), KsqlQueryStatus.ERROR), KsqlQueryType.PERSISTENT, ImmutableList.of(new QueryError(timestamp, "error", Type.SYSTEM)), ImmutableSet.of(new StreamsTaskMetadata("test", Collections.emptySet(), Optional.empty())), "consumerGroupId"));
    final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(queryEntity));
    // When:
    console.printKsqlEntityList(entityList);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) QueryDescriptionEntity(io.confluent.ksql.rest.entity.QueryDescriptionEntity) QueryId(io.confluent.ksql.query.QueryId) KsqlHostInfoEntity(io.confluent.ksql.rest.entity.KsqlHostInfoEntity) QueryDescription(io.confluent.ksql.rest.entity.QueryDescription) Matchers.containsString(org.hamcrest.Matchers.containsString) QueryError(io.confluent.ksql.query.QueryError) FieldInfo(io.confluent.ksql.rest.entity.FieldInfo) StreamsTaskMetadata(io.confluent.ksql.rest.entity.StreamsTaskMetadata) SchemaInfo(io.confluent.ksql.rest.entity.SchemaInfo) Test(org.junit.Test)

Aggregations

QueryError (io.confluent.ksql.query.QueryError)10 Test (org.junit.Test)4 StreamsException (org.apache.kafka.streams.errors.StreamsException)2 Type (io.confluent.ksql.query.QueryError.Type)1 QueryId (io.confluent.ksql.query.QueryId)1 FieldInfo (io.confluent.ksql.rest.entity.FieldInfo)1 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)1 KsqlHostInfoEntity (io.confluent.ksql.rest.entity.KsqlHostInfoEntity)1 QueryDescription (io.confluent.ksql.rest.entity.QueryDescription)1 QueryDescriptionEntity (io.confluent.ksql.rest.entity.QueryDescriptionEntity)1 SchemaInfo (io.confluent.ksql.rest.entity.SchemaInfo)1 StreamsTaskMetadata (io.confluent.ksql.rest.entity.StreamsTaskMetadata)1 QueryMetadata (io.confluent.ksql.util.QueryMetadata)1 Instant (java.time.Instant)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ExecutionException (java.util.concurrent.ExecutionException)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1