jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Clustered HttpSession IllegalStateException: Invalid for read

Open hanlinlisumo opened this issue 7 years ago • 5 comments

Jetty 9.4.19.v20190610 java version "1.8.0_131"

I'm using DeafultSessionCache + persistent session store + sticky load balancer. The session not resident exception happens when two concurrent requests share the same session, one exits first and sets the session to be non-resident, the other request fails with the exception. I have attached the jetty debug logs, not sure if I understand it correctly but this seems like a reference counting issue?


2019-07-24 14:32:34.521:DBUG:oejs.session:qtp707806938-23: SessionHandler.doScope
2019-07-24 14:32:34.521:DBUG:oejs.session:qtp707806938-23: Got Session ID node0u6otrnfqbwyb1ukwc0klaihsz193.node0 from cookie
2019-07-24 14:32:34.521:DBUG:oejs.session:qtp707806938-23: Session node0u6otrnfqbwyb1ukwc0klaihsz193 not found locally, attempting to load
2019-07-24 14:32:34.521:DBUG:oejsh.ContextHandler:qtp707806938-186: scope null||/json/v1/log@ o.e.j.w.WebAppContext@24a35978{Service,/,file:///usr/webapps/root/,AVAILABLE}{/root}
2019-07-24 14:32:34.521:DBUG:oejsh.ContextHandler:qtp707806938-186: context=||/json/v1/log/log @ o.e.j.w.WebAppContext@24a35978{Service,/,file:///usr/webapps/root/,AVAILABLE}{/root}
2019-07-24 14:32:34.521:DBUG:oejs.session:qtp707806938-186: SessionHandler.doScope
2019-07-24 14:32:34.521:DBUG:oejs.session:qtp707806938-186: Got Session ID node0u6otrnfqbwyb1ukwc0klaihsz193.node0 from cookie
2019-07-24 14:32:34.523:DBUG:oejs.session:qtp707806938-23: Testing expiry on session node0u6otrnfqbwyb1ukwc0klaihsz193: expires at 1564005034523 now 1564003954523 maxIdle 1080000
2019-07-24 14:32:34.523:DBUG:oejs.session:qtp707806938-186: Testing expiry on session node0u6otrnfqbwyb1ukwc0klaihsz193: expires at 1564005034523 now 1564003954523 maxIdle 1080000
2019-07-24 14:32:34.523:DBUG:oejs.session:qtp707806938-186: Testing expiry on session node0u6otrnfqbwyb1ukwc0klaihsz193: expires at 1564005034523 now 1564003954523 maxIdle 1080000
2019-07-24 14:32:34.523:DBUG:oejs.session:qtp707806938-186: Session node0u6otrnfqbwyb1ukwc0klaihsz193 accessed, stopping timer, active requests=1
2019-07-24 14:32:34.523:DBUG:oejs.session:qtp707806938-186: Cancelled timer for session node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.523:DBUG:oejs.session:qtp707806938-186: sessionHandler=org.eclipse.jetty.server.session.SessionHandler385337537==dftMaxIdleSec=900 session=Session@5809e419{id=node0u6otrnfqbwyb1ukwc0klaihsz193,x=node0u6otrnfqbwyb1ukwc0klaihsz193.node0,req=1,res=true}
2019-07-24 14:32:34.523:DBUG:oejs.ServletHandler:qtp707806938-186: servlet |/json|/v1/log/log -> jersey@baa68670==com.service.jersey.SpringServlet,jsp=null,order=2,inst=true,async=false
2019-07-24 14:32:34.523:DBUG:oejs.ServletHandler:qtp707806938-186: chain=log4jServletFilter@7523a3dc==org.apache.logging.log4j.web.Log4jServletFilter,inst=true,async=false->ElbSSLRedirect@2806d6da==com.webutil.filter.security.ElbSSLRedirectFilter,inst=true,async=false->dynamicTracingFilter@cb39552==com.webutil.filter.DynamicTracingFilter,inst=true,async=false->exceptionHandlingFilter@75e27856==com.service.util.ExceptionHandlingFilter,inst=true,async=false->executionContextServletFilter@6749fe50==org.springframework.web.filter.DelegatingFilterProxy,inst=true
...
2019-07-24 14:32:34.524:DBUG:oejs.ServletHandler:qtp707806938-186: call filter cacheFilter@1db7157f==com.webutil.filter.CacheControlFilter,inst=true,async=false
2019-07-24 14:32:34.524:DBUG:oejs.ServletHandler:qtp707806938-186: call servlet jersey@baa68670==com.service.jersey.SpringServlet,jsp=null,order=2,inst=true,async=false
2019-07-24 14:32:34.524:DBUG:oejs.HttpConnection:qtp707806938-186: HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=-,to=4/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=CONTENT,0 of 1200},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=DISPATCHED,uri=//www.net/json/v1/log/log,age=4} parse HeapByteBuffer@614fdabf[p=1091,l=2291,c=8192,r=1200]={POST /json/v1/log...64003954483\r\n\r\n<<<[{"message":"[mes...gic.net/ui/]"}]>>>cesExtraInfo\\":tr...tractionRulesBl} {}
2019-07-24 14:32:34.524:DBUG:oejh.HttpParser:qtp707806938-186: parseNext s=CONTENT HeapByteBuffer@614fdabf[p=1091,l=2291,c=8192,r=1200]={POST /log...64003954483\r\n\r\n<<<[{"message":"[mes...gic.net/ui/]"}]>>>cesExtraInfo\\":tr...tractionRulesBl}
2019-07-24 14:32:34.524:DBUG:oejs.HttpChannel:qtp707806938-186: HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=DISPATCHED,uri=//www.net/log,age=4} onContent Content@2b69a8e9{HeapByteBufferR@7eb3f7[p=1091,l=2291,c=8192,r=1200]={POST /log...64003954483\r\n\r\n<<<[{"message":"[mes...gic.net/ui/]"}]>>>cesExtraInfo\\":tr...tractionRulesBl}}
2019-07-24 14:32:34.524:DBUG:oejs.HttpInput:qtp707806938-186: HttpInputOverHTTP@1396cfa2[c=0,q=0,[0]=null,s=STREAM] addContent Content@2b69a8e9{HeapByteBufferR@7eb3f7[p=1091,l=2291,c=8192,r=1200]={POST /log...64003954483\r\n\r\n<<<[{"message":"[mes...gic.net/ui/]"}]>>>cesExtraInfo\\":tr...tractionRulesBl}}
2019-07-24 14:32:34.524:DBUG:oejh.HttpParser:qtp707806938-186: CONTENT --> END
2019-07-24 14:32:34.524:DBUG:oejs.HttpChannel:qtp707806938-186: HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=DISPATCHED,uri=//www.net/log,age=4} onContentComplete
2019-07-24 14:32:34.524:DBUG:oejs.HttpChannel:qtp707806938-186: HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=DISPATCHED,uri=//www.net/log,age=4} onRequestComplete
2019-07-24 14:32:34.524:DBUG:oejs.HttpInput:qtp707806938-186: HttpInputOverHTTP@1396cfa2[c=0,q=1,[0]=EOF,s=STREAM] addContent EOF
2019-07-24 14:32:34.524:DBUG:oejs.HttpConnection:qtp707806938-186: HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=-,to=4/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=END,1200 of 1200},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=DISPATCHED,uri=//www.net/log/log,age=4} parsed false HttpParser{s=END,1200 of 1200}
2019-07-24 14:32:34.524:DBUG:oejs.HttpInput:qtp707806938-186: HttpInputOverHTTP@1396cfa2[c=1200,q=1,[0]=EOF,s=STREAM] read 1200 from Content@2b69a8e9{HeapByteBufferR@7eb3f7[p=2291,l=2291,c=8192,r=0]={POST /json/v1/log...gic.net/ui/]"}]<<<>>>cesExtraInfo\\":tr...tractionRulesBl}}
2019-07-24 14:32:34.524:DBUG:oejs.HttpConnection:qtp707806938-186: releaseRequestBuffer HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=-,to=4/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=END,1200 of 1200},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=DISPATCHED,uri=//www.net/log/log,age=4}
2019-07-24 14:32:34.524:DBUG:oejs.HttpConnection:qtp707806938-186: org.eclipse.jetty.server.HttpConnection$SendCallback@33e0c6b8[PROCESSING][i=HTTP/1.1{s=200,h=8,cl=-1},cb=org.eclipse.jetty.server.HttpChannel$SendCallback@51091011] generate: NEED_HEADER (null,[p=0,l=91,c=32768,r=91],false)@START
2019-07-24 14:32:34.524:DBUG:oejh.HttpGenerator:qtp707806938-186: generateHeaders HTTP/1.1{s=200,h=8,cl=-1} last=false content=DirectByteBuffer@39046605[p=0,l=91,c=32768,r=91]={<<<{"error":false,"e...eyedErrors":[]}>>>"userSettingsMap"...,8.0,8.0,8.0,8.}
2019-07-24 14:32:34.525:DBUG:oejh.HttpGenerator:qtp707806938-186: Date: Wed, 24 Jul 2019 21:32:34 GMT<|Strict-Transport-Security: max-age=15552000<|X-Content-Type-Options: nosniff<|X-Frame-Options: SAMEORIGIN<|X-XSS-Protection: 1; mode=block<|Content-Security-Policy-Report-Only: default-src 'self'; report-uri https://events.net/receiver/v1/http/ZaVnC4dhaV2qhOhqZTtG9JMLsccv2pGIO2iJFPasZvlxcYuqG1FfN1zoT6JDkI4qe8-Lzl3nN2eZn1gmTFCOtd-cVYnTmsmpGBTk9J0I5K0efq61Jj3JRw==; style-src 'self' https://fonts.googleapis.com https://maxcdn.bootstrapcdn.com;<|Cache-Control: private,max-age=0,no-cache,no-store<|Content-Type: application/json<|<|
2019-07-24 14:32:34.525:DBUG:oejh.HttpGenerator:qtp707806938-186: CHUNKED_CONTENT
2019-07-24 14:32:34.525:DBUG:oejs.HttpConnection:qtp707806938-186: org.eclipse.jetty.server.HttpConnection$SendCallback@33e0c6b8[PROCESSING][i=HTTP/1.1{s=200,h=8,cl=-1},cb=org.eclipse.jetty.server.HttpChannel$SendCallback@51091011] generate: FLUSH ([p=0,l=633,c=8192,r=633],[p=0,l=91,c=32768,r=91],false)@COMMITTED
2019-07-24 14:32:34.525:DBUG:oeji.WriteFlusher:qtp707806938-186: write: WriteFlusher@40aa1ce3{IDLE}->null [HeapByteBuffer@614fdabf[p=0,l=633,c=8192,r=633]={<<<HTTP/1.1 200 OK\r\n...chunked\r\n\r\n5B\r\n>>>/...tractionRulesBl},DirectByteBuffer@39046605[p=0,l=91,c=32768,r=91]={<<<{"error":false,"e...eyedErrors":[]}>>>"userSettingsMap"...,8.0,8.0,8.0,8.}]
2019-07-24 14:32:34.525:DBUG:oeji.WriteFlusher:qtp707806938-186: update WriteFlusher@40aa1ce3{WRITING}->null:IDLE-->WRITING
2019-07-24 14:32:34.525:DBUG:oeji.ChannelEndPoint:qtp707806938-186: flushed 724 SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=W,to=4/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=END,1200 of 1200},g=HttpGenerator@2b9c644c{s=COMMITTED}]=>HttpChannelOverHttp@1a3576ce{r=451,c=true,c=false/false,a=DISPATCHED,uri=//www.net/json/v1/log/log,age=5}
2019-07-24 14:32:34.525:DBUG:oeji.WriteFlusher:qtp707806938-186: Flushed=true written=724 remaining=0 WriteFlusher@40aa1ce3{WRITING}->null
2019-07-24 14:32:34.525:DBUG:oeji.WriteFlusher:qtp707806938-186: update WriteFlusher@40aa1ce3{IDLE}->null:WRITING-->IDLE
2019-07-24 14:32:34.525:DBUG:oejs.HttpConnection:qtp707806938-186: org.eclipse.jetty.server.HttpConnection$SendCallback@33e0c6b8[PROCESSING][i=HTTP/1.1{s=200,h=8,cl=-1},cb=org.eclipse.jetty.server.HttpChannel$SendCallback@51091011] generate: DONE ([p=633,l=633,c=8192,r=0],[p=91,l=91,c=32768,r=0],false)@COMMITTED
2019-07-24 14:32:34.525:DBUG:oejs.session:qtp707806938-186: FinalSession=Session@5809e419{id=node0u6otrnfqbwyb1ukwc0klaihsz193,x=node0u6otrnfqbwyb1ukwc0klaihsz193.node0,req=1,res=true}, old_session_handler=null, this=org.eclipse.jetty.server.session.SessionHandler385337537==dftMaxIdleSec=900, calling complete=true
2019-07-24 14:32:34.525:DBUG:oejs.session:qtp707806938-186: Complete called with session Session@5809e419{id=node0u6otrnfqbwyb1ukwc0klaihsz193,x=node0u6otrnfqbwyb1ukwc0klaihsz193.node0,req=1,res=true}
2019-07-24 14:32:34.525:DBUG:oejs.session:qtp707806938-186: Session node0u6otrnfqbwyb1ukwc0klaihsz193 complete, active requests=0
2019-07-24 14:32:34.525:DBUG:oejs.session:qtp707806938-186: Session node0u6otrnfqbwyb1ukwc0klaihsz193 evict on exit
2019-07-24 14:32:34.525:DBUG:oejs.session:qtp707806938-186: Not starting timer for session node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.525:DBUG:oejs.session:qtp707806938-186: Session passivating id=node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.525:DBUG:oejs.session:qtp707806938-186: Store: id=node0u6otrnfqbwyb1ukwc0klaihsz193, dirty=false, lsave=0, period=0, elapsed=1564003954525
2019-07-24 14:32:34.528:DBUG:oejs.session:qtp707806938-186: Destroyed timer for session node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.528:DBUG:oejs.session:qtp707806938-186: Evicted on request exit id=node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.528:DBUG:oejs.Server:qtp707806938-186: handled=true async=false committed=true on HttpChannelOverHttp@1a3576ce{r=451,c=true,c=false/false,a=DISPATCHED,uri=//log,age=8}
2019-07-24 14:32:34.528:DBUG:oejs.HttpChannelState:qtp707806938-186: unhandle HttpChannelState@5d4890e6{s=DISPATCHED a=NOT_ASYNC i=true r=IDLE w=false}
2019-07-24 14:32:34.528:DBUG:oejs.HttpChannel:qtp707806938-186: HttpChannelOverHttp@1a3576ce{r=451,c=true,c=false/false,a=COMPLETING,uri=//www.net/json/log,age=8} action COMPLETE
2019-07-24 14:32:34.528:DBUG:oejs.HttpChannel:qtp707806938-186: sendResponse info=null content=HeapByteBuffer@7098f413[p=0,l=0,c=0,r=0]={<<<>>>} complete=true committing=false callback=Blocker@d6e95cb{null}
2019-07-24 14:32:34.528:DBUG:oejs.HttpConnection:qtp707806938-186: org.eclipse.jetty.server.HttpConnection$SendCallback@33e0c6b8[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@6707033a] generate: CONTINUE (null,[p=0,l=0,c=0,r=0],true)@COMPLETING
2019-07-24 14:32:34.528:DBUG:oejs.HttpConnection:qtp707806938-186: org.eclipse.jetty.server.HttpConnection$SendCallback@33e0c6b8[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@6707033a] generate: NEED_CHUNK (null,[p=0,l=0,c=0,r=0],true)@COMPLETING
2019-07-24 14:32:34.528:DBUG:oejs.HttpConnection:qtp707806938-186: org.eclipse.jetty.server.HttpConnection$SendCallback@33e0c6b8[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@6707033a] generate: FLUSH (null,[p=0,l=0,c=0,r=0],true)@COMPLETING
2019-07-24 14:32:34.528:DBUG:oeji.WriteFlusher:qtp707806938-186: write: WriteFlusher@40aa1ce3{IDLE}->null [HeapByteBuffer@4b9a3cc1[p=0,l=7,c=1024,r=7]={<<<\r\n0\r\n\r\n>>>\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}]
2019-07-24 14:32:34.528:DBUG:oeji.WriteFlusher:qtp707806938-186: update WriteFlusher@40aa1ce3{WRITING}->null:IDLE-->WRITING
2019-07-24 14:32:34.528:DBUG:oeji.ChannelEndPoint:qtp707806938-186: flushed 7 SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=W,to=3/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=END,1200 of 1200},g=HttpGenerator@2b9c644c{s=COMPLETING}]=>HttpChannelOverHttp@1a3576ce{r=451,c=true,c=false/false,a=COMPLETING,uri=//www.net/json/v1/log/log,age=8}
2019-07-24 14:32:34.529:DBUG:oeji.WriteFlusher:qtp707806938-186: Flushed=true written=7 remaining=0 WriteFlusher@40aa1ce3{WRITING}->null
2019-07-24 14:32:34.529:DBUG:oeji.WriteFlusher:qtp707806938-186: update WriteFlusher@40aa1ce3{IDLE}->null:WRITING-->IDLE
2019-07-24 14:32:34.529:DBUG:oejs.HttpConnection:qtp707806938-186: org.eclipse.jetty.server.HttpConnection$SendCallback@33e0c6b8[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@6707033a] generate: DONE (null,[p=0,l=0,c=0,r=0],true)@END
2019-07-24 14:32:34.529:DBUG:oejs.HttpChannelState:qtp707806938-186: onComplete HttpChannelState@5d4890e6{s=COMPLETING a=NOT_ASYNC i=false r=IDLE w=false}
2019-07-24 14:32:34.529:DBUG:oejs.HttpChannel:qtp707806938-186: COMPLETE for /json/log written=91
2019-07-24 14:32:34.529:DBUG:oejs.HttpChannelState:qtp707806938-186: recycle HttpChannelState@5d4890e6{s=COMPLETED a=NOT_ASYNC i=false r=IDLE w=false}
2019-07-24 14:32:34.529:DBUG:oejh.HttpParser:qtp707806938-186: reset HttpParser{s=END,1200 of 1200}
2019-07-24 14:32:34.529:DBUG:oejh.HttpParser:qtp707806938-186: END --> START
2019-07-24 14:32:34.529:DBUG:oejs.HttpChannel:qtp707806938-186: HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0} handle exit, result COMPLETE
2019-07-24 14:32:34.529:DBUG:oeji.ChannelEndPoint:qtp707806938-186: filled 0 HeapByteBuffer@614fdabf[p=0,l=0,c=8192,r=0]={<<<>>>HTTP/1.1 200 OK\r\n...tractionRulesBl}
2019-07-24 14:32:34.529:DBUG:oeji.ChannelEndPoint:qtp707806938-186: filled 0 HeapByteBuffer@614fdabf[p=0,l=0,c=8192,r=0]={<<<>>>HTTP/1.1 200 OK\r\n...tractionRulesBl}
2019-07-24 14:32:34.529:DBUG:oejs.HttpConnection:qtp707806938-186: HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=-,to=0/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0} filled 0 HeapByteBuffer@614fdabf[p=0,l=0,c=8192,r=0]={<<<>>>HTTP/1.1 200 OK\r\n...tractionRulesBl}
2019-07-24 14:32:34.529:DBUG:oejs.HttpConnection:qtp707806938-186: HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=-,to=0/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0} parse HeapByteBuffer@614fdabf[p=0,l=0,c=8192,r=0]={<<<>>>HTTP/1.1 200 OK\r\n...tractionRulesBl} {}
2019-07-24 14:32:34.529:DBUG:oejh.HttpParser:qtp707806938-186: parseNext s=START HeapByteBuffer@614fdabf[p=0,l=0,c=8192,r=0]={<<<>>>HTTP/1.1 200 OK\r\n...tractionRulesBl}
2019-07-24 14:32:34.529:DBUG:oejs.HttpConnection:qtp707806938-186: HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=-,to=0/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0} parsed false HttpParser{s=START,0 of -1}
2019-07-24 14:32:34.529:DBUG:oejs.HttpConnection:qtp707806938-186: releaseRequestBuffer HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=-,to=0/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0}
2019-07-24 14:32:34.529:DBUG:oeji.AbstractConnection:qtp707806938-186: fillInterested HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=-,flush=-,to=0/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0}
2019-07-24 14:32:34.529:DBUG:oeji.FillInterest:qtp707806938-186: interested FillInterest@1aaee4f7{AC.ReadCB@7d063764{HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=FI,flush=-,to=0/90000}{io=0/0,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0}}}
2019-07-24 14:32:34.529:DBUG:oeji.ChannelEndPoint:qtp707806938-186: changeInterests p=false 0->1 for SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=FI,flush=-,to=0/90000}{io=0/1,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0}
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-186: Queued change org.eclipse.jetty.io.ChannelEndPoint$1@3f898e4 on ManagedSelector@2da3ae4c{STARTED} id=1 keys=24 selected=0 updates=0
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-186: Wakeup on submit ManagedSelector@2da3ae4c{STARTED} id=1 keys=24 selected=0 updates=1
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-409: Selector sun.nio.ch.EPollSelectorImpl@26bd0df9 woken with none selected
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-409: Selector sun.nio.ch.EPollSelectorImpl@26bd0df9 woken up from select, 0/0/24 selected
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-409: Selector sun.nio.ch.EPollSelectorImpl@26bd0df9 processing 0 keys, 1 updates
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-409: updateable 1
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-409: update org.eclipse.jetty.io.ChannelEndPoint$1@3f898e4
2019-07-24 14:32:34.529:DBUG:oejs.HttpConnection:qtp707806938-186: HttpConnection@7d063764::SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=FI,flush=-,to=0/90000}{io=0/1,kio=0,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0} onFillable exit HttpChannelState@5d4890e6{s=IDLE a=NOT_ASYNC i=true r=IDLE w=false} null
2019-07-24 14:32:34.529:DBUG:oejut.ReservedThreadExecutor:qtp707806938-186: ReservedThreadExecutor@42f93a98{s=2/4,p=0}@4b91350c waiting
2019-07-24 14:32:34.529:DBUG:oejs.session:qtp707806938-23: Testing expiry on session node0u6otrnfqbwyb1ukwc0klaihsz193: expires at 1564005034529 now 1564003954529 maxIdle 1080000
2019-07-24 14:32:34.529:DBUG:oeji.ChannelEndPoint:qtp707806938-409: Key interests updated 0 -> 1 on SocketChannelEndPoint@14484088{/10.0.36.34:44562<->/10.0.152.55:23662,OPEN,fill=FI,flush=-,to=0/90000}{io=1/1,kio=1,kro=1}->HttpConnection@7d063764[p=HttpParser{s=START,0 of -1},g=HttpGenerator@2b9c644c{s=START}]=>HttpChannelOverHttp@1a3576ce{r=451,c=false,c=false/false,a=IDLE,uri=null,age=0}
2019-07-24 14:32:34.529:DBUG:oejs.session:qtp707806938-23: Session node0u6otrnfqbwyb1ukwc0klaihsz193 accessed, stopping timer, active requests=1
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-409: updates 0
2019-07-24 14:32:34.529:DBUG:oejs.session:qtp707806938-23: Cancelled timer for session node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.529:DBUG:oeji.ManagedSelector:qtp707806938-409: Selector sun.nio.ch.EPollSelectorImpl@26bd0df9 waiting with 24 keys
2019-07-24 14:32:34.529:DBUG:oejs.session:qtp707806938-23: sessionHandler=org.eclipse.jetty.server.session.SessionHandler385337537==dftMaxIdleSec=900 session=Session@5809e419{id=node0u6otrnfqbwyb1ukwc0klaihsz193,x=node0u6otrnfqbwyb1ukwc0klaihsz193.node0,req=1,res=false}
2019-07-24 14:32:34.529:DBUG:oejs.ServletHandler:qtp707806938-23: servlet |/json|/account -> jersey@baa68670==com.service.jersey.SpringServlet,jsp=null,order=2,inst=true,async=false
...
2019-07-24 14:32:34.529:DBUG:oejs.ServletHandler:qtp707806938-23: call filter xml-request-filter@52bf7bf6==com.webutil.filter.xml.XmlRequestTypeFilter,inst=true,async=false
2019-07-24 14:32:34.529:DBUG:oejs.ServletHandler:qtp707806938-23: call filter springSecurityFilterChain@bbd4791==org.springframework.web.filter.DelegatingFilterProxy,inst=true,async=false
2019-07-24 14:32:34,530 -0700 ERROR [logger=service.util.ExceptionHandlingFilter] [thread=qtp707806938-23] Error ID M8UA2-EH7ID-CD2H6 while executing service method java.lang.IllegalStateException: Invalid for read: id=node0u6otrnfqbwyb1ukwc0klaihsz193 not resident
        at org.eclipse.jetty.server.session.Session.checkValidForRead(Session.java:711)
        at org.eclipse.jetty.server.session.Session.getAttribute(Session.java:729)
        at org.springframework.security.web.context.HttpSessionSecurityContextRepository.readSecurityContextFromSession(HttpSessionSecurityContextRepository.java:182)
        at org.springframework.security.web.context.HttpSessionSecurityContextRepository.loadContext(HttpSessionSecurityContextRepository.java:112)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:100)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        at com.webutil.filter.xml.XmlRequestTypeFilter.doFilter(XmlRequestTypeFilter.scala:50)
        at com.webutil.filter.HttpFilterBase.doFilter(HttpFilterBase.scala:11)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        at com.external.filter.RequestResponseFilter.doFilter(RequestResponseFilter.scala:18)
        at com.webutil.filter.HttpFilterBase.doFilter(HttpFilterBase.scala:11)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        ...
        at com.util.context.ExecutionContextServletFilter.doFilter(ExecutionContextServletFilter.scala:43)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        at com.service.util.ExceptionHandlingFilter.doFilter(ExceptionHandlingFilter.scala:19)
        at com.webutil.filter.HttpFilterBase.doFilter(HttpFilterBase.scala:11)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        at io.opentracing.contrib.web.servlet.filter.TracingFilter.doFilter(TracingFilter.java:165)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        ...
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1711)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
        at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:56)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1347)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1678)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1249)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:152)
        at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:753)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.eclipse.jetty.server.Server.handle(Server.java:505)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:781)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:917)
        at java.lang.Thread.run(Thread.java:748)

