Skip to content

Conversation

@navina
Copy link
Contributor

@navina navina commented Apr 25, 2017

  • SamzaContainerExceptionHandler is written in Java and used by LocalContainerRunner.java

@navina
Copy link
Contributor Author

navina commented Apr 25, 2017

@prateekm Can you please take a look at the changes? Please comment if this was not what you had in mind. Thanks!


/**
* An UncaughtExceptionHandler for SamzaContainer that simply shuts down when any thread throws
* an uncaught exception.
Copy link
Contributor

@vjagadish1989 vjagadish1989 Apr 25, 2017

Choose a reason for hiding this comment

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

Minor:

Documentation could use slight re-wording? This does not invoke System.exit itself right? IIUC, It simply runs the provided Runnable?

Or, we could get rid off the runnable, and make the code and documentation consistent. (It's a matter of minor convenience anyways)

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 think this is a result of copying the documentation over from the scala class. I will fix the documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 if you want to remove the Runnable parameter.

import org.apache.samza.SamzaException
import org.junit.After
import org.apache.samza.SamzaException;
import org.junit.Test;
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: organize these imports.

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 is how IntelliJ organizes imports. Were you referring some specific ordering?

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, I thought the junit imports could have been potentially grouped together. I think I may have missed the static clause in the assertTrue.

try {
runLoopThread.join(shutdownMs)
} catch {
case e: Exception => // Ignore to avoid deadlock with uncaughtExceptioHandler. See SAMZA-1220
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO it makes sense to catch, log and ignore all Throwable here.

  • OOM errors happening in shutdown hook are usually in-actionable.
  • We will bound the wait time by shutdownMs anyways.
  • Other throwables happening in the shutdownHook will end up calling the UncaughtExceptionHandler resulting in a potential deadlock. Catching all Throwables will prevent this.

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. Makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for catching Throwable. Maybe also move the logging to try instead of finally (in case it throws).

Copy link
Contributor

@prateekm prateekm left a comment

Choose a reason for hiding this comment

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

Looks good, thanks. Some minor comments.

}
} catch {
case e: IllegalStateException => {
// When samza is shutdown by external command, IllegalStateException will be thrown.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rephrase to:
"Thrown when then JVM is already shutting down, so safe to ignore."?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.


/**
* An UncaughtExceptionHandler for SamzaContainer that simply shuts down when any thread throws
* an uncaught exception.
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 if you want to remove the Runnable parameter.

try {
runLoopThread.join(shutdownMs)
} catch {
case e: Exception => // Ignore to avoid deadlock with uncaughtExceptioHandler. See SAMZA-1220
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for catching Throwable. Maybe also move the logging to try instead of finally (in case it throws).

Copy link
Contributor

@vjagadish1989 vjagadish1989 left a comment

Choose a reason for hiding this comment

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

approved. looks great to me. thank you for the contribution navina.

@asfgit asfgit closed this in edc8722 Apr 25, 2017
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.

3 participants