blob: e571810ad3e3cf1665faccf49d6d4e81f3fc6024 [file] [log] [blame]
Frédéric Lécailledd51e532018-08-31 11:05:39 +02001# 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écailledc1a3bd2019-03-29 15:07:24 +010017#REGTEST_TYPE=bug
Willy Tarreau826f3ab2021-02-10 12:07:15 +010018#REQUIRE_VERSION=2.4
Frédéric Lécailledc1a3bd2019-03-29 15:07:24 +010019
Frédéric Lécailledd51e532018-08-31 11:05:39 +020020varnishtest "stick-tables: Test expirations when used with table_*"
21
22# As some macros for haproxy are used in this file, this line is mandatory.
23feature ignore_unknown_macro
24
25# Do nothing.
26server s1 {
27} -start
28
29haproxy h1 -conf {
30 # Configuration file of 'h1' haproxy instance.
31 defaults
32 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010033 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
34 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
35 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
Frédéric Lécailledd51e532018-08-31 11:05:39 +020036
37 frontend http1
38 bind "fd@${my_frontend_fd}"
Willy Tarreau826f3ab2021-02-10 12:07:15 +010039 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écailledd51e532018-08-31 11:05:39 +020040 http-request track-sc0 req.hdr(X-Forwarded-For)
41 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_cnt(http1) -m int lt 0 }
42 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_trackers(http1) -m int lt 0 }
43 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),in_table(http1) -m int lt 0 }
44 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_bytes_in_rate(http1) -m int lt 0 }
45 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_bytes_out_rate(http1) -m int lt 0 }
46 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_cnt(http1) -m int lt 0 }
47 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_cur(http1) -m int lt 0 }
48 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_rate(http1) -m int lt 0 }
49 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpt0(http1) -m int lt 0 }
50 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpc0(http1) -m int lt 0 }
51 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpc0_rate(http1) -m int lt 0 }
52 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_err_cnt(http1) -m int lt 0 }
53 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 Tarreau826f3ab2021-02-10 12:07:15 +010054 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_fail_cnt(http1) -m int lt 0 }
55 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écailledd51e532018-08-31 11:05:39 +020056 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_cnt(http1) -m int lt 0 }
57 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_rate(http1) -m int lt 0 }
58 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_kbytes_in(http1) -m int lt 0 }
59 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_kbytes_out(http1) -m int lt 0 }
60 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_server_id(http1) -m int lt 0 }
61 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_sess_cnt(http1) -m int lt 0 }
62 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_sess_rate(http1) -m int lt 0 }
63 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_trackers(http1) -m int lt 0 }
Willy Tarreaua1af38b2020-08-19 11:20:28 +020064} -start
Frédéric Lécailledd51e532018-08-31 11:05:39 +020065
66client c1 -connect ${h1_my_frontend_fd_sock} {
67 txreq -url "/" -hdr "X-Forwarded-For: 127.0.0.1"
68 rxresp
69 expect resp.status == 503
70} -run
71
72haproxy h1 -cli {
73 send "show table http1"
Willy Tarreau826f3ab2021-02-10 12:07:15 +010074 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écailledd51e532018-08-31 11:05:39 +020075} -wait