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:
- Configure backend to have small expire timeout and disable caching on backend. E.g. for nginx:
- Send GET to TempestaFW. It will be forwarded to origin server, response will populate the cache
- Send GET once again, it will be served from cache
- Wait 15-20 secconds, cache entry will expire
- Send GET, It will be forwarded to origin server, response will populate the cache
- 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).
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 thekeygiven 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:
Note: there is a few more tasks on cache revalidation: #515 #518
Depends on #515 (TDBv2, removal is required).