Skip to content

Unable to serve from cache if cache entry was expired or invalidated #788

@vankoven

Description

@vankoven

The issue is here: https://github.com/tempesta-tech/tempesta/blob/master/tempesta_fw/cache.c#L852

__cache_add_node() must revalidate or remove already existing entry to the key given instead of unconditional addition of a new cache entry. The new cache entry will have the same key as the expired one, so the new entry will be added into one collision chain with expired entry. In most cases it will be added to the end of the chain.

This make impossible to get not expired cache entry when serving new requests. And response to every request of that resource will be added into cache. That leads to memory leakage.

Steps to reproduce:

  1. Configure backend to have small expire timeout and disable caching on backend. E.g. for nginx:
expires 15; # 15 seconds
  1. Send GET to TempestaFW. It will be forwarded to origin server, response will populate the cache
  2. Send GET once again, it will be served from cache
  3. Wait 15-20 secconds, cache entry will expire
  4. Send GET, It will be forwarded to origin server, response will populate the cache
  5. Send GET once again, It will be forwarded to origin server, response will populate the cache. That is the issue, the request must be served from cache

Note: there is a few more tasks on cache revalidation: #515 #518

Depends on #515 (TDBv2, removal is required).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions