You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2008/10/05 13:28:59 UTC

svn commit: r701777 - in /tomcat/connectors/trunk/jk/native/common: jk_lb_worker.c jk_lb_worker.h

Author: mturk
Date: Sun Oct  5 04:28:58 2008
New Revision: 701777

URL: http://svn.apache.org/viewvc?rev=701777&view=rev
Log:
Add and use retry_interval for load balancer. Like with ajp worker retries and retry_interval are used to create multiple calls to get_worker. On retry the internal tables are reset and everything goes again like with new request

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h

Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c?rev=701777&r1=701776&r2=701777&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Sun Oct  5 04:28:58 2008
@@ -1016,7 +1016,7 @@
                              jk_logger_t *l, int *is_error)
 {
     lb_endpoint_t *p;
-    int attempt = 1;
+    int attempt = 0;
     lb_sub_worker_t *prec = NULL;
     int num_of_workers;
     int first = 1;
@@ -1025,6 +1025,7 @@
     int rc = JK_UNSET;
     char *sessionid = NULL;
     int i;
+    int retry;
 
     JK_TRACE_ENTER(l);
 
@@ -1081,9 +1082,31 @@
                "service sticky_session=%d id='%s'",
                p->worker->sticky_session, sessionid ? sessionid : "empty");
 
-    while (attempt <= num_of_workers && recoverable == JK_TRUE) {
-        lb_sub_worker_t *rec =
-            get_most_suitable_worker(s, p->worker, sessionid, p->states, l);
+    while (recoverable == JK_TRUE) {
+        lb_sub_worker_t *rec;
+        if (attempt >= num_of_workers) {
+            retry++;
+            if (retry > p->worker->retries) {
+                /* Done with retrying */
+                break;
+            }
+            if (JK_IS_DEBUG_LEVEL(l))
+                jk_log(l, JK_LOG_DEBUG,
+                       "retry %d, sleeping for %d ms before retrying",
+                       retry, p->worker->retry_interval);
+            jk_sleep(p->worker->retry_interval);
+            /* Pull shared memory if something changed during sleep */
+            jk_shm_lock();
+            if (p->worker->sequence != p->worker->s->h.sequence)
+                jk_lb_pull(p->worker, l);
+            jk_shm_unlock();
+            for (i = 0; i < num_of_workers; i++) {
+                /* Copy the shared state info */
+                p->states[i] = p->worker->lb_workers[i].s->state;
+            }
+            attempt = 0;
+        }
+        rec = get_most_suitable_worker(s, p->worker, sessionid, p->states, l);
         rc = JK_FALSE;
         *is_error = JK_HTTP_SERVER_BUSY;
         /* Do not reuse previous worker, because
@@ -1594,8 +1617,11 @@
 
     p->retries = jk_get_worker_retries(props, p->name,
                                        JK_RETRIES);
+    p->retry_interval =
+            jk_get_worker_retry_interval(props, p->name,
+                                        JK_SLEEP_DEF);
     p->recover_wait_time = jk_get_worker_recover_timeout(props, p->name,
-                                                            WAIT_BEFORE_RECOVER);
+                                                         WAIT_BEFORE_RECOVER);
     if (p->recover_wait_time < 1)
         p->recover_wait_time = 1;
     p->max_reply_timeouts = jk_get_worker_max_reply_timeouts(props, p->name,

Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h?rev=701777&r1=701776&r2=701777&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h Sun Oct  5 04:28:58 2008
@@ -189,6 +189,7 @@
     int          recover_wait_time;
     int          max_reply_timeouts;
     int          retries;
+    int          retry_interval;
     int          lbmethod;
     int          lblock;
     int          maintain_time;



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


Re: svn commit: r701777 - in /tomcat/connectors/trunk/jk/native/common: jk_lb_worker.c jk_lb_worker.h

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Mladen,

mturk@apache.org schrieb:
> +            /* Pull shared memory if something changed during sleep */
> +            jk_shm_lock();
> +            if (p->worker->sequence != p->worker->s->h.sequence)
> +                jk_lb_pull(p->worker, l);
> +            jk_shm_unlock();

I think the new lock - pull -unlock blocks are not needed.
The pull is not relevant for the runtime states, like busyness or error
states. It is only important, after status worker administration changed
configuration related items. Retry cycles last typically sub second, so
whether a configuration change via the status worker influences a retry
or not is not really predictable. I can imagine no scenario, where those
additional pulls before retries are really helpful. What do you think?

Regards,

Rainer


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