@@ -229,7 +229,7 @@ class LogbookThread {
229229 if (publishRequest.load ()) return __LINE__; // fail if request already pending
230230 publishRequest = 1 ;
231231 if (this ->verbose ) {
232- theLog.log (LogInfoDevel_ (3210 ), " Requested to publish logbook stats" );
232+ theLog.log (LogInfoDevel_ (3210 ), " Requested to publish bookkeeping stats" );
233233 }
234234 if (timeoutMilliseconds > 0 ) {
235235 // wait request completed and check status
@@ -251,6 +251,8 @@ class LogbookThread {
251251 std::atomic<int > publishRequest; // flag to ask thread to publish current values
252252 std::atomic<int > publishSuccess; // flag to report status of latest publish operation
253253 void run () {
254+ int nSuccessiveFailures = 0 ;
255+ const int maxSuccessiveFailures = 3 ;
254256 setThreadName (" logbook" );
255257 // thread loop, 10Hz
256258 while (!shutdownRequest && (logbookHandle != nullptr )) {
@@ -268,20 +270,25 @@ class LogbookThread {
268270 (int64_t )snapshot.numberOfSubtimeframes .load (), (int64_t )snapshot.bytesReadout .load (), (int64_t )snapshot.bytesRecorded .load (), (int64_t )snapshot.bytesFairMQ .load ()
269271 );
270272 if (this ->verbose ) {
271- theLog.log (LogInfoDevel_ (3210 ), " Publishing logbook stats: tf = %llu, bytesReadout = %llu" , (unsigned long long )snapshot.numberOfSubtimeframes .load (), (unsigned long long )snapshot.bytesReadout .load ());
273+ theLog.log (LogInfoDevel_ (3210 ), " Publishing bookkeeping stats: tf = %llu, bytesReadout = %llu" , (unsigned long long )snapshot.numberOfSubtimeframes .load (), (unsigned long long )snapshot.bytesReadout .load ());
272274 }
273275 publishSuccess = 1 ;
274276 } catch (const std::exception& ex) {
275- theLog.log (LogErrorDevel_ (3210 ), " Failed to update logbook : %s" , ex.what ());
277+ theLog.log (LogErrorDevel_ (3210 ), " Failed to update bookkeeping : %s" , ex.what ());
276278 } catch (...) {
277- theLog.log (LogErrorDevel_ (3210 ), " Failed to update logbook : unknown exception" );
279+ theLog.log (LogErrorDevel_ (3210 ), " Failed to update bookkeeping : unknown exception" );
278280 }
279281 if (!publishSuccess.load ()) {
280- // closing logbook immediately
281- logbookHandle = nullptr ;
282- theLog.log (LogErrorSupport_ (3210 ), " Logbook now disabled" );
283- break ;
284- }
282+ nSuccessiveFailures++;
283+ if (nSuccessiveFailures >= maxSuccessiveFailures) {
284+ // closing logbook immediately
285+ logbookHandle = nullptr ;
286+ theLog.log (LogErrorSupport_ (3210 ), " Bookkeeping updates now disabled, after %d consecutive failures" , nSuccessiveFailures);
287+ break ;
288+ }
289+ } else {
290+ nSuccessiveFailures = 0 ;
291+ }
285292 }
286293 publishRequest = 0 ;
287294 }
@@ -470,7 +477,7 @@ void Readout::publishLogbookStats(int timeout)
470477 if (theLogbookThread != nullptr ) {
471478 int err = theLogbookThread->publishStats (timeout);
472479 if ((timeout > 0 ) && (err)) {
473- theLog.log (LogErrorDevel_ (3210 ), " Logbook publish failed within given time (%d ms)" , timeout);
480+ theLog.log (LogErrorDevel_ (3210 ), " Bookkeeping publish failed within given time (%d ms)" , timeout);
474481 }
475482 }
476483#endif
@@ -1072,15 +1079,15 @@ int Readout::_configure(const boost::property_tree::ptree& properties)
10721079
10731080 if (cfgLogbookEnabled) {
10741081#ifndef WITH_LOGBOOK
1075- theLog.log (LogErrorDevel_ (3210 ), " Logbook enabled in configuration, but feature not available in this build" );
1082+ theLog.log (LogErrorDevel_ (3210 ), " Bookkeeping enabled in configuration, but feature not available in this build" );
10761083#else
10771084 // configuration parameter: | readout | logbookUrl | string | | The address to be used for the logbook API. |
10781085 cfg.getOptionalValue <std::string>(" readout.logbookUrl" , cfgLogbookUrl);
10791086
10801087 theLog.log (LogInfoDevel, " Logbook enabled, %ds update interval, using URL = %s" , cfgLogbookUpdateInterval, cfgLogbookUrl.c_str ());
10811088 auto logbookHandle = o2::bkp::api::BkpClientFactory::create (cfgLogbookUrl);
10821089 if (logbookHandle == nullptr ) {
1083- theLog.log (LogErrorSupport_ (3210 ), " Failed to create handle to logbook " );
1090+ theLog.log (LogErrorSupport_ (3210 ), " Failed to create handle to bookkeeping " );
10841091 } else {
10851092 theLogbookThread = std::make_unique<LogbookThread>(std::move (logbookHandle));
10861093 }
0 commit comments