diff --git a/reg-tests/checks/pgsql-check.vtc b/reg-tests/checks/pgsql-check.vtc index 417932ee9..2c9c65b0e 100644 --- a/reg-tests/checks/pgsql-check.vtc +++ b/reg-tests/checks/pgsql-check.vtc @@ -23,6 +23,11 @@ server s3 { send "Not a PostgreSQL response" } -start +server s4 { + recv 23 + sendhex "52000000170000000A534352414D2D5348412D3235360000" +} -start + syslog S1 -level notice { recv expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+info: \"PostgreSQL server is ok\".+check duration: [[:digit:]]+ms, status: 1/1 UP." @@ -38,6 +43,10 @@ syslog S3 -level notice { expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv failed, reason: Layer7 wrong status.+info: \"PostgreSQL unknown error\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN." } -start +syslog S4 -level notice { + recv + expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv succeeded, reason: Layer7 check passed.+info: \"PostgreSQL server is ok\".+check duration: [[:digit:]]+ms, status: 1/1 UP." +} -start haproxy h1 -conf { defaults @@ -64,6 +73,12 @@ haproxy h1 -conf { option pgsql-check user postgres server srv ${s3_addr}:${s3_port} check inter 1s rise 1 fall 1 + backend be4 + log ${S4_addr}:${S4_port} daemon + option log-health-checks + option pgsql-check user postgres + server srv ${s4_addr}:${s4_port} check inter 1s rise 1 fall 1 + listen pgsql1 bind "fd@${pgsql}" tcp-request inspect-delay 100ms @@ -75,3 +90,4 @@ haproxy h1 -conf { syslog S1 -wait syslog S2 -wait syslog S3 -wait +syslog S4 -wait diff --git a/src/tcpcheck.c b/src/tcpcheck.c index 5ef1c69cb..366a8d09c 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -4517,7 +4517,7 @@ int proxy_parse_pgsql_check_opt(char **args, int cur_arg, struct proxy *curpx, c chk->index = 2; LIST_APPEND(&rs->rules, &chk->list); - chk = parse_tcpcheck_expect((char *[]){"tcp-check", "expect", "rbinary", "^52000000(08|0A|0C)000000(00|02|03|04|05|06)", + chk = parse_tcpcheck_expect((char *[]){"tcp-check", "expect", "rbinary", "^52000000[A-Z0-9]{2}000000(00|02|03|04|05|06|07|09|0A)", "min-recv", "9", "error-status", "L7STS", "on-success", "PostgreSQL server is ok",