HomePhorge

parser: Avoid cache stampede on pages which use {{CURRENTYEAR}}

This commit no longer exists in the repository. It may have been part of a branch which was deleted.

Description

parser: Avoid cache stampede on pages which use {{CURRENTYEAR}}

With the precise expiration computation for magic words like
{{CURRENTYEAR}} there's the potential for all the pages which
use (say) {{CURRENTYEAR}} to expire at the exact same time,
causing a cache stampede.

I9acb42b0d9ff67798a1624cbf9c7cac99c8fbe2f added code to "randomly"
stagger the cache expiration:

$ttl += ( $deadlineUnix % self::DEADLINE_TTL_STAGGER_MAX );

However, this "stagger" was not actually random, since it is
based on the computed deadline. So all of the pages which use
{{CURRENTYEAR}} will all compute the same $deadlineUnix (midnight
of January 1st of the next year) and thus compute the same "stagger".

Change $deadlineUnix to $tsUnix so that the stagger is based on when
this particular page is being parsed, which should actually have
the desired effect of spreading out the possible cache stampede.

Followup-To: I9acb42b0d9ff67798a1624cbf9c7cac99c8fbe2f
Change-Id: I95272e301c00e4646dd29ca22abc26c6cbe9028e

Details

Provenance
C. Scott AnanianAuthored on May 6 2024, 7:48 PM

Event Timeline

C. Scott Ananian <cscott@cscott.net> committed rMWc668d33d215c: parser: Avoid cache stampede on pages which use {{CURRENTYEAR}} (authored by C. Scott Ananian <cscott@cscott.net>).May 6 2024, 8:36 PM

Commit No Longer Exists

This commit no longer exists in the repository.