Frédéric Lécaille | dd51e53 | 2018-08-31 11:05:39 +0200 | [diff] [blame] | 1 | # commit 3e60b11 |
| 2 | # BUG/MEDIUM: stick-tables: Decrement ref_cnt in table_* converters |
| 3 | # |
| 4 | # When using table_* converters ref_cnt was incremented |
| 5 | # and never decremented causing entries to not expire. |
| 6 | # |
| 7 | # The root cause appears to be that stktable_lookup_key() |
| 8 | # was called within all sample_conv_table_* functions which was |
| 9 | # incrementing ref_cnt and not decrementing after completion. |
| 10 | # |
| 11 | # Added stktable_release() to the end of each sample_conv_table_* |
| 12 | # function and reworked the end logic to ensure that ref_cnt is |
| 13 | # always decremented after use. |
| 14 | # |
| 15 | # This should be backported to 1.8 |
| 16 | |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 17 | #REGTEST_TYPE=bug |
Willy Tarreau | 826f3ab | 2021-02-10 12:07:15 +0100 | [diff] [blame] | 18 | #REQUIRE_VERSION=2.4 |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 19 | |
Frédéric Lécaille | dd51e53 | 2018-08-31 11:05:39 +0200 | [diff] [blame] | 20 | varnishtest "stick-tables: Test expirations when used with table_*" |
| 21 | |
| 22 | # As some macros for haproxy are used in this file, this line is mandatory. |
| 23 | feature ignore_unknown_macro |
| 24 | |
| 25 | # Do nothing. |
| 26 | server s1 { |
| 27 | } -start |
| 28 | |
| 29 | haproxy h1 -conf { |
| 30 | # Configuration file of 'h1' haproxy instance. |
| 31 | defaults |
| 32 | mode http |
Christopher Faulet | 8f16148 | 2018-12-19 11:49:39 +0100 | [diff] [blame] | 33 | ${no-htx} option http-use-htx |
Frédéric Lécaille | dd51e53 | 2018-08-31 11:05:39 +0200 | [diff] [blame] | 34 | timeout connect 5s |
| 35 | timeout server 30s |
| 36 | timeout client 30s |
| 37 | |
| 38 | frontend http1 |
| 39 | bind "fd@${my_frontend_fd}" |
Willy Tarreau | 826f3ab | 2021-02-10 12:07:15 +0100 | [diff] [blame] | 40 | stick-table size 1k expire 1ms type ip store conn_rate(10s),http_req_cnt,http_err_cnt,http_fail_cnt,http_req_rate(10s),http_err_rate(10s),http_fail_rate(10s),gpc0,gpc0_rate(10s),gpt0 |
Frédéric Lécaille | dd51e53 | 2018-08-31 11:05:39 +0200 | [diff] [blame] | 41 | http-request track-sc0 req.hdr(X-Forwarded-For) |
| 42 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_cnt(http1) -m int lt 0 } |
| 43 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_trackers(http1) -m int lt 0 } |
| 44 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),in_table(http1) -m int lt 0 } |
| 45 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_bytes_in_rate(http1) -m int lt 0 } |
| 46 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_bytes_out_rate(http1) -m int lt 0 } |
| 47 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_cnt(http1) -m int lt 0 } |
| 48 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_cur(http1) -m int lt 0 } |
| 49 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_rate(http1) -m int lt 0 } |
| 50 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpt0(http1) -m int lt 0 } |
| 51 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpc0(http1) -m int lt 0 } |
| 52 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpc0_rate(http1) -m int lt 0 } |
| 53 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_err_cnt(http1) -m int lt 0 } |
| 54 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_err_rate(http1) -m int lt 0 } |
Willy Tarreau | 826f3ab | 2021-02-10 12:07:15 +0100 | [diff] [blame] | 55 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_fail_cnt(http1) -m int lt 0 } |
| 56 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_fail_rate(http1) -m int lt 0 } |
Frédéric Lécaille | dd51e53 | 2018-08-31 11:05:39 +0200 | [diff] [blame] | 57 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_cnt(http1) -m int lt 0 } |
| 58 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_rate(http1) -m int lt 0 } |
| 59 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_kbytes_in(http1) -m int lt 0 } |
| 60 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_kbytes_out(http1) -m int lt 0 } |
| 61 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_server_id(http1) -m int lt 0 } |
| 62 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_sess_cnt(http1) -m int lt 0 } |
| 63 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_sess_rate(http1) -m int lt 0 } |
| 64 | http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_trackers(http1) -m int lt 0 } |
Willy Tarreau | a1af38b | 2020-08-19 11:20:28 +0200 | [diff] [blame] | 65 | } -start |
Frédéric Lécaille | dd51e53 | 2018-08-31 11:05:39 +0200 | [diff] [blame] | 66 | |
| 67 | client c1 -connect ${h1_my_frontend_fd_sock} { |
| 68 | txreq -url "/" -hdr "X-Forwarded-For: 127.0.0.1" |
| 69 | rxresp |
| 70 | expect resp.status == 503 |
| 71 | } -run |
| 72 | |
| 73 | haproxy h1 -cli { |
| 74 | send "show table http1" |
Willy Tarreau | 826f3ab | 2021-02-10 12:07:15 +0100 | [diff] [blame] | 75 | expect ~ "table: http1, type: ip, size:1024, used:(0|1\\n0x[0-9a-f]*: key=127\\.0\\.0\\.1 use=0 exp=[0-9]* gpt0=0 gpc0=0 gpc0_rate\\(10000\\)=0 conn_rate\\(10000\\)=1 http_req_cnt=1 http_req_rate\\(10000\\)=1 http_err_cnt=0 http_err_rate\\(10000\\)=0 http_fail_cnt=0 http_fail_rate\\(10000\\)=0)\\n$" |
Frédéric Lécaille | dd51e53 | 2018-08-31 11:05:39 +0200 | [diff] [blame] | 76 | } -wait |