Bug 61891 - infinitive loop of AH01323: Purge of LDAP cache failed
Summary: infinitive loop of AH01323: Purge of LDAP cache failed
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_ldap (show other bugs)
Version: 2.4.27
Hardware: All Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Reported: 2017-12-11 15:19 UTC by Hendrik Harms
Modified: 2018-12-03 10:33 UTC (History)
1 user (show)

mod_ldap TTL patch (7.64 KB, patch)
2017-12-11 15:28 UTC, Hendrik Harms
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hendrik Harms 2017-12-11 15:19:18 UTC
Sometimes I see the error "AH01323: Purge of LDAP cache failed" repeated many times. Only restarting the HTTPD could stop it.

After some investigation I think the marktime set when the cache is 3/4 full is the problem: 
If we have a cache with a short TTL-time many entries are renewed before the maxentries are reached. If the purge-run could only delete less than 1/4 of the entries (cause more than 1/2 are renewed meanwhile) we don't pass the place where the marktime is set again. After this we could not add any new item into the cache. Any try to add an item will cause the error "AH01323: Purge of LDAP cache failed".
Comment 1 Hendrik Harms 2017-12-11 15:28:15 UTC
Created attachment 35608 [details]
mod_ldap TTL patch

We have a TTL-time for each cache. So why don't use it for recalculating the best marktime before purging.
Comment 2 Hendrik Harms 2017-12-13 15:49:32 UTC
A small example to make the issue more clear:

Imagine we have a cache that could store 20 items -> maxentries=20
and the TTL for the items is 10 seconds.
markentries = maxentries*3/4 = 15
We have 11 power users sending a request every 5 seconds
We have 20 lazy users sending a request once a minute (average 1 per 5 seconds)

We start with an empty cache at 0 sec
at  5 sec 12 items a taken (11 power + 1 lazy)
at 20 sec 15 items a taken (11 power + 4 lazy)
  -> markentries reatched -> set marktime = 20
at 45 sec 20 items a taken (11 power + 9 lazy)
at 50 sec a new lazy entry should be added into the cache but cache is full
  -> a purge starts
    The purge could only delete the 4 lazy entries older than marktime
    cause the power entries are already renewed. (TTL=10)
    So we left with 16 entries in our cache.  
    16 is greater than 15 ! So we never set a new marktime and
    all following purges could not delete any item. -> bang -> AH01323
Comment 3 Eric Covener 2017-12-13 16:59:46 UTC
Thank for the report, patch, and followup (it helped).

I committed the patch with minor changes r1818040 and have proposed it for backport to 2.4.x.
Comment 4 Christophe JAILLET 2018-03-24 12:09:58 UTC
Backported in 2.4.x in r1820800

This is part of 2.4.30
Comment 5 Hendrik Harms 2018-12-03 10:33:38 UTC
released with 2.4.33 -  THX