wang-haha / memcached-session-manager

Automatically exported from code.google.com/p/memcached-session-manager
0 stars 0 forks source link

ajax request, lockingmode=all ,still can't get session attribute sometimes #218

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
 I just create random code for user to login, and put the random code into session attribute by using ajax,
but sometimes I can't find the attribute,
and sometimes I can get it.

and I feel the problem may be related with "time".
if the random code was put into session for a while ,
I can find it every times. but if I don't wait and input the random code very 
quickly, the probability that the attribute can't be found may be very high 。

I just used one tomcat server. 

I can't get any useful issues from now.

I used tomcat 7 .
in tomcat context.xml : 

  <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
            memcachedNodes="n1:10.0.110.232:11211"
                sticky="false"
            lockingMode="all"
            sessionBackupAsync="false"
            sessionBackupTimeout= "2"           
            storageKeyPrefix="static:test"      
            requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
            transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"

            />  

in lib,I used the following jars:
asm-3.2.jar
kryo-1.04.jar
kryo-serializers-0.11.jar
memcached-session-manager-1.8.3.jar
memcached-session-manager-tc7-1.8.3.jar
minlog-1.2.jar
msm-kryo-serializer-1.8.3.jar
reflectasm-1.01.jar
spymemcached-2.11.1.jar

Original issue reported on code.google.com by zheng.gu...@gmail.com on 11 Nov 2014 at 6:50

GoogleCodeExporter commented 8 years ago
martin.grotzke:

 hi,I'm urgenly waiting for your help. 
and I tried issue 151, still can't work.

Original comment by zheng.gu...@gmail.com on 11 Nov 2014 at 8:01

GoogleCodeExporter commented 8 years ago
Where do you read the value? Are you sure that this happens after the ajax 
request was completed? 

Original comment by martin.grotzke on 11 Nov 2014 at 8:12

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I think I'm using msm in a very common context and should not meet these 
problems.

maybe any jar version is something wrong ?

Original comment by zheng.gu...@gmail.com on 11 Nov 2014 at 9:59

GoogleCodeExporter commented 8 years ago
Can you activate debug logging according to the docs and share the log output? 

Original comment by martin.grotzke on 11 Nov 2014 at 10:01

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Do you have the related tomcat logs (with debug mode enabled)?

Original comment by martin.grotzke on 12 Nov 2014 at 8:15

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
log file as attachment . 
 /wmt365/user!randomImage.action  create random and set to session attribute.
/wmt365/login!login.action check request random with session attribute random

I tested twice . 
the first is ok,the second is bad.
And I saw that ,the first time ,randomImage.action set attribute to the 
session,and when logined, 
"2014-11-21 00:36:44,257 [http-bio-80-exec-10] DEBUG 
de.javakaffee.web.msm.SessionIdFormat- Creating new session id with orig id 
'ping' and memcached id 'n1'.
2014-11-21 00:36:44,260 [http-bio-80-exec-10] DEBUG 
de.javakaffee.web.msm.NodeAvailabilityCache- CacheLoader returned node 
availability 'true' for node 'n1'.
2014-11-21 00:36:44,261 [http-bio-80-exec-10] DEBUG 
de.javakaffee.web.msm.MemcachedBackupSessionManager$1- Loading session from 
memcached: F05F8770BB6E6CE2BB968C713088F840-n1"

Yes, session is loaded from memcached.

but the second time:
2014-11-21 00:36:50,449 [http-bio-80-exec-1] DEBUG 
de.javakaffee.web.msm.SessionIdFormat- Creating new session id with orig id 
'ping' and memcached id 'n1'.
2014-11-21 00:36:50,452 [http-bio-80-exec-1] DEBUG 
de.javakaffee.web.msm.NodeAvailabilityCache- CacheLoader returned node 
availability 'true' for node 'n1'.
2014-11-21 00:36:50,460 [http-bio-80-exec-1] DEBUG 
de.javakaffee.web.msm.MemcachedBackupSessionManager$1- createSession invoked: 
F05F8770BB6E6CE2BB968C713088F840-n1
2014-11-21 00:36:50,460 [http-bio-80-exec-1] DEBUG 
de.javakaffee.web.msm.MemcachedBackupSessionManager$1- Created new session with 
id F05F8770BB6E6CE2BB968C713088F840-n1
2014-11-21 00:36:50,570 [http-bio-80-exec-1] DEBUG 
de.javakaffee.web.msm.BackupSessionService- Starting for session id 
F05F8770BB6E6CE2BB968C713088F840-n1

"Created new session" ,why created again ? not loaded from memached?

Can you help me out ? Thanks a lot.

Original comment by zheng.gu...@gmail.com on 20 Nov 2014 at 4:47

Attachments:

GoogleCodeExporter commented 8 years ago
martin.grotzke:

 Hello. I found the problem about the LRUCache.

====
  In MemcachedSessionService.java :
   private final LRUCache<String, Boolean> _invalidSessionsCache = new LRUCache<String, Boolean>( 2000, 5000 );
====

you defined the cache time to 5000,that's 5 seconds long.

When I logouted ,no sticky session called removed.
MemcachedBackupSessionManager- remove invoked, removeFromMemcached: true

thus ,the sessionid is input to the _invalidSessionsCache.

in short time(less than 5 seconds) after random created and input to session 
attribute,I relogined, but the session id was indicated to invalid one. 
then recreated the session ,and the random session attribute was also dispeared.

Thus, I have two ways :
1: reduce the LRUCache timeout from 5000 to 500 or more less ?
2: like another issue, remove the cookie ,every session with different cookie

Original comment by zheng.gu...@gmail.com on 21 Nov 2014 at 6:54

GoogleCodeExporter commented 8 years ago
Issues are moved to github, this one is now 
https://github.com/magro/memcached-session-manager/issues/257

Original comment by martin.grotzke on 24 Aug 2015 at 3:16