]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: cache: reattach the row when a secondary entry is incomplete
authorMaxime Henrion <mhenrion@haproxy.com>
Fri, 10 Jul 2026 00:46:42 +0000 (20:46 -0400)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2026 14:42:35 +0000 (16:42 +0200)
In http_action_req_cache_use() with Vary, the row of the secondary entry
matching the request is detached from the avail list for reading. Since
get_secondary_entry() only rejects expired entries, that secondary may
be incomplete (still being written by another stream), and in that case
the request was forwarded without reattaching the row, leaking its
blocks out of the avail list (refcount and nbav never restored). Over a
Vary workload this eventually prevents the cache from reserving any row.

Reattach the row before returning, as the other paths that give up on
the cache entry do.

Present since the Vary support was added in 2.4 (1785f3dd9); to be
backported as far as 2.6.

src/cache.c

index 79cfa635724a72a66e3879c71bea14f60d28703f..c995890a4c1d04921ac81ef07ef9bcc8411ca9cf 100644 (file)
@@ -2231,6 +2231,9 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
                        return ACT_RET_CONT;
                } else if (!res->complete) {
                        release_entry(cache_tree, res, 1);
+                       shctx_wrlock(shctx);
+                       shctx_row_reattach(shctx, entry_block);
+                       shctx_wrunlock(shctx);
                        return ACT_RET_CONT;
                }