Do not run tryTo on invalid string if status is not ok

Summary: Also it causes debug failure on unchecked Expected when status is not ok

Reviewed By: mkareta

Differential Revision: D13859377

fbshipit-source-id: 596410350cb91d469dc0a19f0e8eec558e8627bd
This commit is contained in:
Alexander Kindyakov 2019-01-29 08:09:32 -08:00 committed by Facebook Github Bot
parent 04f632f16e
commit e1045be13e

View File

@ -37,13 +37,13 @@ void DistributedRunner::start() {
dist.runQueries();
}
std::string str_acu = "0";
Status database = getDatabaseValue(
kPersistentSettings, "distributed_accelerate_checkins_expire", str_acu);
auto const accelerate_checkins_expire_exp =
tryTo<unsigned long int>(str_acu, 10);
if (!database.ok() || accelerate_checkins_expire_exp.isError() ||
getUnixTime() > accelerate_checkins_expire_exp.get()) {
std::string accelerate_checkins_expire_str = "-1";
Status status = getDatabaseValue(kPersistentSettings,
"distributed_accelerate_checkins_expire",
accelerate_checkins_expire_str);
if (!status.ok() || getUnixTime() > tryTo<unsigned long int>(
accelerate_checkins_expire_str, 10)
.takeOr(0ul)) {
pause(std::chrono::seconds(FLAGS_distributed_interval));
} else {
pause(std::chrono::seconds(kDistributedAccelerationInterval));