Skip to content

NIFI-1636: Print Stacktrace When Unexpected OnTrigger Exception Caught#285

Closed
rickysaltzer wants to merge 1 commit intoapache:masterfrom
rickysaltzer:NIFI-1636
Closed

NIFI-1636: Print Stacktrace When Unexpected OnTrigger Exception Caught#285
rickysaltzer wants to merge 1 commit intoapache:masterfrom
rickysaltzer:NIFI-1636

Conversation

@rickysaltzer
Copy link
Contributor

No description provided.

session.commit();
} catch (final Throwable t) {
getLogger().error("{} failed to process due to {}; rolling back session", new Object[]{this, t});
StringWriter stacktraceWriter = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic needs to be in the logger and that is its intent. You will note that the throwable is being passed into it. The stack traces are getting logged when debug level is engaged for a given logger. This allows the user to control whether they are generated or not. That said...it is clearly counterintuitive and we need to improve.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense @joewitt. Should legitimate unexpected exceptions be surfaced to INFO by default? I feel like these are uncommon enough to warrant it, but I could be wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say generally no. They are uncommon in general but when they happen they happen in bursts. As a general rule I think we should strive to make what the user sees be something a lot more friendly than a wild stack trace. But, the logs should have them. We did discuss this on dev list a while back and there were some great inputs from various folks. We def need to do something here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if it would make sense to surface the shorthand message to the user in the UI but log the stacktrace to the log file. I imagine this would take some re-working.

Copy link
Contributor

Choose a reason for hiding this comment

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

that is actually the current behavior/intent. I think the change needed is to simply get rid of the 'if debug enabled' stuff we did in the logger and instead just always log the stacktrace when it is there. This is what Adam Taft had advocated for previously as I recall. I now see why he was saying it. So yeah in the UI it should be a short and ideally meaningful message (not always possible) and if a throwable shows up we should put the whole stack trace in the logs.

The current idea that a user will go in an do debug enabled....just has proven to be a failed experiment in my view and as someone who advocated for that I now think i was wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So if I understand correctly, this happens now but only in DEBUG mode. What we would like to see is that behavior but even if we're in INFO mode. That is, shortened version logged to the UI and the stacktrace logged to the log file?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. So i think the short version is in the UI now. But you want the stacktrace too. We should make that available in the logs. And this class is what controls that I believe https://github.com/apache/nifi/blob/master/nifi-commons/nifi-logging-utils/src/main/java/org/apache/nifi/logging/NiFiLog.java You'll see it has some ifDebugEnabled guards. We should probably just toss those out. @markap14 what say you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep that would be the easiest way, and I can go ahead and throw this mess I added in above.

Copy link
Contributor

Choose a reason for hiding this comment

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

I should clarify...i agree with you this is confusing and not quite doing what we want. We need to fix it. Can you share a screenshot of what you see for a given error in the UI vs what shows in the logs and then let's agree on what it should ideally be and then figure out how to get there :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, my battery just died so I will as soon as able. Thanks!

Logs the stacktrace to the default log file, and emits the
shortened version for the UI.
@rickysaltzer
Copy link
Contributor Author

@joewitt posted a new version of the patch. I tested it out on my local machine and it seems to work as expected. That is, the stacktrace is logged to the nifi-app.log, while the the shortened version is logged to the UI. The contrib-check also checks out ;)

@olegz
Copy link
Contributor

olegz commented Mar 23, 2016

Ricky

Could you please take a look at https://issues.apache.org/jira/browse/NIFI-1447 and see if it's what you are looking for? If I remember correctly we don't really want to log stack traces unless we're in DEBUG mode and that is what the above JIRA addresses.

@olegz
Copy link
Contributor

olegz commented Mar 23, 2016

Also, you may want to amend the commit message "Unepected" unless its a new English word I haven't learned yet ;)

@rickysaltzer rickysaltzer changed the title NIFI-1636: Print Stacktrace When Unepected OnTrigger Exception Caught NIFI-1636: Print Stacktrace When Unexpected OnTrigger Exception Caught Mar 25, 2016
@rickysaltzer
Copy link
Contributor Author

Thanks, @olegz! Thankfully that wasn't the commit message :). I took a look at NIFI-1447, and I believe this could be what I'm looking for. I understand the concern for overly verbose logging in the case of a FlowFile getting stuck in some sort of infinite loop.

Regarding NIFI-1447, are uncaught stacktraces logged at ERROR level?

@olegz
Copy link
Contributor

olegz commented Apr 4, 2016

They were logged at DEBUG only level and that was the issue since you would not be able to see them, but now if there is an error the stack trace will be printed

@olegz
Copy link
Contributor

olegz commented Apr 17, 2016

@rickysaltzer where do you think we are with this one? I mean, do you think NIFI-1447 solved your issue or this PR is still valid?

@apiri
Copy link
Member

apiri commented Jun 17, 2016

@rickysaltzer Was combing over PRs in rounding up items for 0.7.0. Curious if the effort highlighted by Oleg makes this particular PR OBE. Thanks!

@trixpan
Copy link
Contributor

trixpan commented Oct 3, 2016

@rickysaltzer - is the PR still relevant? Would you mind if we close otherwise?

@rickysaltzer
Copy link
Contributor Author

@trixpan thanks for the reminder, closing...

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants