3232namespace ripple {
3333
3434LoadManager::LoadManager (Application& app, beast::Journal journal)
35- : app_(app), journal_(journal), deadLock_ (), armed_(false )
35+ : app_(app), journal_(journal), lastHeartbeat_ (), armed_(false )
3636{
3737}
3838
@@ -53,19 +53,19 @@ LoadManager::~LoadManager()
5353// ------------------------------------------------------------------------------
5454
5555void
56- LoadManager::activateDeadlockDetector ()
56+ LoadManager::activateStallDetector ()
5757{
5858 std::lock_guard sl (mutex_);
5959 armed_ = true ;
60- deadLock_ = std::chrono::steady_clock::now ();
60+ lastHeartbeat_ = std::chrono::steady_clock::now ();
6161}
6262
6363void
64- LoadManager::resetDeadlockDetector ()
64+ LoadManager::heartbeat ()
6565{
66- auto const detector_start = std::chrono::steady_clock::now ();
66+ auto const heartbeat = std::chrono::steady_clock::now ();
6767 std::lock_guard sl (mutex_);
68- deadLock_ = detector_start ;
68+ lastHeartbeat_ = heartbeat ;
6969}
7070
7171// ------------------------------------------------------------------------------
@@ -118,63 +118,62 @@ LoadManager::run()
118118 break ;
119119
120120 // Copy out shared data under a lock. Use copies outside lock.
121- auto const deadLock = deadLock_ ;
121+ auto const lastHeartbeat = lastHeartbeat_ ;
122122 auto const armed = armed_;
123123 sl.unlock ();
124124
125- // Measure the amount of time we have been deadlocked , in seconds.
125+ // Measure the amount of time we have been stalled , in seconds.
126126 using namespace std ::chrono;
127- auto const timeSpentDeadlocked =
128- duration_cast<seconds>(steady_clock::now () - deadLock );
127+ auto const timeSpentStalled =
128+ duration_cast<seconds>(steady_clock::now () - lastHeartbeat );
129129
130130 constexpr auto reportingIntervalSeconds = 10s;
131- constexpr auto deadlockFatalLogMessageTimeLimit = 90s;
132- constexpr auto deadlockLogicErrorTimeLimit = 600s;
131+ constexpr auto stallFatalLogMessageTimeLimit = 90s;
132+ constexpr auto stallLogicErrorTimeLimit = 600s;
133133
134- if (armed && (timeSpentDeadlocked >= reportingIntervalSeconds))
134+ if (armed && (timeSpentStalled >= reportingIntervalSeconds))
135135 {
136- // Report the deadlocked condition every
137- // reportingIntervalSeconds
138- if ((timeSpentDeadlocked % reportingIntervalSeconds) == 0s)
136+ // Report the stalled condition every reportingIntervalSeconds
137+ if ((timeSpentStalled % reportingIntervalSeconds) == 0s)
139138 {
140- if (timeSpentDeadlocked < deadlockFatalLogMessageTimeLimit )
139+ if (timeSpentStalled < stallFatalLogMessageTimeLimit )
141140 {
142141 JLOG (journal_.warn ())
143- << " Server stalled for " << timeSpentDeadlocked .count ()
142+ << " Server stalled for " << timeSpentStalled .count ()
144143 << " seconds." ;
144+
145145 if (app_.getJobQueue ().isOverloaded ())
146146 {
147- JLOG (journal_.warn ()) << app_.getJobQueue ().getJson (0 );
147+ JLOG (journal_.warn ())
148+ << " JobQueue: " << app_.getJobQueue ().getJson (0 );
148149 }
149150 }
150151 else
151152 {
152153 JLOG (journal_.fatal ())
153- << " Deadlock detected. Deadlocked time: "
154- << timeSpentDeadlocked. count () << " s " ;
154+ << " Server stalled for " << timeSpentStalled. count ()
155+ << " seconds. " ;
155156 JLOG (journal_.fatal ())
156157 << " JobQueue: " << app_.getJobQueue ().getJson (0 );
157158 }
158159 }
159160
160- // If we go over the deadlockTimeLimit spent deadlocked, it
161- // means that the deadlock resolution code has failed, which
162- // qualifies as undefined behavior.
163- //
164- if (timeSpentDeadlocked >= deadlockLogicErrorTimeLimit)
161+ // If we go over the stallLogicErrorTimeLimit spent stalled, it
162+ // means that the stall resolution code has failed, which qualifies
163+ // as a LogicError
164+ if (timeSpentStalled >= stallLogicErrorTimeLimit)
165165 {
166166 JLOG (journal_.fatal ())
167- << " LogicError: Deadlock detected. Deadlocked time: "
168- << timeSpentDeadlocked .count () << " s" ;
167+ << " LogicError: Fatal server stall detected. Stalled time: "
168+ << timeSpentStalled .count () << " s" ;
169169 JLOG (journal_.fatal ())
170170 << " JobQueue: " << app_.getJobQueue ().getJson (0 );
171- LogicError (" Deadlock detected" );
171+ LogicError (" Fatal server stall detected" );
172172 }
173173 }
174174 }
175175
176- bool change;
177-
176+ bool change = false ;
178177 if (app_.getJobQueue ().isOverloaded ())
179178 {
180179 JLOG (journal_.info ()) << " Raising local fee (JQ overload): "
0 commit comments