<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hi!<DIV><BR class="khtml-block-placeholder"></DIV><DIV>We found a bug in the calculation of the latency for a passive check. This has highlighted a possible race condition re: freshness checking. We wanted to get some ideas on what is the best approach to fix this.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Background:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>We have a master/slave arrangement, with freshness checking (freshness_threshold=0) of slave services on the master.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Looking in the NDO db, we realised that the latency values for passive results were incorrectly calculate - sometimes latency values could be 1000x out. The patch is attached. However, since using this patch, we've seen occasional race conditions.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Problem:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Within checks.c:check_service_result_freshness, if a service has past its expiration_time, it is marked as is_being_freshened and a forced service check is scheduled. However, if a passive result for this service is processed before this forced check is run, then the service is marked as stale and the state is inconsistent between master and slave.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Possible solutions:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>  - If a check result is processed with is_being_freshened set for the service, then remove forced check from schedule if it exists.</DIV><DIV>  - Change is_being_freshened to stale_time (0 if not stale). On running the forced check, if stale_time is less than last_check_time (+ latency?), break out of running the forced check.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>None of these sound particularly appealing to us. Are there other possible solutions? Any opinions?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Ton<DIV><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV><BR class="khtml-block-placeholder"></DIV><DIV><A href="http://www.altinity.com">http://www.altinity.com</A></DIV><DIV>T: +44 (0)870 787 9243</DIV><DIV>F: +44 (0)845 280 1725</DIV><DIV>Skype: tonvoon</DIV></SPAN></SPAN></SPAN></SPAN></SPAN><BR class="Apple-interchange-newline"></SPAN> </DIV></DIV></BODY></HTML>