-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: continue monitoring if unhandled Exception is thrown #676
Conversation
} finally { | ||
if (this.monitoringConn != null) { | ||
try { | ||
this.monitoringConn.close(); | ||
} catch (final SQLException ex) { | ||
// ignore | ||
LOGGER.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I'm not sure this message adds extra clarity.
2cdb0f2
to
51659d2
Compare
@@ -94,6 +94,9 @@ public MonitorImpl( | |||
|
|||
@Override | |||
public void startMonitoring(final MonitorConnectionContext context) { | |||
if (this.stopped) { | |||
LOGGER.warning(() -> Messages.get("MonitorImpl.monitorIsStopped")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add monitoring host name to the message?
4ee88ef
to
10ba058
Compare
Do we have an issue to refer to that prompted this change ? |
Yes, #675. I've updated the PR description. |
10ba058
to
809b30c
Compare
@@ -188,6 +188,9 @@ MonitorThreadContainer.emptyNodeKeys=Provided node keys are empty. | |||
|
|||
# Monitor Impl | |||
MonitorImpl.contextNullWarning=Parameter 'context' should not be null. | |||
MonitorImpl.interruptedExceptionDuringMonitoring=Monitoring thread for node {0} was interrupted: {1} | |||
MonitorImpl.exceptionDuringMonitoring=Unhandled exception in monitoring thread for node {0}: {1} | |||
MonitorImpl.monitorIsStopped=Monitoring has already stopped for node {0}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Monitor was or is already stopped?
() -> Messages.get( | ||
"MonitorImpl.interruptedExceptionDuringMonitoring", | ||
new Object[] {this.hostSpec.getHost(), intEx.getMessage()})); | ||
} catch (final Exception ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we expecting any other kind of exception? (we did not catch it beforehand)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're adding extra logging in case there was an exception we hadn't accounted for stopping this method and going undetected. This is because of the OOM error that was noticed after the newContexts queue had too many context objects added to it.
809b30c
to
f320b8b
Compare
new Object[] {this.hostSpec.getHost(), intEx.getMessage()})); | ||
} catch (final Exception ex) { | ||
// do nothing; exit thread | ||
LOGGER.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to change code so such unhandled exceptions to be logged but the monitoring thread/loop keeps running.
f320b8b
to
0e6fd68
Compare
eabc10f
to
81530fe
Compare
81530fe
to
e3da22e
Compare
this.activeContexts.add(monitorContext); | ||
break; | ||
} | ||
synchronized (monitorContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really have to be synchronized? It is a local variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a local variable but we add it to queues in MonitorImpl that runs in a separate thread. Monitoring thread may change an internal state of the context. The idea was to synchronize on it to avoid multi-threading collisions. It seems this intent isn't properly implemented here. Need to address it in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fix it in this PR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some investigation, it seems like the current implementation is working and a fix isn't required.
a29d9c4
to
249a8b8
Compare
ddc8a54
to
6b1e5c4
Compare
6b1e5c4
to
e5dc854
Compare
chore: add additional logging for efm
e5dc854
to
5a19f35
Compare
Summary
Add additional logging for efm
Description
MonitorImpl
class for previously unhandled exceptions and for scenarios where monitoring has stopped but thestartMonitoring
method was called again.Related to #675
Additional Reviewers
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.