aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2018-08-21 15:23:15 +0200
committerGitHub <noreply@github.com>2018-08-21 15:23:15 +0200
commitd914bbe09f5b6140f9becc474790fe21ac5fac00 (patch)
tree16995ae7af2054bc378befdd09eaf10763ca0e05
parent7f3bd67fa8b0d9e58af1ff65e0a1f8e6e8609f02 (diff)
parentbd87e1b6146a211f8e62db6402cf337723472467 (diff)
Merge pull request #6639 from vespa-engine/arnej/delay-crash-loops-more
more restart penalty
-rw-r--r--configd/src/apps/sentinel/service.cpp15
-rw-r--r--configd/src/apps/sentinel/service.h2
2 files changed, 10 insertions, 7 deletions
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp
index 866171bf75f..e70304efcb5 100644
--- a/configd/src/apps/sentinel/service.cpp
+++ b/configd/src/apps/sentinel/service.cpp
@@ -167,10 +167,13 @@ Service::start()
// make sure the service does not restart in a tight loop:
time_t now = time(0);
int diff = now - _last_start;
- if (diff < 10) {
+ if (diff < MAX_RESTART_PENALTY) {
incrementRestartPenalty();
- now += _restartPenalty; // will delay start this much
}
+ if (diff > 10 * MAX_RESTART_PENALTY) {
+ resetRestartPenalty();
+ }
+ now += _restartPenalty; // will delay start this much
_last_start = now;
// make a pipe, close the good ends of it, mark it close-on-exec
@@ -230,7 +233,7 @@ Service::start()
kill(getpid(), SIGTERM);
}
if (_restartPenalty > 0) {
- LOG(debug, "%s: Applying %u sec restart penalty", name().c_str(),
+ LOG(info, "%s: Applying %u sec restart penalty", name().c_str(),
_restartPenalty);
sleep(_restartPenalty);
}
@@ -423,9 +426,9 @@ Service::setAutomatic(bool autoStatus)
void
Service::incrementRestartPenalty()
{
- if (_restartPenalty < MAX_RESTART_PENALTY) {
- _restartPenalty++;
- } else {
+ _restartPenalty += 1;
+ _restartPenalty *= 2;
+ if (_restartPenalty > MAX_RESTART_PENALTY) {
_restartPenalty = MAX_RESTART_PENALTY;
}
}
diff --git a/configd/src/apps/sentinel/service.h b/configd/src/apps/sentinel/service.h
index 6419fdd7268..54bf1105a77 100644
--- a/configd/src/apps/sentinel/service.h
+++ b/configd/src/apps/sentinel/service.h
@@ -26,7 +26,7 @@ private:
SentinelConfig::Service *_config;
bool _isAutomatic;
- static const unsigned int MAX_RESTART_PENALTY = 60;
+ static const int MAX_RESTART_PENALTY = 1800;
unsigned int _restartPenalty;
time_t _last_start;