You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Le Huy <le...@gmail.com> on 2012/03/25 23:00:59 UTC

tomcat connector - jk_status does not update shm correctly

Hi

I am facing problem in using jkstatus to update subworker lb_factor,
it seems that after changing it, the mod_jk balancer does not change
anything

Looking at source code in trunk, I think that there is bug , I
include herewith the 2 changes that I think will fix the problem,

1) I move update_mult() a head of  jk_lb_push() in update_worker() so
the lb_mult of sub worker can be persisted to shm
2) I reverse the condition using to guard of update shm of subworkder
in jk_lb_push()


Can someone review it ? to be honest I am not very familiar with the code base.



Index: native/common/jk_status.c
===================================================================
--- native/common/jk_status.c   (revision 1305015)
+++ native/common/jk_status.c   (working copy)
@@ -4161,6 +4161,9 @@
                if (rv & JK_STATUS_NEEDS_ADDR_PUSH) {
                    aw->addr_sequence++;
                }
+                if (rv & JK_STATUS_NEEDS_UPDATE_MULT)
+                    /* Recalculate the load multiplicators wrt. lb_factor */
+                    update_mult(lb, l);
                if (rv & (JK_STATUS_NEEDS_PUSH | JK_STATUS_NEEDS_ADDR_PUSH)) {
                    wr->sequence++;
                    lb->sequence++;
@@ -4168,9 +4171,6 @@
                }
                if (rv & JK_STATUS_NEEDS_RESET_LB_VALUES)
                    reset_lb_values(lb, l);
