mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
mod_proxy_balancer: Fix balancers and balancer members reuse on
restart when new ones are added. PR 58024. Since slotmem_create() issues a strict check on the size of an existing slot before reusing it, it won't reuse existing balancers and members when new ones are added during restart (whereas growth margins would allow it). Fix this by using slotmem_attach() first and if it succeeds do the checks based on the returned previous number of existing entries. [Reverted by r1698123] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1696960 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,6 +1,9 @@
|
|||||||
-*- coding: utf-8 -*-
|
-*- coding: utf-8 -*-
|
||||||
Changes with Apache 2.5.0
|
Changes with Apache 2.5.0
|
||||||
|
|
||||||
|
*) mod_proxy_balancer: Fix balancers and balancer members reuse on
|
||||||
|
restart when new ones are added. PR 58024. [Yann Ylavic]
|
||||||
|
|
||||||
*) mod_socache_memcache: Add the 'MemcacheConnTTL' directive to control how
|
*) mod_socache_memcache: Add the 'MemcacheConnTTL' directive to control how
|
||||||
long to keep idle connections with the memcache server(s).
|
long to keep idle connections with the memcache server(s).
|
||||||
Change default value from 600 usec (!) to 15 sec. PR 58091
|
Change default value from 600 usec (!) to 15 sec. PR 58091
|
||||||
|
@@ -1 +1 @@
|
|||||||
2964
|
2966
|
||||||
|
@@ -761,8 +761,11 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
|
|||||||
char *id;
|
char *id;
|
||||||
proxy_balancer *balancer;
|
proxy_balancer *balancer;
|
||||||
ap_slotmem_type_t type;
|
ap_slotmem_type_t type;
|
||||||
|
apr_size_t attached_size;
|
||||||
|
unsigned int attached_num;
|
||||||
void *sconf = s->module_config;
|
void *sconf = s->module_config;
|
||||||
conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
|
conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* During create_proxy_config() we created a dummy id. Now that
|
* During create_proxy_config() we created a dummy id. Now that
|
||||||
* we have identifying info, we can create the real id
|
* we have identifying info, we can create the real id
|
||||||
@@ -794,11 +797,39 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
|
|||||||
(int)ALIGNED_PROXY_BALANCER_SHARED_SIZE,
|
(int)ALIGNED_PROXY_BALANCER_SHARED_SIZE,
|
||||||
(int)conf->balancers->nelts, conf->max_balancers);
|
(int)conf->balancers->nelts, conf->max_balancers);
|
||||||
|
|
||||||
rv = storage->create(&new, conf->id,
|
/* First try to attach() since the number of configured balancers
|
||||||
ALIGNED_PROXY_BALANCER_SHARED_SIZE,
|
* may have changed during restart, and we don't want create() to
|
||||||
conf->max_balancers, type, pconf);
|
* fail because the overall size * number of entries is not stricly
|
||||||
|
* identical to the previous run. There may still be enough room
|
||||||
|
* for this new run thanks to bgrowth margin, so if attach()
|
||||||
|
* succeeds we can only check for the number of available entries
|
||||||
|
* to be *greater or* equal to what we need now. If attach() fails
|
||||||
|
* we simply fall back to create().
|
||||||
|
*/
|
||||||
|
rv = storage->attach(&new, conf->id,
|
||||||
|
&attached_size, &attached_num,
|
||||||
|
pconf);
|
||||||
if (rv != APR_SUCCESS) {
|
if (rv != APR_SUCCESS) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01179) "balancer slotmem_create failed");
|
rv = storage->create(&new, conf->id,
|
||||||
|
ALIGNED_PROXY_BALANCER_SHARED_SIZE,
|
||||||
|
conf->max_balancers, type, pconf);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02964)
|
||||||
|
"Balancers attached: %d, %d (%d)",
|
||||||
|
(int)ALIGNED_PROXY_BALANCER_SHARED_SIZE,
|
||||||
|
(int)attached_num, conf->max_balancers);
|
||||||
|
if (attached_size == ALIGNED_PROXY_BALANCER_SHARED_SIZE
|
||||||
|
&& attached_num >= conf->balancers->nelts) {
|
||||||
|
conf->max_balancers = attached_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = APR_ENOSPC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rv != APR_SUCCESS) {
|
||||||
|
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01179)
|
||||||
|
"balancer slotmem create or attach failed");
|
||||||
return !OK;
|
return !OK;
|
||||||
}
|
}
|
||||||
conf->bslot = new;
|
conf->bslot = new;
|
||||||
@@ -864,11 +895,32 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
|
|||||||
(int)ALIGNED_PROXY_WORKER_SHARED_SIZE,
|
(int)ALIGNED_PROXY_WORKER_SHARED_SIZE,
|
||||||
(int)balancer->max_workers, i);
|
(int)balancer->max_workers, i);
|
||||||
|
|
||||||
rv = storage->create(&new, balancer->s->sname,
|
/* try to attach first (see rationale from balancers above) */
|
||||||
ALIGNED_PROXY_WORKER_SHARED_SIZE,
|
rv = storage->attach(&new, balancer->s->sname,
|
||||||
balancer->max_workers, type, pconf);
|
&attached_size, &attached_num,
|
||||||
|
pconf);
|
||||||
if (rv != APR_SUCCESS) {
|
if (rv != APR_SUCCESS) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01185) "worker slotmem_create failed");
|
rv = storage->create(&new, balancer->s->sname,
|
||||||
|
ALIGNED_PROXY_WORKER_SHARED_SIZE,
|
||||||
|
balancer->max_workers, type, pconf);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02965)
|
||||||
|
"Workers attached: %s (%s), %d, %d (%d) [%u]",
|
||||||
|
balancer->s->name, balancer->s->sname,
|
||||||
|
(int)ALIGNED_PROXY_WORKER_SHARED_SIZE,
|
||||||
|
(int)attached_num, balancer->max_workers, i);
|
||||||
|
if (attached_size == ALIGNED_PROXY_WORKER_SHARED_SIZE
|
||||||
|
&& attached_num >= balancer->workers->nelts) {
|
||||||
|
balancer->max_workers = attached_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = APR_ENOSPC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rv != APR_SUCCESS) {
|
||||||
|
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01185)
|
||||||
|
"worker slotmem create or attach failed");
|
||||||
return !OK;
|
return !OK;
|
||||||
}
|
}
|
||||||
balancer->wslot = new;
|
balancer->wslot = new;
|
||||||
|
Reference in New Issue
Block a user