mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
BUG/MEDIUM: cache: replace old object on store
Currently the cache aborts a store operation if the object to store already exists in the cache. This is used to avoid storing multiple copies at the same time on concurrent accesses. It causes an issue though, which is that existing unexpired objects cannot be updated. This happens when any request criterion disables the retrieval from the cache (eg: with max-age or any other cache-control condition). For now, let's simply replace the previous existing entry by unlinking it from the index. This could possibly be improved in the future if needed. This fix needs to be backported to 1.8.
This commit is contained in:
parent
7704b1e89a
commit
c9bd34c7e0
14
src/cache.c
14
src/cache.c
@ -469,6 +469,7 @@ enum act_return http_action_store_cache(struct act_rule *rule, struct proxy *px,
|
|||||||
filter->config->conf == rule->arg.act.p[0]) {
|
filter->config->conf == rule->arg.act.p[0]) {
|
||||||
if (filter->ctx) {
|
if (filter->ctx) {
|
||||||
struct cache_st *cache_ctx = filter->ctx;
|
struct cache_st *cache_ctx = filter->ctx;
|
||||||
|
struct cache_entry *old;
|
||||||
|
|
||||||
cache_ctx->first_block = first;
|
cache_ctx->first_block = first;
|
||||||
object = (struct cache_entry *)first->data;
|
object = (struct cache_entry *)first->data;
|
||||||
@ -478,14 +479,11 @@ enum act_return http_action_store_cache(struct act_rule *rule, struct proxy *px,
|
|||||||
/* Insert the node later on caching success */
|
/* Insert the node later on caching success */
|
||||||
|
|
||||||
shctx_lock(shctx);
|
shctx_lock(shctx);
|
||||||
if (entry_exist(cache, txn->cache_hash)) {
|
|
||||||
shctx_unlock(shctx);
|
old = entry_exist(cache, txn->cache_hash);
|
||||||
if (filter->ctx) {
|
if (old) {
|
||||||
object->eb.key = 0;
|
eb32_delete(&old->eb);
|
||||||
pool_free(pool_head_cache_st, filter->ctx);
|
old->eb.key = 0;
|
||||||
filter->ctx = NULL;
|
|
||||||
}
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
shctx_unlock(shctx);
|
shctx_unlock(shctx);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user