简体   繁体   中英

Tomcat 7 Persistent Session Manager prematurely loads from Store

We are attempting to configure the dynamodb session manager for tomcat 7 in an elasticbeanstalk environment running a single server.

We can see the session data being periodically backed up to dynamodb but occasionally the old session data (for the same session) is being loaded back out of dynamodb. In our application this manifests itself by loading the previous item you were looking at (the item is stored on the session). The JSESSIONID cookie stays the same and the client keeps the same session. If we turn the session manager off, the issue is resolved.

Here is the contents of our context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Manager
    className="com.amazonaws.services.dynamodb.sessionmanager.DynamoDBSessionManager"
    Table="SessionTable"
    RegionId="eu-west-1"/>
</Context>

We've tried setting maxIdleBackup and maxIdleSwap to high numbers as defined in the tomcat 7 docs to no avail.

If we set maxIdleBackup and maxIdleSwap to zero then the error is reduced because the session data is backed up to dynamodb more often, but this doesn't solve the issue.

What is causing tomcat to load the session data back from the Store? My understanding was that it should only be loaded from the store if it is not available at all (ie client hits a different tomcat).

I believe you suffer from the async nature (and the implicit need for sticky sessions) of the implementation as noted in issue #6

If you are not using sticky sessions I recommend you go for the Redis approach which is synchronous

In the end we resorted to using the JDBCStore which does not have this issue. I hope to come back to this problem in the future given more time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM