* mod_cache, mod_disk_cache: Try to use the key of a possible open but
stale cache entry if there is one. This fixes problem when two different
cache locks have been created for single stale cache entry leading to two
requests sent to backend.
PR 50317
* Remove useless apr_file_remove() before renaming the cache entry in
mod_disk_cache. This fixes small time-frame during which stale cache
entry can be seen as not-cached.
PR 50317
Subitted By: rpluem, jkaluza, ylavic
Reviewed By: ylavic, rpluem, jkaluza
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@
1608838 13f79535-47bb-0310-9956-
ffa450edef68
-*- coding: utf-8 -*-
Changes with Apache 2.2.28
+ *) mod_cache, mod_disk_cache: With CacheLock enabled, responses with a Vary
+ header might not get the benefit of the thundering herd protection due to
+ an incorrect internal cache key. PR 50317.
+ [Ruediger Pluem, Jan Kaluza, Yann Ylavic]
+
*) mod_rewrite: Support session cookies with the CO= flag when later parameters
are used. The doc for this implied the feature had been backported for
quite some time. PR56014 [Eric Covener]
*) mod_cache: Don't remove stale cache entries that cannot be conditionally
- revalidated. This prevents the thundring herd protection from serving
+ revalidated. This prevents the thundering herd protection from serving
stale responses during a revalidation. PR 50317.
[Eric Covener, Jan Kaluza, Ruediger Pluem]
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * mod_cache, mod_disk_cache: Try to use the key of a possible open but
- stale cache entry if there is one. This fixes problem when two different
- cache locks have been created for single stale cache entry leading to two
- requests sent to backend.
- Remove useless apr_file_remove() before renaming the cache entry in
- mod_disk_cache. This fixes small time-frame during which stale cache
- entry can be seen as not-cached.
- PR 50317
- 2.2.x patch: http://people.apache.org/~jkaluza/patches/httpd-2.2.x-thundering-herd.patch
- +1: ylavic, rpluem, jkaluza
PATCHES PROPOSED TO BACKPORT FROM TRUNK:
[ New proposals should be added at the end of the list ]
if (rv != OK) {
if (rv == DECLINED) {
if (!lookup) {
+ char *key;
+ cache_handle_t *h;
+
+ /*
+ * Try to use the key of a possible open but stall cache
+ * entry if we have one.
+ */
+ if (cache->handle != NULL) {
+ h = cache->handle;
+ }
+ else {
+ h = cache->stale_handle;
+ }
+ if ((h != NULL) &&
+ (h->cache_obj != NULL) &&
+ (h->cache_obj->key != NULL)) {
+ key = apr_pstrdup(r->pool, h->cache_obj->key);
+ }
+ else {
+ key = NULL;
+ }
/* try to obtain a cache lock at this point. if we succeed,
* we are the first to try and cache this url. if we fail,
* backend without any attempt to cache. this stops
* duplicated simultaneous attempts to cache an entity.
*/
- rv = ap_cache_try_lock(conf, r, NULL);
+ rv = ap_cache_try_lock(conf, r, key);
if (APR_SUCCESS == rv) {
/*
apr_file_close(dobj->hfd); /* flush and close */
- /* Remove old file with the same name. If remove fails, then
- * perhaps we need to create the directory tree where we are
- * about to write the new headers file.
- */
- rv = apr_file_remove(dobj->hdrsfile, r->pool);
- if (rv != APR_SUCCESS) {
- mkdir_structure(conf, dobj->hdrsfile, r->pool);
- }
-
rv = safe_file_rename(conf, dobj->tempfile, dobj->hdrsfile, r->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, r->server,