2019-07-24 14:32:34.533:DBUG:oejs.session:qtp707806938-23: FinalSession=Session@5809e419{id=node0u6otrnfqbwyb1ukwc0klaihsz193,x=node0u6otrnfqbwyb1ukwc0klaihsz193.node0,req=1,res=false}, old_session_handler=null, this=org.eclipse.jetty.server.session.SessionHandler385337537==dftMaxIdleSec=900, calling complete=true
2019-07-24 14:32:34.533:DBUG:oejs.session:qtp707806938-23: Complete called with session Session@5809e419{id=node0u6otrnfqbwyb1ukwc0klaihsz193,x=node0u6otrnfqbwyb1ukwc0klaihsz193.node0,req=1,res=false}
2019-07-24 14:32:34.533:DBUG:oejs.session:qtp707806938-23: Session node0u6otrnfqbwyb1ukwc0klaihsz193 complete, active requests=0
2019-07-24 14:32:34.533:DBUG:oejs.session:qtp707806938-23: Session node0u6otrnfqbwyb1ukwc0klaihsz193 evict on exit
2019-07-24 14:32:34.533:DBUG:oejs.session:qtp707806938-23: Not starting timer for session node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.533:DBUG:oejs.session:qtp707806938-23: Session passivating id=node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.533:DBUG:oejs.session:qtp707806938-23: Store: id=node0u6otrnfqbwyb1ukwc0klaihsz193, dirty=false, lsave=1564003954525, period=0, elapsed=8
2019-07-24 14:32:34.544:DBUG:oejs.session:qtp707806938-380: Destroyed timer for session node0uksy1vo0bw8ms507tk4calgd176
2019-07-24 14:32:34.544:DBUG:oejs.session:qtp707806938-380: Evicted on request exit id=node0uksy1vo0bw8ms507tk4calgd176
2019-07-24 14:32:34.544:DBUG:oejs.Server:qtp707806938-380: handled=true async=false committed=true on HttpChannelOverHttp@72b30e20{r=507,c=true,c=false/false,a=DISPATCHED,uri=//www.net/log,age=90}
2019-07-24 14:32:34.544:DBUG:oejs.HttpChannelState:qtp707806938-380: unhandle HttpChannelState@54b39f76{s=DISPATCHED a=NOT_ASYNC i=true r=IDLE w=false}
2019-07-24 14:32:34.544:DBUG:oejs.HttpChannel:qtp707806938-380: HttpChannelOverHttp@72b30e20{r=507,c=true,c=false/false,a=COMPLETING,uri=//www.net/json/v1/log/log,age=90} action COMPLETE
2019-07-24 14:32:34.544:DBUG:oejs.HttpChannel:qtp707806938-380: sendResponse info=null content=HeapByteBuffer@7098f413[p=0,l=0,c=0,r=0]={<<<>>>} complete=true committing=false callback=Blocker@4b45e284{null}
2019-07-24 14:32:34.544:DBUG:oejs.HttpConnection:qtp707806938-380: org.eclipse.jetty.server.HttpConnection$SendCallback@57dd935b[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@1fbd0b46] generate: CONTINUE (null,[p=0,l=0,c=0,r=0],true)@COMPLETING
2019-07-24 14:32:34.544:DBUG:oejs.session:qtp707806938-23: Destroyed timer for session node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.544:DBUG:oejs.session:qtp707806938-23: Evicted on request exit id=node0u6otrnfqbwyb1ukwc0klaihsz193
2019-07-24 14:32:34.544:DBUG:oejs.HttpConnection:qtp707806938-380: org.eclipse.jetty.server.HttpConnection$SendCallback@57dd935b[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@1fbd0b46] generate: NEED_CHUNK (null,[p=0,l=0,c=0,r=0],true)@COMPLETING
2019-07-24 14:32:34.544:DBUG:oejs.HttpConnection:qtp707806938-380: org.eclipse.jetty.server.HttpConnection$SendCallback@57dd935b[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@1fbd0b46] generate: FLUSH (null,[p=0,l=0,c=0,r=0],true)@COMPLETING

hanlinlisumo avatar Jul 30 '19 04:07 hanlinlisumo

@hanlinlisumo typically this could happen if your application or a library that you are using retains references to session objects beyond the lifetime of a single request.

If you're totally sure that no references to session objects are being stored anywhere by your application, but are always and only obtained by request.getSession(), I'd need to see a reproduction test case.

janbartel avatar Jul 30 '19 05:07 janbartel

@hanlinlisumo I have been able to work out what is happening from the logs you supplied: it is indeed a horrible, horrible race condition. Contemplating a fix.

janbartel avatar Jul 30 '19 06:07 janbartel

PR #3947 opened

joakime avatar Aug 08 '19 22:08 joakime

Description of race: SessionHandler line 1539: the retrieval of the session at line 1535 is separated in time from the point at which the session is marked as being accessed by a request at line 1539. This means that Request1 can come in, increment the request count to 1, execute application code and then exit the session, decrementing the request count to 0 in between line 1535 and 1539 executed by Request2. Aiding and abetting the problem is that Session.access does not check if the session is resident before incrementing the request count: thus, Request1's exit might have evicted the Session from the cache, but Request2 obtained a reference to it before it was evicted, incremented the access count (didn't check the session was resident first), then tried to use the session and failed the residency check that gates all application code interaction with a session.

janbartel avatar Aug 12 '19 05:08 janbartel

Fix checked in for 9.4.21 and above.

janbartel avatar Aug 15 '19 03:08 janbartel