-                if (rv & JK_STATUS_NEEDS_UPDATE_MULT)
-                    /* Recalculate the load multiplicators wrt. lb_factor */
-                    update_mult(lb, l);
                if (rc == JK_FALSE) {
                    jk_log(l, JK_LOG_ERROR,
                           "Status worker '%s' failed updating sub
worker '%s' (at least partially).%s",
Index: native/common/jk_lb_worker.c
===================================================================
--- native/common/jk_lb_worker.c        (revision 1305015)
+++ native/common/jk_lb_worker.c        (working copy)
@@ -370,7 +370,7 @@

    for (i = 0; i < p->num_of_workers; i++) {
        lb_sub_worker_t *w = &p->lb_workers[i];
-        if (w->sequence < w->s->h.sequence) {
+        if (w->sequence > w->s->h.sequence) {
            jk_worker_t *jw = w->worker;
            ajp_worker_t *aw = (ajp_worker_t *)jw->worker_private;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: tomcat connector - jk_status does not update shm correctly

Posted by Le Huy <le...@gmail.com>.
Thank for clarification


1) in unix if we do not update lb_mult of worker then push it to shm
storage and indicate other processes to pull it from shm storage then
how other processes know that the balancer was changed and act
accordingly ?

Looking at static void commit_all_members(), there is clear that the
update_mult is performed correctly before  jk_lb_push

3657         else if (rc == 2)
3658             /* Recalculate the load multiplicators wrt. lb_factor */
3659             update_mult(lb, l);
3660         if (rc) {
3661             lb->sequence++;
3662             jk_lb_push(lb, JK_TRUE, l);
3663         }

2) As I understand there are jk_lb_pull which sync mem from shm to
heap and jk_lb_push which sync from mem to shm.  So when we need to
update shm  we will increase sequence of mem of one process   by doing
this sequence of mem is ahead of shm then call jk_lb_push to copy  mem
including its sequence to shm.
Other process has mem's sequence behind shm's sequence thus will call
jk_lb_pull to copy data from shm to its heap.

Finally   all processes will have sequence of their mem same as shm.



On Mon, Mar 26, 2012 at 12:49 PM, Mladen Turk <mt...@apache.org> wrote:
> On 03/25/2012 11:00 PM, Le Huy wrote:
>>
>> Hi
>>
>> I am facing problem in using jkstatus to update subworker lb_factor,
>> it seems that after changing it, the mod_jk balancer does not change
>> anything
>>
>> Looking at source code in trunk, I think that there is bug , I
>> include herewith the 2 changes that I think will fix the problem,
>>
>
> It won't fix the problems.
> It'll cause IIS to crash on recycle.
>
> Think that the entire jkstatus needs to get reviewed
> cause the current code is  unnecessary complex.
>
>>
>>     for (i = 0; i<  p->num_of_workers; i++) {
>>         lb_sub_worker_t *w =&p->lb_workers[i];
>> -        if (w->sequence<  w->s->h.sequence) {
>> +        if (w->sequence>  w->s->h.sequence) {
>
>
> That's not correct.
> The shared memory needs to get incremented on change
> and heap memory updated when its sequence is behind
> the shared memory. It is illegal to have heap memory
> 'newer' then the content of shared memory.
>
>
>
> Regards
> --
> ^TM
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: tomcat connector - jk_status does not update shm correctly

Posted by Rainer Jung <ra...@kippdata.de>.
On 26.03.2012 12:49, Mladen Turk wrote:
> On 03/25/2012 11:00 PM, Le Huy wrote:
>> Hi
>>
>> I am facing problem in using jkstatus to update subworker lb_factor,
>> it seems that after changing it, the mod_jk balancer does not change
>> anything
>>
>> Looking at source code in trunk, I think that there is bug , I
>> include herewith the 2 changes that I think will fix the problem,
>>
>
> It won't fix the problems.
> It'll cause IIS to crash on recycle.
>
> Think that the entire jkstatus needs to get reviewed
> cause the current code is unnecessary complex.
>
>>
>> for (i = 0; i< p->num_of_workers; i++) {
>> lb_sub_worker_t *w =&p->lb_workers[i];
>> - if (w->sequence< w->s->h.sequence) {
>> + if (w->sequence> w->s->h.sequence) {
>
> That's not correct.
> The shared memory needs to get incremented on change
> and heap memory updated when its sequence is behind
> the shared memory. It is illegal to have heap memory
> 'newer' then the content of shared memory.

But that change was in the push function. So heap *is* newer than shared 
and wants to update shared because of that. I agree with the OP that it 
should be ">" instead of "<" here. The other changes in r1302479 look OK 
to me, but that line consitutes a bug in itself independent of lb_mult 
updating. It should prohibit publishing changes of lb member attributes 
done via the status worker during runtime at least when under load the 
other processes had already pulled the previous state (might not occur 
when only clicking a few times).

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: tomcat connector - jk_status does not update shm correctly

Posted by Rainer Jung <ra...@kippdata.de>.
On 26.03.2012 12:49, Mladen Turk wrote:
> On 03/25/2012 11:00 PM, Le Huy wrote:
>> Hi
>>
>> I am facing problem in using jkstatus to update subworker lb_factor,
>> it seems that after changing it, the mod_jk balancer does not change
>> anything
>>
>> Looking at source code in trunk, I think that there is bug , I
>> include herewith the 2 changes that I think will fix the problem,
>>
>
> It won't fix the problems.
> It'll cause IIS to crash on recycle.
>
> Think that the entire jkstatus needs to get reviewed
> cause the current code is unnecessary complex.

I think the OP is also correct with the first patch for fixing the 
handling of lb_mult. Why do you think reordering like he suggests in his 
first patch will cause IIS to crash? It should just update some local 
data first before it gets pushed to shm instead of after pushing. What 
reason for a crash do you see?

Regards,

Rainer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: tomcat connector - jk_status does not update shm correctly

Posted by Mladen Turk <mt...@apache.org>.
On 03/25/2012 11:00 PM, Le Huy wrote:
> Hi
>
> I am facing problem in using jkstatus to update subworker lb_factor,
> it seems that after changing it, the mod_jk balancer does not change
> anything
>
> Looking at source code in trunk, I think that there is bug , I
> include herewith the 2 changes that I think will fix the problem,
>

It won't fix the problems.
It'll cause IIS to crash on recycle.

Think that the entire jkstatus needs to get reviewed
cause the current code is  unnecessary complex.

>
>      for (i = 0; i<  p->num_of_workers; i++) {
>          lb_sub_worker_t *w =&p->lb_workers[i];
> -        if (w->sequence<  w->s->h.sequence) {
> +        if (w->sequence>  w->s->h.sequence) {

That's not correct.
The shared memory needs to get incremented on change
and heap memory updated when its sequence is behind
the shared memory. It is illegal to have heap memory
'newer' then the content of shared memory.



Regards
-- 
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org