From: markt Date: Fri, 19 Nov 2010 16:20:09 +0000 (+0000) Subject: The 60s timeout waiting for session info from other nodes will block processing of... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3f45a5ce806850487cef719870fd0d2dffa26002;p=tomcat7.0 The 60s timeout waiting for session info from other nodes will block processing of all cluster messages. As well as lost session updates, this can result in lost sessions if a fail-over occurs while the messages are being blocked. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1036918 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/core/ContainerBase.java b/java/org/apache/catalina/core/ContainerBase.java index 2b6c78bbb..f45e3fc71 100644 --- a/java/org/apache/catalina/core/ContainerBase.java +++ b/java/org/apache/catalina/core/ContainerBase.java @@ -799,29 +799,32 @@ public abstract class ContainerBase extends LifecycleMBeanBase "' is not unique"); child.setParent(this); // May throw IAE children.put(child.getName(), child); + } - // Start child - if ((getState().isAvailable() || - LifecycleState.STARTING_PREP.equals(getState())) && - startChildren) { - boolean success = false; - try { - child.start(); - success = true; - } catch (LifecycleException e) { - log.error("ContainerBase.addChild: start: ", e); - throw new IllegalStateException - ("ContainerBase.addChild: start: " + e); - } finally { - if (!success) { + // Start child + // Don't do this inside sync block - start can be a slow process and + // locking the children object can cause problems elsewhere + if ((getState().isAvailable() || + LifecycleState.STARTING_PREP.equals(getState())) && + startChildren) { + boolean success = false; + try { + child.start(); + success = true; + } catch (LifecycleException e) { + log.error("ContainerBase.addChild: start: ", e); + throw new IllegalStateException + ("ContainerBase.addChild: start: " + e); + } finally { + if (!success) { + synchronized (children) { children.remove(child.getName()); } } } - - fireContainerEvent(ADD_CHILD_EVENT, child); } + fireContainerEvent(ADD_CHILD_EVENT, child); } @@ -864,7 +867,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase if (name == null) return (null); - synchronized (children) { // Required by post-start changes + synchronized (children) { return children.get(name); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 4a308d25a..806cd4ae7 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -140,6 +140,12 @@ Reduce synchronization in session managers to improve performance of session creation. (markt) + + If starting children automatically when adding them to a container (e.g. + when adding a Context to a Host) don't lock the parent's set + of children whilst the new child is being started since this can block + other threads and cause issues such as lost cluster messages. (markt) + @@ -205,6 +211,11 @@ send options to be set for the reply message. Based on a patch by Ariel. (markt) + + Ensure that a new Context waiting for session data from other nodes in + the cluster does not block the processing of clustering messages for + other Contexts. (markt) +