You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2011/09/22 20:01:32 UTC

svn commit: r1174289 - in /tomcat/jk/trunk: native/apache-1.3/ native/apache-2.0/ native/common/ native/iis/ xdocs/miscellaneous/ xdocs/reference/

Author: rjung
Date: Thu Sep 22 18:01:31 2011
New Revision: 1174289

URL: http://svn.apache.org/viewvc?rev=1174289&view=rev
Log:
- URI Map: Add "sticky_ignore" extension attributes to uri worker map.
  It allows to disable stickyness for individual mounts.

- HTTPD: Allow dynamic disabling of stickyness using the environment
  variable JK_STICKY_IGNORE. This can be useful to break cookie stickyness
  for non-sticky requests like login forms.

Modified:
    tomcat/jk/trunk/native/apache-1.3/mod_jk.c
    tomcat/jk/trunk/native/apache-2.0/mod_jk.c
    tomcat/jk/trunk/native/common/jk_lb_worker.c
    tomcat/jk/trunk/native/common/jk_service.h
    tomcat/jk/trunk/native/common/jk_status.c
    tomcat/jk/trunk/native/common/jk_uri_worker_map.c
    tomcat/jk/trunk/native/common/jk_uri_worker_map.h
    tomcat/jk/trunk/native/common/jk_util.c
    tomcat/jk/trunk/native/iis/jk_isapi_plugin.c
    tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
    tomcat/jk/trunk/xdocs/reference/apache.xml
    tomcat/jk/trunk/xdocs/reference/uriworkermap.xml
    tomcat/jk/trunk/xdocs/reference/workers.xml

Modified: tomcat/jk/trunk/native/apache-1.3/mod_jk.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-1.3/mod_jk.c?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/apache-1.3/mod_jk.c (original)
+++ tomcat/jk/trunk/native/apache-1.3/mod_jk.c Thu Sep 22 18:01:31 2011
@@ -79,6 +79,7 @@
 #define JK_ENV_KEY_SIZE             ("SSL_CIPHER_USEKEYSIZE")
 #define JK_ENV_CERTCHAIN_PREFIX     ("SSL_CLIENT_CERT_CHAIN_")
 #define JK_ENV_REPLY_TIMEOUT        ("JK_REPLY_TIMEOUT")
+#define JK_ENV_STICKY_IGNORE        ("JK_STICKY_IGNORE")
 #define JK_ENV_WORKER_NAME          ("JK_WORKER_NAME")
 #define JK_NOTE_WORKER_NAME         ("JK_WORKER_NAME")
 #define JK_NOTE_WORKER_TYPE         ("JK_WORKER_TYPE")
