Author: rjung Date: Mon Nov 2 21:34:46 2009 New Revision: 832112 URL: http://svn.apache.org/viewvc?rev=832112&view=rev Log: DeltaManager needs to replicate changed attributes even if session gets invalidated. Otherwise session listeners will not see the right data on the secondary nodes.
Ported from r812427 of OACC and r818061 of TC5.5.x. Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=832112&r1=832111&r2=832112&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Mon Nov 2 21:34:46 2009 @@ -303,15 +303,6 @@ the installer, leaving the one in the ROOT webapp as is. Note, that we already have these two copies of the file in our zip/tgz distributions. -* Fix cluster replication problem: session expiration uses a replication - shortcut, so that attributes changed immediately before invalidation do - not get replicated before the expiration replication message. - That's a problem in case a session listener needs the changed attribute. - Has already been fixed in trunk, OACC and tc5.5.x. - http://svn.apache.org/viewvc?rev=818062&view=rev (trunk) - +1: rjung, pero, fhanik - -1: - * Fix memory leak causes by a JRE implementation change in 1.6.0_15 onwards http://svn.apache.org/viewvc?view=revision&revision=828196 http://svn.apache.org/viewvc?view=revision&revision=830378 Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java?rev=832112&r1=832111&r2=832112&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java Mon Nov 2 21:34:46 2009 @@ -1106,6 +1106,25 @@ * @return a SessionMessage to be sent, */ public ClusterMessage requestCompleted(String sessionId) { + return requestCompleted(sessionId, false); + } + + /** + * When the request has been completed, the replication valve will notify + * the manager, and the manager will decide whether any replication is + * needed or not. If there is a need for replication, the manager will + * create a session message and that will be replicated. The cluster + * determines where it gets sent. + * + * Session expiration also calls this method, but with expires == true. + * + * @param sessionId - + * the sessionId that just completed. + * @param expires - + * whether this method has been called during session expiration + * @return a SessionMessage to be sent, + */ + public ClusterMessage requestCompleted(String sessionId, boolean expires) { DeltaSession session = null; try { session = (DeltaSession) findSession(sessionId); @@ -1127,7 +1146,7 @@ } } if(!isDeltaRequest) { - if(!session.isPrimarySession()) { + if(!expires && !session.isPrimarySession()) { counterSend_EVT_SESSION_ACCESSED++; msg = new SessionMessageImpl(getName(), SessionMessage.EVT_SESSION_ACCESSED, @@ -1143,9 +1162,10 @@ log.debug(sm.getString("deltaManager.createMessage.delta",getName(), sessionId)); } } - session.setPrimarySession(true); + if (!expires) + session.setPrimarySession(true); //check to see if we need to send out an access message - if ((msg == null)) { + if (!expires && (msg == null)) { long replDelta = System.currentTimeMillis() - session.getLastTimeReplicated(); if (replDelta > (getMaxInactiveInterval() * 1000)) { counterSend_EVT_SESSION_ACCESSED++; Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java?rev=832112&r1=832111&r2=832112&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java Mon Nov 2 21:34:46 2009 @@ -37,7 +37,9 @@ import org.apache.catalina.Manager; import org.apache.catalina.ha.ClusterManager; +import org.apache.catalina.ha.CatalinaCluster; import org.apache.catalina.ha.ClusterSession; +import org.apache.catalina.ha.ClusterMessage; import org.apache.catalina.realm.GenericPrincipal; import org.apache.catalina.session.StandardSession; import org.apache.catalina.tribes.io.ReplicationStream; @@ -382,7 +384,24 @@ } public void expire(boolean notify, boolean notifyCluster) { + if (expiring) + return; String expiredId = getIdInternal(); + + if(expiredId != null && manager != null && + manager instanceof DeltaManager) { + DeltaManager dmanager = (DeltaManager)manager; + CatalinaCluster cluster = dmanager.getCluster(); + ClusterMessage msg = dmanager.requestCompleted(expiredId, true); + if (msg != null) { + if(dmanager.doDomainReplication()) { + cluster.sendClusterDomain(msg); + } else { + cluster.send(msg); + } + } + } + super.expire(notify); if (notifyCluster) { Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=832112&r1=832111&r2=832112&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Mon Nov 2 21:34:46 2009 @@ -299,6 +299,11 @@ <subsection name="Cluster"> <changelog> <fix> + DeltaManager needs to replicate changed attributes even if session + gets invalidated. Otherwise session listeners will not see the right + data on the secondary nodes. (rjung) + </fix> + <fix> Spurious startup errors during session transfer. Sessions get transferred, but node still waits until timeout. (rjung) </fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org