blob: 502a05996a8c0828d77a88a2bf93b52808338091 [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
Christopher Faulet8f161482018-12-19 11:49:39 +010033 ${no-htx} option http-use-htx
Frédéric Lécailledd51e532018-08-31 11:05:39 +020034 timeout connect 5s
35 timeout server 30s
36 timeout client 30s
37
38 frontend http1
39 bind "fd@${my_frontend_fd}"
Willy Tarreau826f3ab2021-02-10 12:07:15 +010040 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 +020041 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 Tarreau826f3ab2021-02-10 12:07:15 +010055 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écailledd51e532018-08-31 11:05:39 +020057 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 Tarreaua1af38b2020-08-19 11:20:28 +020065} -start
Frédéric Lécailledd51e532018-08-31 11:05:39 +020066
67client 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
73haproxy h1 -cli {
74 send "show table http1"
Willy Tarreau826f3ab2021-02-10 12:07:15 +010075 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 +020076} -wait