@@ -679,6 +680,7 @@ static int init_ws_service(apache_privat
     request_rec *r = private_data->r;
     char *ssl_temp = NULL;
     const char *reply_timeout = NULL;
+    const char *sticky_ignore = NULL;
     rule_extension_t *e;
 
     /* Copy in function pointers (which are really methods) */
@@ -726,6 +728,7 @@ static int init_ws_service(apache_privat
     e = (rule_extension_t *)ap_get_module_config(r->request_config, &jk_module);
     if (e) {
         s->extension.reply_timeout = e->reply_timeout;
+        s->extension.sticky_ignore = e->sticky_ignore;
         s->extension.use_server_error_pages = e->use_server_error_pages;
         if (e->activation) {
             s->extension.activation = ap_palloc(r->pool, e->activation_size * sizeof(int));
@@ -744,6 +747,22 @@ static int init_ws_service(apache_privat
             s->extension.reply_timeout = r;
     }
 
+    sticky_ignore = ap_table_get(r->subprocess_env, JK_ENV_STICKY_IGNORE);
+    if (sticky_ignore) {
+        if (*sticky_ignore == '\0') {
+            s->extension.reply_timeout = JK_TRUE;
+        }
+        else {
+            int r = atoi(sticky_ignore);
+            if (r) {
+                s->extension.reply_timeout = JK_TRUE;
+            }
+            else {
+                s->extension.reply_timeout = JK_FALSE;
+            }
+        }
+    }
+
     if (conf->options & JK_OPT_DISABLEREUSE)
         s->disable_reuse = 1;
 

Modified: tomcat/jk/trunk/native/apache-2.0/mod_jk.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-2.0/mod_jk.c?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/apache-2.0/mod_jk.c (original)
+++ tomcat/jk/trunk/native/apache-2.0/mod_jk.c Thu Sep 22 18:01:31 2011
@@ -114,6 +114,7 @@
 #define JK_ENV_KEY_SIZE             ("SSL_CIPHER_USEKEYSIZE")
 #define JK_ENV_CERTCHAIN_PREFIX     ("SSL_CLIENT_CERT_CHAIN_")
 #define JK_ENV_REPLY_TIMEOUT        ("JK_REPLY_TIMEOUT")
+#define JK_ENV_STICKY_IGNORE        ("JK_STICKY_IGNORE")
 #define JK_ENV_WORKER_NAME          ("JK_WORKER_NAME")
 #define JK_NOTE_WORKER_NAME         ("JK_WORKER_NAME")
 #define JK_NOTE_WORKER_TYPE         ("JK_WORKER_TYPE")
@@ -734,6 +735,7 @@ static int init_ws_service(apache_privat
     request_rec *r = private_data->r;
     char *ssl_temp = NULL;
     const char *reply_timeout = NULL;
+    const char *sticky_ignore = NULL;
     rule_extension_t *e;
 
     /* Copy in function pointers (which are really methods) */
@@ -780,6 +782,7 @@ static int init_ws_service(apache_privat
     e = (rule_extension_t *)ap_get_module_config(r->request_config, &jk_module);
     if (e) {
         s->extension.reply_timeout = e->reply_timeout;
+        s->extension.sticky_ignore = e->sticky_ignore;
         s->extension.use_server_error_pages = e->use_server_error_pages;
         if (e->activation) {
             s->extension.activation = apr_palloc(r->pool, e->activation_size * sizeof(int));
@@ -798,6 +801,22 @@ static int init_ws_service(apache_privat
             s->extension.reply_timeout = r;
     }
 
+    sticky_ignore = apr_table_get(r->subprocess_env, JK_ENV_STICKY_IGNORE);
+    if (sticky_ignore) {
+        if (*sticky_ignore == '\0') {
+            s->extension.reply_timeout = JK_TRUE;
+        }
+        else {
+            int r = atoi(sticky_ignore);
+            if (r) {
+                s->extension.reply_timeout = JK_TRUE;
+            }
+            else {
+                s->extension.reply_timeout = JK_FALSE;
+            }
+        }
+    }
+
     if (conf->options & JK_OPT_DISABLEREUSE)
         s->disable_reuse = 1;
 

Modified: tomcat/jk/trunk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_lb_worker.c?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_lb_worker.c (original)
+++ tomcat/jk/trunk/native/common/jk_lb_worker.c Thu Sep 22 18:01:31 2011
@@ -1118,9 +1118,9 @@ static int JK_METHOD service(jk_endpoint
     jk_b_reset(s->reco_buf);
     s->reco_status = RECO_INITED;
 
-    if (p->worker->sticky_session) {
+    if (p->worker->sticky_session && s->extension.sticky_ignore != JK_TRUE) {
         /* Use sessionid only if sticky_session is
-         * defined for this load balancer
+         * defined and not overwritten for this load balancer
          */
         sessionid = get_sessionid(s, p->worker, l);
     }

Modified: tomcat/jk/trunk/native/common/jk_service.h
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_service.h?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_service.h (original)
+++ tomcat/jk/trunk/native/common/jk_service.h Thu Sep 22 18:01:31 2011
@@ -82,6 +82,8 @@ struct svc_extension
 {
     /* reply_timeout overwrite */
     int reply_timeout;
+    /* Whether to ignore session routing info */
+    int sticky_ignore;
     /* activation state overwrites for load balancers */
     /* Dynamically allocated array with one entry per lb member. */
     int *activation;

Modified: tomcat/jk/trunk/native/common/jk_status.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_status.c?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_status.c (original)
+++ tomcat/jk/trunk/native/common/jk_status.c Thu Sep 22 18:01:31 2011
@@ -231,10 +231,10 @@
 #define JK_STATUS_FORM_START               "<form method=\"%s\" action=\"%s\">\n"
 #define JK_STATUS_FORM_HIDDEN_INT          "<input type=\"hidden\" name=\"%s\" value=\"%d\"/>\n"
 #define JK_STATUS_FORM_HIDDEN_STRING       "<input type=\"hidden\" name=\"%s\" value=\"%s\"/>\n"
-#define JK_STATUS_URI_MAP_TABLE_HEAD       "<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n"
-#define JK_STATUS_URI_MAP_TABLE_ROW        "<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n"
-#define JK_STATUS_URI_MAP_TABLE_HEAD2      "<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n"
-#define JK_STATUS_URI_MAP_TABLE_ROW2       "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n"
+#define JK_STATUS_URI_MAP_TABLE_HEAD       "<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n"
+#define JK_STATUS_URI_MAP_TABLE_ROW        "<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n"
+#define JK_STATUS_URI_MAP_TABLE_HEAD2      "<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n"
+#define JK_STATUS_URI_MAP_TABLE_ROW2       "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n"
 #define JK_STATUS_SHOW_AJP_CONF_HEAD       "<tr>" \
                                            "<th>Type</th>" \
                                            "<th>" JK_STATUS_ARG_AJP_TEXT_HOST_STR "</th>" \
@@ -1549,6 +1549,7 @@ static void display_map(jk_ws_service_t 
                           uri_worker_map_get_match(uwr, buf, l),
                           uri_worker_map_get_source(uwr, l),
                           uwr->extensions.reply_timeout,
+                          uwr->extensions.sticky_ignore,
                           uwr->extensions.fail_on_status_str ? uwr->extensions.fail_on_status_str : "-",
                           uwr->extensions.active ? uwr->extensions.active : "-",
                           uwr->extensions.disabled ? uwr->extensions.disabled : "-",
@@ -1560,6 +1561,7 @@ static void display_map(jk_ws_service_t 
                           uri_worker_map_get_match(uwr, buf, l),
                           uri_worker_map_get_source(uwr, l),
                           uwr->extensions.reply_timeout,
+                          uwr->extensions.sticky_ignore,
                           uwr->extensions.fail_on_status_str ? uwr->extensions.fail_on_status_str : "-",
                           uwr->extensions.active ? uwr->extensions.active : "-",
                           uwr->extensions.disabled ? uwr->extensions.disabled : "-",
@@ -1575,6 +1577,7 @@ static void display_map(jk_ws_service_t 
             jk_print_xml_att_string(s, 8, "type", uri_worker_map_get_match(uwr, buf, l));
             jk_print_xml_att_string(s, 8, "source", uri_worker_map_get_source(uwr, l));
             jk_print_xml_att_int(s, 8, "reply_timeout", uwr->extensions.reply_timeout);
+            jk_print_xml_att_int(s, 8, "sticky_ignore", uwr->extensions.sticky_ignore);
             jk_print_xml_att_string(s, 8, "fail_on_status", uwr->extensions.fail_on_status_str);
             jk_print_xml_att_string(s, 8, "active", uwr->extensions.active);
             jk_print_xml_att_string(s, 8, "disabled", uwr->extensions.disabled);
@@ -1591,6 +1594,7 @@ static void display_map(jk_ws_service_t 
             jk_printf(s, " type=\"%s\"", uri_worker_map_get_match(uwr, buf, l));
             jk_printf(s, " source=\"%s\"", uri_worker_map_get_source(uwr, l));
             jk_printf(s, " reply_timeout=\"%d\"", uwr->extensions.reply_timeout);
+            jk_printf(s, " sticky_ignore=\"%d\"", uwr->extensions.sticky_ignore);
             jk_printf(s, " fail_on_status=\"%s\"", uwr->extensions.fail_on_status_str ? uwr->extensions.fail_on_status_str : "");
             jk_printf(s, " active=\"%s\"", uwr->extensions.active ? uwr->extensions.active : "");
             jk_printf(s, " disabled=\"%s\"", uwr->extensions.disabled ? uwr->extensions.disabled : "");
@@ -1605,6 +1609,7 @@ static void display_map(jk_ws_service_t 
             jk_print_prop_item_string(s, w, worker, "map", count, "type", uri_worker_map_get_match(uwr, buf, l));
             jk_print_prop_item_string(s, w, worker, "map", count, "source", uri_worker_map_get_source(uwr, l));
             jk_print_prop_item_int(s, w, worker, "map", count, "reply_timeout", uwr->extensions.reply_timeout);
+            jk_print_prop_item_int(s, w, worker, "map", count, "sticky_ignore", uwr->extensions.sticky_ignore);
             jk_print_prop_item_string(s, w, worker, "map", count, "fail_on_status", uwr->extensions.fail_on_status_str);
             jk_print_prop_item_string(s, w, worker, "map", count, "active", uwr->extensions.active);
             jk_print_prop_item_string(s, w, worker, "map", count, "disabled", uwr->extensions.disabled);
@@ -1659,10 +1664,10 @@ static void display_maps(jk_ws_service_t
             jk_puts(s, "]</h3><table>\n");
             if (has_server_iterator)
                 jk_printf(s, JK_STATUS_URI_MAP_TABLE_HEAD2,
-                          "Server", "URI", "Match Type", "Source", "Reply Timeout", "Fail on Status", "Active", "Disabled", "Stopped", "Use Server Errors");
+                          "Server", "URI", "Match Type", "Source", "Reply Timeout", "Sticky Ignore", "Fail on Status", "Active", "Disabled", "Stopped", "Use Server Errors");
             else
                 jk_printf(s, JK_STATUS_URI_MAP_TABLE_HEAD,
-                          "URI", "Match Type", "Source", "Reply Timeout", "Fail on Status", "Active", "Disabled", "Stopped", "Use Server Errors");
+                          "URI", "Match Type", "Source", "Reply Timeout", "Sticky Ignore", "Fail on Status", "Active", "Disabled", "Stopped", "Use Server Errors");
         }
         count = 0;
         if (has_server_iterator) {

Modified: tomcat/jk/trunk/native/common/jk_uri_worker_map.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_uri_worker_map.c?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_uri_worker_map.c (original)
+++ tomcat/jk/trunk/native/common/jk_uri_worker_map.c Thu Sep 22 18:01:31 2011
@@ -40,6 +40,7 @@
 #endif
 
 #define JK_UWMAP_EXTENSION_REPLY_TIMEOUT  "reply_timeout="
+#define JK_UWMAP_EXTENSION_STICKY_IGNORE  "sticky_ignore="
 #define JK_UWMAP_EXTENSION_ACTIVE         "active="
 #define JK_UWMAP_EXTENSION_DISABLED       "disabled="
 #define JK_UWMAP_EXTENSION_STOPPED        "stopped="
@@ -637,6 +638,7 @@ int uri_worker_map_add(jk_uri_worker_map
 
         w = jk_pool_strdup(p, worker);
         uwr->extensions.reply_timeout = -1;
+        uwr->extensions.sticky_ignore = JK_FALSE;
         uwr->extensions.active = NULL;
         uwr->extensions.disabled = NULL;
         uwr->extensions.stopped = NULL;
@@ -661,6 +663,15 @@ int uri_worker_map_add(jk_uri_worker_map
                 if (!strncmp(param, JK_UWMAP_EXTENSION_REPLY_TIMEOUT, strlen(JK_UWMAP_EXTENSION_REPLY_TIMEOUT))) {
                     uwr->extensions.reply_timeout = atoi(param + strlen(JK_UWMAP_EXTENSION_REPLY_TIMEOUT));
                 }
+                else if (!strncmp(param, JK_UWMAP_EXTENSION_STICKY_IGNORE, strlen(JK_UWMAP_EXTENSION_STICKY_IGNORE))) {
+                    int val = atoi(param + strlen(JK_UWMAP_EXTENSION_STICKY_IGNORE));
+                    if (val) {
+                        uwr->extensions.sticky_ignore = JK_TRUE;
+                    }
+                    else {
+                        uwr->extensions.sticky_ignore = JK_FALSE;
+                    }
+                }
                 else if (!strncmp(param, JK_UWMAP_EXTENSION_USE_SRV_ERRORS, strlen(JK_UWMAP_EXTENSION_USE_SRV_ERRORS))) {
                     uwr->extensions.use_server_error_pages = atoi(param + strlen(JK_UWMAP_EXTENSION_USE_SRV_ERRORS));
                 }

Modified: tomcat/jk/trunk/native/common/jk_uri_worker_map.h
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_uri_worker_map.h?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_uri_worker_map.h (original)
+++ tomcat/jk/trunk/native/common/jk_uri_worker_map.h Thu Sep 22 18:01:31 2011
@@ -73,6 +73,8 @@ struct rule_extension
 {
     /* reply_timeout overwrite */
     int reply_timeout;
+    /* Whether to ignore session routing info */
+    int sticky_ignore;
     /* activation state overwrites for load balancers */
     /* Number of elements in the array activations. */
     int activation_size;

Modified: tomcat/jk/trunk/native/common/jk_util.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_util.c?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_util.c (original)
+++ tomcat/jk/trunk/native/common/jk_util.c Thu Sep 22 18:01:31 2011
@@ -2075,6 +2075,7 @@ void jk_init_ws_service(jk_ws_service_t 
     s->flush_packets = JK_FALSE;
     s->flush_header = JK_FALSE;
     s->extension.reply_timeout = -1;
+    s->extension.sticky_ignore = JK_FALSE;
     s->extension.use_server_error_pages = 0;
     s->extension.activation = NULL;
     s->extension.fail_on_status_size = 0;

Modified: tomcat/jk/trunk/native/iis/jk_isapi_plugin.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/iis/jk_isapi_plugin.c?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/native/iis/jk_isapi_plugin.c (original)
+++ tomcat/jk/trunk/native/iis/jk_isapi_plugin.c Thu Sep 22 18:01:31 2011
@@ -3084,6 +3084,7 @@ static int init_ws_service(isapi_private
         if (JK_IS_DEBUG_LEVEL(logger))
             jk_log(logger, JK_LOG_DEBUG, "Applying service extensions" );
         s->extension.reply_timeout = e->reply_timeout;
+        s->extension.sticky_ignore = e->sticky_ignore;
         s->extension.use_server_error_pages = e->use_server_error_pages;
         if (e->activation) {
             s->extension.activation = jk_pool_alloc(s->pool, e->activation_size * sizeof(int));

Modified: tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml Thu Sep 22 18:01:31 2011
@@ -40,6 +40,22 @@
   new documentation project for JK was started.
   </p>
 </section>
+<section name="Changes between 1.2.32 and 1.2.33">
+  <br />
+  <subsection name="Native">
+    <changelog>
+      <add>
+        URI Map: Add "sticky_ignore" extension attributes to uri worker map.
+        It allows to disable stickyness for individual mounts. (rjung)
+      </add>
+      <add>
+        HTTPD: Allow dynamic disabling of stickyness using the environment
+        variable JK_STICKY_IGNORE. This can be useful to break cookie stickyness
+        for non-sticky requests like login forms. (rjung)
+      </add>
+    </changelog>
+  </subsection>
+</section>
 <section name="Changes between 1.2.31 and 1.2.32">
   <br />
   <subsection name="Native">

Modified: tomcat/jk/trunk/xdocs/reference/apache.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/reference/apache.xml?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/reference/apache.xml (original)
+++ tomcat/jk/trunk/xdocs/reference/apache.xml Thu Sep 22 18:01:31 2011
@@ -1120,6 +1120,24 @@ for more complex rules to change the <b>
 to request properties like e.g. the request URI.
 This is available since version 1.2.27.
 </p>
+<p>
+The environment variable
+<b>JK_IGNORE_STICKY</b> can be set to disable session stickyness
+for individual requests. If the variable is set to an empty string
+or a nonzero number, session stickyness will be disabled. Setting
+it to <b>0</b> will reset to the behaviour defined by the worker
+configuration.
+This is available since version 1.2.33.
+</p>
+<p>
+This feature can be useful to optimize load balancing when using
+cookie based session stickyness. In this case, as long as she keeps
+her browser open, any request by a user who started a session will
+be send to the same Tomcat instance, even if he left the part of
+the application which uses the session. You can for instance
+set this environment variable when a user requests a login form
+to ensure, that this initial session request is balanced non-sticky.
+</p>
 </subsection>
  </section>
 </body>

Modified: tomcat/jk/trunk/xdocs/reference/uriworkermap.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/reference/uriworkermap.xml?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/reference/uriworkermap.xml (original)
+++ tomcat/jk/trunk/xdocs/reference/uriworkermap.xml Thu Sep 22 18:01:31 2011
@@ -246,6 +246,27 @@ For a general description of reply timeo
 <a href="../generic_howto/timeouts.html#Reply Timeout">timeouts</a> documentation.
 </p>
 </subsection>
+<subsection name="Extension sticky_ignore">
+<br/>
+<p>
+The extension <code>sticky_ignore</code> can disable session stickyness for a single mapping rule.
+<source>
+  # Disable session stickyness
+  # only for this mapping.
+  /myapp/loginform.jsp=myworker;sticky_ignore=1
+</source>
+This extension can be useful to optimize load balancing when using
+cookie based session stickyness. In this case, as long as she keeps
+her browser open, any request by a user who started a session will
+be send to the same Tomcat instance, even if he left the part of
+the application which uses the session. You can for instance
+set this environment variable when a user requests a login form
+to ensure, that this initial session request is balanced non-sticky.
+</p>
+<p>
+This extension is available since version 1.2.33.
+</p>
+</subsection>
 <subsection name="Extensions active/disabled/stopped">
 <br/>
 <p>

Modified: tomcat/jk/trunk/xdocs/reference/workers.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/reference/workers.xml?rev=1174289&r1=1174288&r2=1174289&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/reference/workers.xml (original)
+++ tomcat/jk/trunk/xdocs/reference/workers.xml Thu Sep 22 18:01:31 2011
@@ -503,6 +503,11 @@ Tomcat worker. If sticky_session is set 
 sticky_session is set to <b>False</b>. Set sticky_session to <b>False</b> when Tomcat
 is using a Session Manager which can persist session data across multiple
 instances of Tomcat.
+<p>
+The <b>sticky_session</b> setting can be overwritten using the Apache httpd
+environment variable <b>JK_STICKY_IGNORE</b> and the worker map extension for
+<b>sticky_ignore</b>. This has been added in version <b>1.2.33</b>.
+</p>
 </directive>
 
 <directive name="sticky_session_force" default="False" required="false">



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


Re: svn commit: r1174289 - in /tomcat/jk/trunk: native/apache-1.3/ native/apache-2.0/ native/common/ native/iis/ xdocs/miscellaneous/ xdocs/reference/

Posted by Rainer Jung <ra...@kippdata.de>.
On 22.09.2011 20:33, Konstantin Kolinko wrote:
> 2011/9/22  <rj...@apache.org>:
>> Author: rjung
>> Date: Thu Sep 22 18:01:31 2011
>> New Revision: 1174289
>>
>> URL: http://svn.apache.org/viewvc?rev=1174289&view=rev
>> Log:
>> - URI Map: Add "sticky_ignore" extension attributes to uri worker map.
>>  It allows to disable stickyness for individual mounts.
>>
>> - HTTPD: Allow dynamic disabling of stickyness using the environment
>>  variable JK_STICKY_IGNORE. This can be useful to break cookie stickyness
>>  for non-sticky requests like login forms.
>>
>> Modified:
>>    tomcat/jk/trunk/native/apache-1.3/mod_jk.c
>>    tomcat/jk/trunk/native/apache-2.0/mod_jk.c
>>    tomcat/jk/trunk/native/common/jk_lb_worker.c
>>    tomcat/jk/trunk/native/common/jk_service.h
>>    tomcat/jk/trunk/native/common/jk_status.c
>>    tomcat/jk/trunk/native/common/jk_uri_worker_map.c
>>    tomcat/jk/trunk/native/common/jk_uri_worker_map.h
>>    tomcat/jk/trunk/native/common/jk_util.c
>>    tomcat/jk/trunk/native/iis/jk_isapi_plugin.c
>>    tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
>>    tomcat/jk/trunk/xdocs/reference/apache.xml
>>    tomcat/jk/trunk/xdocs/reference/uriworkermap.xml
>>    tomcat/jk/trunk/xdocs/reference/workers.xml
>>
>> Modified: tomcat/jk/trunk/native/apache-1.3/mod_jk.c
>> URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-1.3/mod_jk.c?rev=1174289&r1=1174288&r2=1174289&view=diff
>>
> ==============================================================================
> (...)
>> +    sticky_ignore = ap_table_get(r->subprocess_env, JK_ENV_STICKY_IGNORE);
>> +    if (sticky_ignore) {
>> +        if (*sticky_ignore == '\0') {
>> +            s->extension.reply_timeout = JK_TRUE;
> 
> You are assigning to a wrong option!
> Below and in httpd 2.0 version as well.

Copy&Paste - thanks a million - fixed in r1174314.

> Also the above means that if the variable is present, but has empty
> value, it is threated as true? This flag is false by default
> elsewhere.

Yes, I made a difference here betwenn the env var and the extension.
Usually if an env var flags a boolean value, setting the variable is
assumed to be equal to true. Setting it to "0" is supported here to
reset, because onemight end up with a set of RewriteRules setting the
env var and not all 2.2 version support unsetting in RewriteRule.

For the worker map extension it seems not necessary, because a more
special rule can simply omit the extension.

P.S.: I hope the use case in the docs is understandable. I didn't want
to make it to long.

The idea is: Once a cookie is set, there is some likelihood, that a user
might come back to the app with the old session cookie, but in fact
without a resuable session. Until now we would still route him to the
old node, which might be bad, e.g. if we want to drain it, or if we want
to balance with the session count method. So we allow the admin to
configure a URL which he knows is an entry point to the application and
does not yet need stickyness.

Anotherway would be mod_headers tricking into deleteingthe JSESSIONID
cookie before mod_jk checks it, but that is much more complicated.

In addition, the JK_STICKY_IGNORE also "resets" stickyness, if the user
came back via a bookmark with a jsessionid encoded. As soon as he
requests the configured URL we will send him to a non-sticky node.

I plan to add to additional features:

a) round robin balancing
b) ability to mark requests as not influencing balancing counter
   (lb_value)

b) improves session load balancing for the session and round-robin
balancing methods. If there is static content, that is not URL encoded,
or that is loaded before the session, until now we count each such
request as a new session. This is not what we want. Of course static
content should be moved to Apache directly and JkUnMounted, but
unfortunately that's not always the case ...

Requests falling into category b), e.g. that have no session id, but we
don't want to take them into account w.r.t. load balancing, I plan to
balance with a separate round-robin index.

Regards,

Rainer

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


Re: svn commit: r1174289 - in /tomcat/jk/trunk: native/apache-1.3/ native/apache-2.0/ native/common/ native/iis/ xdocs/miscellaneous/ xdocs/reference/

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/9/22  <rj...@apache.org>:
> Author: rjung
> Date: Thu Sep 22 18:01:31 2011
> New Revision: 1174289
>
> URL: http://svn.apache.org/viewvc?rev=1174289&view=rev
> Log:
> - URI Map: Add "sticky_ignore" extension attributes to uri worker map.
>  It allows to disable stickyness for individual mounts.
>
> - HTTPD: Allow dynamic disabling of stickyness using the environment
>  variable JK_STICKY_IGNORE. This can be useful to break cookie stickyness
>  for non-sticky requests like login forms.
>
> Modified:
>    tomcat/jk/trunk/native/apache-1.3/mod_jk.c
>    tomcat/jk/trunk/native/apache-2.0/mod_jk.c
>    tomcat/jk/trunk/native/common/jk_lb_worker.c
>    tomcat/jk/trunk/native/common/jk_service.h
>    tomcat/jk/trunk/native/common/jk_status.c
>    tomcat/jk/trunk/native/common/jk_uri_worker_map.c
>    tomcat/jk/trunk/native/common/jk_uri_worker_map.h
>    tomcat/jk/trunk/native/common/jk_util.c
>    tomcat/jk/trunk/native/iis/jk_isapi_plugin.c
>    tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
>    tomcat/jk/trunk/xdocs/reference/apache.xml
>    tomcat/jk/trunk/xdocs/reference/uriworkermap.xml
>    tomcat/jk/trunk/xdocs/reference/workers.xml
>
> Modified: tomcat/jk/trunk/native/apache-1.3/mod_jk.c
> URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-1.3/mod_jk.c?rev=1174289&r1=1174288&r2=1174289&view=diff
>
==============================================================================
(...)
> +    sticky_ignore = ap_table_get(r->subprocess_env, JK_ENV_STICKY_IGNORE);
> +    if (sticky_ignore) {
> +        if (*sticky_ignore == '\0') {
> +            s->extension.reply_timeout = JK_TRUE;

You are assigning to a wrong option!
Below and in httpd 2.0 version as well.

Also the above means that if the variable is present, but has empty
value, it is threated as true? This flag is false by default
elsewhere.

> +        }
> +        else {
> +            int r = atoi(sticky_ignore);
> +            if (r) {
> +                s->extension.reply_timeout = JK_TRUE;
> +            }
> +            else {
> +                s->extension.reply_timeout = JK_FALSE;
> +            }
> +        }
> +    }
> +
>     if (conf->options & JK_OPT_DISABLEREUSE)
>         s->disable_reuse = 1;

>
>
> Modified: tomcat/jk/trunk/native/apache-2.0/mod_jk.c
> URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-2.0/mod_jk.c?rev=1174289&r1=1174288&r2=1174289&view=diff
>
==============================================================================
> --- tomcat/jk/trunk/native/apache-2.0/mod_jk.c (original)
> +++ tomcat/jk/trunk/native/apache-2.0/mod_jk.c Thu Sep 22 18:01:31 2011
(...)
> @@ -798,6 +801,22 @@ static int init_ws_service(apache_privat
>             s->extension.reply_timeout = r;
>     }
>
> +    sticky_ignore = apr_table_get(r->subprocess_env, JK_ENV_STICKY_IGNORE);
> +    if (sticky_ignore) {
> +        if (*sticky_ignore == '\0') {
> +            s->extension.reply_timeout = JK_TRUE;

Here as well.

> +        }
> +        else {
> +            int r = atoi(sticky_ignore);
> +            if (r) {
> +                s->extension.reply_timeout = JK_TRUE;
> +            }
> +            else {
> +                s->extension.reply_timeout = JK_FALSE;
> +            }
> +        }
> +    }
> +
>     if (conf->options & JK_OPT_DISABLEREUSE)
>         s->disable_reuse = 1;
>
>

Best regards,
Konstantin Kolinko

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