Le 06/12/2017 à 02:11, PiBa-NL a écrit :
Hi List, Simon and Baptiste,

Sending to both of you guys as its both tcp-check and email related and
you are the maintainers of those parts.
Patch subject+content basically says it all (i hope.).

It is intended to fixes yesterdays report:
https://www.mail-archive.com/haproxy@formilux.org/msg28158.html

Please let me know if it is OK, or should be done differently.


Hi,

I'm able to reproduce the bug and your patch fixes it.

The difference between 1.7 and 1.8 is that, when an email alert is created, the check->status field is uninitialized in 1.7. In 1.8, the status is set to HCHK_STATUS_INI.

So another way to fix the bug is to leave check->status field uninitialized, as for 1.7. I amended your patch.

Honestly, I don't know which version is the best. Email alerts should probably be rewritten to not use the checks. This was the only solution to do connections by hand when Simon implemented it. That's not true anymore.

Anyway, the bug must be fixed. Thanks.

--
Christopher Faulet
>From adcf5c388d8e1ec02ad708689fd2a2d41891d2cd Mon Sep 17 00:00:00 2001
From: PiBa-NL <pba_...@yahoo.com>
Date: Wed, 6 Dec 2017 01:35:43 +0100
Subject: [PATCH] BUG/MEDIUM: email-alert: don't set server check status when
 an email-alert is created

This avoids possible 100% cpu usage deadlock on a EMAIL_ALERTS_LOCK and avoids
sending lots of emails when 'option log-health-checks' is used.
It is avoided to change the server state and possibly queue a new email while
processing the email alert by checking if the check task is being processed for
the process_email_alert struct.

This needs to be backported to 1.8.
---
 src/checks.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/checks.c b/src/checks.c
index eaf84a225..d463a12a2 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -73,7 +73,6 @@ static int tcpcheck_main(struct check *);
 static struct pool_head *pool_head_email_alert   = NULL;
 static struct pool_head *pool_head_tcpcheck_rule = NULL;
 
-
 static const struct check_status check_statuses[HCHK_STATUS_SIZE] = {
 	[HCHK_STATUS_UNKNOWN]	= { CHK_RES_UNKNOWN,  "UNK",     "Unknown" },
 	[HCHK_STATUS_INI]	= { CHK_RES_UNKNOWN,  "INI",     "Initializing" },
@@ -3145,7 +3144,7 @@ static struct task *process_email_alert(struct task *t)
 			t->expire             = now_ms;
 			check->server         = alert->srv;
 			check->tcpcheck_rules = &alert->tcpcheck_rules;
-			check->status         = HCHK_STATUS_INI;
+			check->status         = HCHK_STATUS_UNKNOWN;
 			check->state         |= CHK_ST_ENABLED;
 		}
 
-- 
2.13.6

Reply via email to