blueslip: Avoid blueslip spam for failed email lookups.

If an email lookup fails, we now wait for five seconds before
doing a blueslip.error() call (after re-checking the email).
This commit is contained in:
Steve Howell 2017-02-03 08:41:16 -08:00 committed by Tim Abbott
parent 633d4d1882
commit 89b9c5eece
1 changed files with 11 additions and 1 deletions

View File

@ -42,7 +42,17 @@ exports.get_by_email = function get_by_email(email) {
exports.get_user_id = function (email) {
var person = people_dict.get(email);
if (person === undefined) {
blueslip.error('Unknown email for get_user_id: ' + email);
// Our blueslip reporting here is a bit complicated, but
// there are known race conditions after reload, and we
// expect occasional failed lookups, but they should resolve
// after five seconds.
var error_msg = 'Unknown email for get_user_id: ' + email;
blueslip.debug(error_msg);
setTimeout(function () {
if (!people_dict.has(email)) {
blueslip.error(error_msg);
}
}, 5000);
return undefined;
}
var user_id = person.user_id;