Hi Costin, it wasn't difficult, so here is the new patch. The new (old) behavior is: The main worker is defined by a lb_value of 0. This will never be changed in jk_lb_worker. The other workers can get a value greater than 0. If the value from config file is less than 0 it is multiplicated with -1.
Your are right this is a better solution. We can switch from doubles to int and we get the other worker balanced if the main worker is down. Bernd Bernd Koecke wrote: > Hi Costin, > > [EMAIL PROTECTED] wrote: > >> Hi Bernd, >> >> First, many thanks for your help :-) >> >> > > your welcome, its a lot of fun :) > >>> No, I think not :). I checked it yesterday. With some additional log >>> statements in the validate function of jk_lb_worker.c you get the >>> value _inf_ for the lb_factor and lb_value (line 434-444). Because if >>> it would be set to 1, my config hadn't worked. Because I set the >>> local worker to 1 and the others to 0. >> >> >> >> I'll check again, and fix it if necesarry. >> >> I wrote some code in jk2 that seems to solve the problem, and I can >> backport this to jk1 if it is correct. >> >> Probably this is my mistake - I remember the discussion and the patch >> that was sent for this problem, and most likely I did something >> wrong commiting it ( i.e. I did few changes trying to simplify it, and it >> seems I 'simplified' too much ). But my memory still has the patch's >> logic >> which seemed fine :-) >> >> >>> This is possible, but then you must add a check if the value is 0. >>> Because without it you calc 1/0 with an int and this will give you an >>> error. >> >> >> >> Yes, of course. 0 will continue to mean 'default worker'. >> > > see below > >> I'm not very comfortable with float calculations in the critical >> path ( and in an area that is executed concurently !). The only problem >> is what happens on overflows - the lb_value may become 0 ( or a small >> value ) and then the worker will take all the load. >> >> >>> Thats not the whole story. Its right you will check the main worker >>> when its back again and use it only once. Because when the request >>> was successful handled rec->in_recovering is true (line 332 of >>> jk_lb_worker.c, service function). Than get_max_lb get the value >>> _inf_ from one of the other worker. Than the things happen which I >>> said in my prior mail. >> >> >> >>> That was it what I did in my sent patch, the additional documentation >>> was sent a few days later. But my additions to the lb_worker were a >>> little bit to complex. You are right we should get it when we use the >>> flag only on the main worker and change the behavior after a failure >>> for this worker. But we need the trick with 0/inf for the other >>> worker, because only with this we have the situation that the other >>> worker wouldn't be asked when there is no session and the main worker >>> is up. >> >> >> >> >> Ok, can you send the patch again :-) ? >> For going back to the main worker - if we let it with lb_value=0 at all >> time ( i.e. we don't alter that at any time ), and only in_error_state >> is set on failure - then I believe the thing will work fine. >> >> > > Thats the invers from the actual situation. So my patch from a few hours > earlier this day depends on the fact that the other worker get a > lb_value of 0 in the config file. This will be converted to _inf_ and > the main worker gets 1 and this will be the minimal lb_value of the > balanced workers. If we want the possibility to switch to ints I could > send a new patch which handles 0 as a special value for the main worker. > > Should I? > > Bernd > > >> >>> I will try to build another patch and send it. I think it could be >>> possible without an additional flag. >> >> >> >> Great ! >> >> >> >>> Another tought about this: >>> When you use double and we fix the handling after an error, the main >>> worker would never reach _inf_. Because the lb_factor is < 1 if >>> lb_value wasn't 0. After choosing the worker this value is added to >>> the lb_value. But with a high value for lb_value the differenc >>> between two savable double numbers is greater than the lb_factor. But >>> this is only interessting in theory. I think in real world we will >>> reboot apache before this will happen :). >> >> >> >> That may become a problem if we use ints. >> >> Costin >> >> >> > [...] > > -- Dipl.-Inform. Bernd Koecke UNIX-Entwicklung Schlund+Partner AG Fon: +49-721-91374-0 E-Mail: [EMAIL PROTECTED]
Index: jk_lb_worker.c =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c,v retrieving revision 1.8 diff -u -r1.8 jk_lb_worker.c --- jk_lb_worker.c 12 Jan 2002 05:27:39 -0000 1.8 +++ jk_lb_worker.c 3 May 2002 17:17:35 -0000 @@ -291,7 +291,12 @@ } } - if(rc) { + /* + * The following isn't necessary, because for the 'main' worker + * lb_value and lb_factor are == 0. And all other worker have a value > 0 + * But it makes the intention clearer. + */ + if(rc && rc->lb_value != 0) { rc->lb_value += rc->lb_factor; } @@ -329,7 +334,7 @@ int src = end->service(end, s, l, &is_recoverable); end->done(&end, l); if(src) { - if(rec->in_recovering) { + if(rec->in_recovering && rec->lb_value != 0) { rec->lb_value = get_max_lb(p->worker) + ADDITINAL_WAIT_LOAD; } rec->in_error_state = JK_FALSE; @@ -433,13 +438,23 @@ p->lb_workers[i].name = jk_pool_strdup(&p->p, worker_names[i]); p->lb_workers[i].lb_factor = jk_get_lb_factor(props, worker_names[i]); - p->lb_workers[i].lb_factor = 1/p->lb_workers[i].lb_factor; + if (p->lb_workers[i].lb_factor < 0) { + p->lb_workers[i].lb_factor = -1 * p->lb_workers[i].lb_factor; + } + if (0 < p->lb_workers[i].lb_factor) { + p->lb_workers[i].lb_factor = 1/p->lb_workers[i].lb_factor; + } /* * Allow using lb in fault-tolerant mode. * Just set lbfactor in worker.properties to 0 to have * a worker used only when principal is down or session route * point to it. Provided by Paul Frieden <[EMAIL PROTECTED]> */ + /* + * The above comment should be fixed because it is vice versa: + * A worker with lb_factor == 0 is always asked and only with a + * session another worker would get the request + */ p->lb_workers[i].lb_value = p->lb_workers[i].lb_factor; p->lb_workers[i].in_error_state = JK_FALSE; p->lb_workers[i].in_recovering = JK_FALSE;
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>