Re: [JK] Shared memory design problems

2012-03-30 Thread Le Huy
Have you look at how mod_proxy solves this issue, it seems that it
does not suffer the problem that we are experiencing , and also does
not need any share memory file.


On Wed, Mar 28, 2012 at 2:32 PM, Mladen Turk mt...@apache.org wrote:
 On 03/28/2012 02:01 PM, jean-frederic clere wrote:

 What about a look on file that contains the id? It gets created and lock
 by the first worker that needs the shared memory and writes the id inside
 and unlock the file? Other workers will just read the id in the file.


 I started to work on 'get by id' record/slot concept.
 There are many advantages over the 'presume we have a correct order'

 Currently if someone reorders worker list everything breaks apart
 or at least gets overwritten by something else.

 The idea is that instead going trough worker/member list and
 allocate next free slot, we actually search if the object with
 the same id (combination of name, type and parent) exists and
 if not then actually create a new shm record.

 This would mean that jk_shm_alloc_xxx won't reset data on
 each restart (done by single proc in httpd and multiple in IIS)
 Thus the sequence will actually be what it is: config update.


 Regards
 --
 ^TM


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


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



Re: tomcat connector - jk_status does not update shm correctly

2012-03-26 Thread Le Huy
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-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: dev-h...@tomcat.apache.org


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



tomcat connector - jk_status does not update shm correctly

2012-03-25 Thread Le Huy
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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org