@@ -22,7 +22,7 @@ boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, co
2222boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, StateType, const MessageOrigin::Ptr&)> Checkable::OnStateChange;
2323boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, std::set<Checkable::Ptr>, const MessageOrigin::Ptr&)> Checkable::OnReachabilityChanged;
2424boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&, const String&, const String&, const MessageOrigin::Ptr&)> Checkable::OnNotificationsRequested;
25- boost::signals2::signal<void (const Checkable::Ptr&)> Checkable::OnNextCheckUpdated;
25+ boost::signals2::signal<void (const Checkable::Ptr&, const Value&, bool )> Checkable::OnNextCheckUpdated;
2626
2727Atomic<uint_fast64_t > Checkable::CurrentConcurrentChecks (0 );
2828
@@ -50,7 +50,32 @@ long Checkable::GetSchedulingOffset()
5050 return m_SchedulingOffset;
5151}
5252
53- void Checkable::UpdateNextCheck (const MessageOrigin::Ptr& origin)
53+ /* *
54+ * Sets the next check time of the current checkable.
55+ *
56+ * This method is a wrapper around the internal @c ObjectImpl::SetNextCheck method that provides additional
57+ * functionality by triggering the @c Checkable::OnNextCheckUpdated event unless suppressed. This event is
58+ * the same as the auto generated event for the property change, but it also provides an additional parameter
59+ * to broadcast to subscribers whether this timestamp change should be persisted to the database. Both events
60+ * will be triggered only if `suppressEvents` isn't set to true. So, if you're interested on the additional argument,
61+ * you should subscribe to the @c Checkable::OnNextCheckUpdated event, otherwise you can just continue to use the
62+ * @c Checkable::OnNextCheckChanged event as before.
63+ *
64+ * @param value The new next check time as a Timestamp.
65+ * @param suppressEvents If true, the OnNextCheckUpdated event will not be triggered.
66+ * @param cookie An optional Value that can be passed to the event handler.
67+ * @param affectsDB If true, indicates that the change should be persisted to the database.
68+ */
69+ void Checkable::SetNextCheck (const Timestamp& value, bool suppressEvents, const Value& cookie, bool affectsDB)
70+ {
71+ ObjectImpl::SetNextCheck (value, suppressEvents, cookie);
72+
73+ if (!suppressEvents) {
74+ OnNextCheckUpdated (Ptr (this ), cookie, affectsDB);
75+ }
76+ }
77+
78+ void Checkable::UpdateNextCheck (const MessageOrigin::Ptr& origin, bool affectsDB)
5479{
5580 double interval;
5681
@@ -78,7 +103,7 @@ void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin)
78103 << " (" << lastCheck << " ) to next check time at "
79104 << Utility::FormatDateTime (" %Y-%m-%d %H:%M:%S %z" , nextCheck) << " (" << nextCheck << " )." ;
80105
81- SetNextCheck (nextCheck, false , origin);
106+ SetNextCheck (nextCheck, false , origin, affectsDB );
82107}
83108
84109bool Checkable::HasBeenChecked () const
@@ -372,7 +397,9 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
372397 // is randomly initialised on each node.
373398 if (!origin) {
374399 if (cr->GetActive ()) {
375- UpdateNextCheck ();
400+ // The OnCheckResult event triggered down below implicitly triggers DB next update,
401+ // so we don't spam the DB with the same information twice.
402+ UpdateNextCheck (Empty, false );
376403 } else {
377404 /* Reschedule the next check for external passive check results. The side effect of
378405 * this is that for as long as we receive results for a service we
@@ -385,7 +412,7 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
385412 else
386413 offset = GetCheckInterval ();
387414
388- SetNextCheck (Utility::GetTime () + offset);
415+ SetNextCheck (Utility::GetTime () + offset, false , Empty, false );
389416 }
390417 }
391418
@@ -518,7 +545,9 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
518545 ObjectLock oLock (child);
519546
520547 if (nextCheck < child->GetNextCheck ()) {
521- child->SetNextCheck (nextCheck);
548+ // This is purely a cheat to force a re-check of the child object ASAP for reachability,
549+ // but this shouldn't be relevant for Icinga DB or IDO, so we don't persist this change.
550+ child->SetNextCheck (nextCheck, false , Empty, false );
522551 }
523552 }
524553 }
@@ -535,7 +564,9 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
535564
536565 if (parent->GetNextCheck () >= now + parent->GetRetryInterval ()) {
537566 ObjectLock olock (parent);
538- parent->SetNextCheck (now);
567+ // This is same as above, we just want to force a re-check of the parent ASAP.
568+ // No need to persist this change to Icinga DB or IDO.
569+ parent->SetNextCheck (now, false , Empty, false );
539570 }
540571 }
541572 }
@@ -571,7 +602,7 @@ void Checkable::ExecuteCheck(const WaitGroup::Ptr& producer)
571602 * queues and ensures that checks are not fired multiple times. ProcessCheckResult()
572603 * is called too late. See #6421.
573604 */
574- UpdateNextCheck ();
605+ UpdateNextCheck (Empty, false );
575606
576607 bool reachable = IsReachable ();
577608
@@ -644,7 +675,7 @@ void Checkable::ExecuteCheck(const WaitGroup::Ptr& producer)
644675 * a check result from the remote instance. The check will be re-scheduled
645676 * using the proper check interval once we've received a check result.
646677 */
647- SetNextCheck (Utility::GetTime () + checkTimeout + 30 );
678+ SetNextCheck (Utility::GetTime () + checkTimeout + 30 , false , Empty, false );
648679
649680 /*
650681 * Let the user know that there was a problem with the check if
0 commit comments