When writing the notificaion fail with TRY_AGAIN in callback, the notificaion is pushed again to the list. If this happens for long time, the list is going to be very big. This cause NTFD take time to process writing all the notification in the list and the request from NTFA come this time may be timeout.
So it should litmit the "retry" of writing notificaion. --- src/ntf/ntfd/NtfLogger.cc | 23 +++++++++++++++++++---- src/ntf/ntfd/NtfLogger.h | 1 - src/ntf/ntfd/NtfNotification.cc | 9 +++++---- src/ntf/ntfd/NtfNotification.h | 2 ++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/ntf/ntfd/NtfLogger.cc b/src/ntf/ntfd/NtfLogger.cc index fd17c58a2..d1057ff5b 100644 --- a/src/ntf/ntfd/NtfLogger.cc +++ b/src/ntf/ntfd/NtfLogger.cc @@ -70,7 +70,7 @@ static SaLogHandleT logHandle; static SaLogStreamHandleT alarmStreamHandle; const SaVersionT kLogVersion = {'A', 2, 3}; -NtfLogger::NtfLogger() : readCounter(0) { +NtfLogger::NtfLogger() { if (SA_AIS_OK != initLog()) { LOG_ER("initialize saflog failed exiting..."); exit(EXIT_FAILURE); @@ -145,8 +145,17 @@ void NtfLogger::log(NtfSmartPtr& notif, bool isLocal) { } void NtfLogger::queueNotifcation(NtfSmartPtr& notif) { - TRACE_2("Queue notification: %llu", notif->getNotificationId()); - queuedNotificationList.push_back(notif); + if (notif->retriesCounterWrite < notif->kMaxRetriesWrite) { + TRACE_2("Queue notification: %llu, number of retry: %u", + notif->getNotificationId(), notif->retriesCounterWrite); + queuedNotificationList.push_back(notif); + ++notif->retriesCounterWrite; + } else { + // Ignore to log it again and send logged confirmation. + // This avoids the queue is too big when writing notification fail with + // TRY_AGAIN due to disk issue for long time. + sendLoggedConfirm(notif->getNotificationId()); + } } void NtfLogger::checkQueueAndLog(NtfSmartPtr& newNotif) { @@ -159,7 +168,13 @@ void NtfLogger::checkQueueAndLog(NtfSmartPtr& newNotif) { if (SA_AIS_OK != this->logNotification(notification)) { TRACE_2("Push back queued notification: %llu", notification->getNotificationId()); - queuedNotificationList.push_front(notification); /* keep order */ + if (notification->retriesCounterWrite < notification->kMaxRetriesWrite) { + queuedNotificationList.push_front(notification); /* keep order */ + ++notification->retriesCounterWrite; + } else { + // Ignore to log it again and send logged confirmation. + sendLoggedConfirm(newNotif->getNotificationId()); + } queueNotifcation(newNotif); TRACE_LEAVE(); return; diff --git a/src/ntf/ntfd/NtfLogger.h b/src/ntf/ntfd/NtfLogger.h index cc0ac7dba..f35f08a41 100644 --- a/src/ntf/ntfd/NtfLogger.h +++ b/src/ntf/ntfd/NtfLogger.h @@ -66,7 +66,6 @@ class NtfLogger { SaAisErrorT initLog(); readerNotificationListT coll_; - unsigned int readCounter; typedef std::list<NtfSmartPtr> QueuedNotificationsList; QueuedNotificationsList queuedNotificationList; }; diff --git a/src/ntf/ntfd/NtfNotification.cc b/src/ntf/ntfd/NtfNotification.cc index 1060606d9..27a72197a 100644 --- a/src/ntf/ntfd/NtfNotification.cc +++ b/src/ntf/ntfd/NtfNotification.cc @@ -39,15 +39,16 @@ NtfNotification::NtfNotification(SaNtfIdentifierT notificationId, SaNtfNotificationTypeT notificationType, ntfsv_send_not_req_t* sendNotInfo) - : notificationId_(notificationId) { - logged = false; - loggFromCallback_ = false; + : loggFromCallback_(false), + retriesCounterWrite(0), + kMaxRetriesWrite(10), + logged(false), notificationId_(notificationId), + notificationType_(notificationType) { TRACE_3("constructor %p, notId: %llu", this, notificationId); sendNotInfo_ = sendNotInfo; SaNtfNotificationHeaderT* header; ntfsv_get_ntf_header(sendNotInfo_, &header); *header->notificationId = notificationId_; - notificationType_ = notificationType; /* deleted in destructor */ } /** diff --git a/src/ntf/ntfd/NtfNotification.h b/src/ntf/ntfd/NtfNotification.h index f937f8f99..6d0c63844 100644 --- a/src/ntf/ntfd/NtfNotification.h +++ b/src/ntf/ntfd/NtfNotification.h @@ -65,6 +65,8 @@ class NtfNotification { SaNtfNotificationHeaderT* header(); ntfsv_send_not_req_t* sendNotInfo_; bool loggFromCallback_; + unsigned int retriesCounterWrite; + const unsigned int kMaxRetriesWrite; private: NtfNotification(); -- 2.15.1 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel