Skip to content

Query should not fail because emitter fails or throws Exception#5484

Merged
b-slim merged 1 commit intoapache:masterfrom
niketh:emitter-phaser-issue
Mar 14, 2018
Merged

Query should not fail because emitter fails or throws Exception#5484
b-slim merged 1 commit intoapache:masterfrom
niketh:emitter-phaser-issue

Conversation

@niketh
Copy link
Copy Markdown
Contributor

@niketh niketh commented Mar 14, 2018

Isolate emitter failures and don't let them affect query failures #5485

@niketh niketh force-pushed the emitter-phaser-issue branch from 849c56a to e9f5658 Compare March 14, 2018 00:24
@b-slim b-slim merged commit 40cc2c8 into apache:master Mar 14, 2018
Copy link
Copy Markdown
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is already merged but please consider fixing the issues anyway. The log message won't be right with the current code.

Also, the try/catch for emitter exceptions is probably indicating some bigger problem. emitter.emit is assumed by lots of places to never fail and Emitter implementations must adhere to that. This fix will help with one specific location, but there are a ton of other places where the emitter is used and exceptions thrown by it will cause problems. I think it's better to fix broken Emitter implementations than to put try/catches everywhere throughout the rest of Druid.

private final long creationTimeNs;
private final ObjLongConsumer<? super QueryMetrics<?>> reportMetric;
private final Consumer<QueryMetrics<?>> applyCustomDimensions;
private static final Logger log = new Logger(MetricsEmittingQueryRunner.class);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the static finals at the top of the file, where they usually go.

}
catch (Exception e) {
// Query should not fail, because of emitter failure. Swallowing the exception.
log.error("Failure while trying to emit [%s] with stacktrace [%s]", emitter.toString(), e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be log.error(e, "Failure emitting query metrics with emitter[%s]", emitter). The exception goes first, or else it won't be interpreted as a stack trace.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, sorry missed that.

@gianm
Copy link
Copy Markdown
Contributor

gianm commented Mar 14, 2018

I raised #5486 with a javadoc clarifying the Emitter.emit contract that has been implicitly in place.

@pjain1 pjain1 added this to the 0.13.0 milestone Mar 14, 2018
@pjain1 pjain1 added the Bug label Mar 14, 2018
@leventov
Copy link
Copy Markdown
Member

What about reverting this PR after #5488 is merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants