BUG/MINOR: cache: Disable cache if applet creation fails
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 21 Apr 2022 09:30:43 +0000 (11:30 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 29 Apr 2022 13:49:18 +0000 (15:49 +0200)
When we want to serve a resource from the cache, if the applet creation
fails, the "cache-use" action must not yield. Otherwise, the stream will
hang. Instead, we now disable the cache. Thus the request may be served by
the server.

This patch must be backported as far as 1.8.

(cherry picked from commit 1d216c7ec1815c510bd3c6a1152cf41f748f93e0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 75fca43e872ee7ffc038979c4472d4e9f372ea90)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 95d7bc53bb17cfe0805214f164763a639987abd3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/cache.c

index 0568abe..24bbc46 100644 (file)
@@ -1344,10 +1344,11 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
                                _HA_ATOMIC_ADD(&px->be_counters.p.http.cache_hits, 1);
                        return ACT_RET_CONT;
                } else {
+                       s->target = NULL;
                        shctx_lock(shctx_ptr(cache));
                        shctx_row_dec_hot(shctx_ptr(cache), block_ptr(res));
                        shctx_unlock(shctx_ptr(cache));
-                       return ACT_RET_YIELD;
+                       return ACT_RET_CONT;
                }
        }
        shctx_unlock(shctx_ptr(cache));