-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
ControllerServlet: do not sent email to admin upon error #6587 #6796
ControllerServlet: do not sent email to admin upon error #6587 #6796
Conversation
*/ | ||
if (errorReport != null) { | ||
log.severe(ActivityLogEntry.generateSystemErrorReportLogMessage(req, errorReport, userType)); | ||
} |
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.
As we are trying to save time here (we have less than 1 second to finish this part), perhaps just a simple log.severe("Unexpected exception " + e.getMessage())
is enough, in which case we can avoid lines 126-134 too?
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.
Ok I have removed the generating of error report.
* in GAE shutting down the instance. | ||
* Note that severe logs are sent by email automatically in the cron job auto/compileLogs. | ||
*/ | ||
log.severe("Unexpected exception " + t.getMessage()); |
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.
Good work. While you are at it, see if there is a way to include the stack trace in the log message. Use TeammatesException#toStringWithStackTrace(...)
?
@@ -126,7 +127,7 @@ public final void doPost(HttpServletRequest req, HttpServletResponse resp) throw | |||
* in GAE shutting down the instance. | |||
* Note that severe logs are sent by email automatically in the cron job auto/compileLogs. | |||
*/ | |||
log.severe("Unexpected exception " + t.getMessage()); | |||
log.severe(TeammatesException.toStringWithStackTrace(t)); |
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.
Better. Can you also include a"Unexpected exception caught by ControllerServlet : "
? I would like an easy way to identify log messages originating from this location.
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.
Ok I have added that. However, there seems to be a failing test unrelated to what I have changed. I have added more details in the conversation.
Running the TestNG test for AccountsDbTest.java results in a failure if testGetAccount is run before testEditAccount. The failed test can be seen here: https://gist.github.com/anonymous/65a51785dcc12cc9880f5ecfb364cdfd So if the order of the test changes it will work, for example the following test suite will work: Additional Info Usual sequence of working test: Sequence for failing test: |
@xpdavid Thanks for the info. The tests are now passing. |
@damithc doing what is done right now will strip off all the information originally sent via email: request method, request user agent, request path, request URL, request parameters. I believe at least three of them are useful, if not critical, in troubleshooting. |
This PR is doing what I have been doing for many months now. I've been applying this "fix" to live code before deploying ever since we started having many server crashes. This PR is just migrating my hot patch to the permanent code base. :-p Yes, it will strip off useful info from the log message, but those info are logged by GAE anyway, so they are not completely lost. It's just a bit harder to locate. I'm not sure how much we can do within 1 second under full load, so I don't want to risk entire server being killed in order to collect those info. Having said that, we'll try to add those things back after we've resolved some of our other performance issues and server crashes are no longer a big concern. |
In that case, @LiHaoTan check if the following functions are still used somewhere else:
If they are not, remove them as well. |
Remove ActivityLogEntry#generateSystemErrorReportLogMessage. Remove EmailGenerator#generateSystemErrorEmail. Remove test case EmailGeneratorTest#testSystemCrashReportEmailContent.
Ok I have removed them. By the way, they still look useful, or are they not? |
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.
Few more things to remove.
String subject = String.format(EmailType.ADMIN_SYSTEM_ERROR.getSubject(), | ||
Config.getAppVersion(), error.getMessage()); | ||
|
||
verifyEmail(email, Config.SUPPORT_EMAIL, subject, "/systemCrashReportEmail.html"); |
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.
This HTML file should be fine to be removed. It can be found in the folder src/test/resources/emails
.
modifiedContent = email.getContent().replaceAll(lastCommonLineRegex, "$1...$2"); | ||
email.setContent(modifiedContent); | ||
|
||
verifyEmail(email, Config.SUPPORT_EMAIL, subject, "/systemCrashReportEmailLessInfo.html"); |
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.
Similarly here.
@wkurniawan07 Ok I have removed the files, sorry for overlooking them. Thanks for the link on the dead code. |
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.
Few more things to remove.
"${stackTrace}", stackTrace); | ||
|
||
EmailWrapper email = getEmptyEmailAddressedToEmail(Config.SUPPORT_EMAIL); | ||
email.setSubject(String.format(EmailType.ADMIN_SYSTEM_ERROR.getSubject(), Config.getAppVersion(), errorMessage)); |
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.
Looks like I missed this. This enum EmailType.ADMIN_SYSTEM_ERROR
should be fine to be removed as well.
|
||
String actualUser = userType == null || userType.id == null ? "Not logged in" : userType.id; | ||
|
||
String emailBody = Templates.populateTemplate(EmailTemplates.SYSTEM_ERROR, |
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.
So is EmailTemplates.SYSTEM_ERROR
, and by extension src/main/resources/systemErrorEmailTemplate.html
.
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.
Looks good, thanks for your contribution @LiHaoTan! 👍
Fixes #6587
Outline of Solution
Additional Info
I added the comments as I feel the code does not explain why an error report does not need to be sent through email. Not sure if this is appropriate.
I also worked on this issue because the person originally working on the issue KYUUBI have went missing.