未找到 Wildfly 17 分布式 Infinispan 缓存会话

Wildfly 17 Distributed Infinispan Cache Session not found

我正在考虑为会话配置 wf 17 的分布式缓存,但我在使其正常工作时遇到了问题。这是一个分布式配置,我使用基本身份验证,当我们将 post 发送到 /j_security_check 时,它将发送到一个节点,并在身份验证成功完成后获取 /index.html 它将一个不同的节点。当请求到达第二个节点时,我有这个异常:

2019-10-16 17:17:39,901 TRACE [org.wildfly.clustering.web.infinispan] (default task-9) Session _ttZ3PQsisp4qCdTlkY512jYoG02S3DiYgpDUGjJ not found  
2019-10-16 17:17:39,903 TRACE [org.wildfly.clustering.web.infinispan] (default task-9) Session _ttZ3PQsisp4qCdTlkY512jYoG02S3DiYgpDUGjJ not found  
2019-10-16 17:17:39,905 TRACE [org.wildfly.clustering.web.infinispan] (default task-9) Session _ttZ3PQsisp4qCdTlkY512jYoG02S3DiYgpDUGjJ not found  
2019-10-16 17:17:39,906 TRACE [org.wildfly.clustering.web.infinispan] (remote-thread--p17-t4) Session vjStKgUR6gnUne3KPr_v89S_37Dp-jc4eqNXZ1kk will be removed  
2019-10-16 17:17:39,907 TRACE [org.wildfly.clustering.web.infinispan] (default task-9) Session _ttZ3PQsisp4qCdTlkY512jYoG02S3DiYgpDUGjJ not found  
2019-10-16 17:17:39,965 ERROR [io.undertow.request] (default task-9) UT005023: Exception handling request to /index.html: java.lang.IllegalStateException: WFLYCLWEBUT0002: Session _ttZ3PQsisp4qCdTlkY512jYoG02S3DiYgpDUGjJ already exists  
        at org.wildfly.clustering.web.undertow.session.DistributableSessionManager.createSession(DistributableSessionManager.java:169)  
        at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:918)  
        at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:933)  
        at io.undertow.servlet.handlers.security.ServletFormAuthenticationMechanism.storeInitialLocation(ServletFormAuthenticationMechanism.java:175)  

我可以在另一台服务器上看到 /j_security_check post 发生的地方:

    contentLength=0  
       contentType=null  
            cookie=JSESSIONID=_ttZ3PQsisp4qCdTlkY512jYoG02S3DiYgpDUGjJ.staging-2:staging-2-wildfly; domain=null; path=/  
            header=Expires=0  
            header=Connection=close  
            header=Cache-Control=no-cache, no-store, must-revalidate  
            header=Set-Cookie=JSESSIONID="_ttZ3PQsisp4qCdTlkY512jYoG02S3DiYgpDUGjJ.staging-2:staging-2-wildfly"; Version=1; Path=/; Secure; HttpOnly  
            header=Pragma=no-cache  
            header=Location=....  
            header=Content-Length=0  
            header=Date=Wed, 16 Oct 2019 16:17:39 GMT  
            status=302  
2019-10-16 17:17:39,210 TRACE [org.wildfly.clustering.web.infinispan] (default task-10) Session _ttZ3PQsisp4qCdTlkY512jYoG02S3DiYgpDUGjJ will expire in 14401 sec  

我的 inifinispan 缓存配置是:

                <cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan">
                    <transport lock-timeout="60000"/>
                    <distributed-cache name="dist" remote-timeout="17500" l1-lifespan="0" owners="2">
                        <locking acquire-timeout="60000" isolation="READ_COMMITTED"/>
                        <transaction locking="OPTIMISTIC" mode="BATCH"/>
                        <file-store/>
                    </distributed-cache>
                </cache-container>

只要会话缓存在 infinispan 中,为什么当请求到达第二个服务器时最初找不到它,但在尝试创建它时却抱怨它已经存在?

此外,我尝试配置 distributable-web:1.0 wf 子系统以使用上述缓存,但输出是相同的。不确定是否需要,如果我在 web.xml 中有标签,它将是相同的 "default" 可分发网络子系统,对吗?

我注意到但不明白的另一种情况:

----------------------------REQUEST---------------------------  
               URI=/j_security_check  
             cookie=JSESSIONID=0Zb-sRk9GvM_NXxpOcS5SPifwCour07qm41kTujh.starscream:starscream-wildfly  
           method=POST  
--------------------------RESPONSE--------------------------  
            cookie=JSESSIONID=mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI.starscream:starscream-wildfly; domain=null; path=/  
            status=302  
==============================================================  
2019-10-17 10:06:42,347 TRACE [org.wildfly.clustering.web.infinispan] (default task-59) Session mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI will expire in 14401 sec  
2019-10-17 10:06:42,355 TRACE [org.wildfly.clustering.web.infinispan] (default task-72) Session mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI not found  
2019-10-17 10:06:42,357 TRACE [org.wildfly.clustering.web.infinispan] (default task-72) Session mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI not found  
2019-10-17 10:06:42,360 TRACE [org.wildfly.clustering.web.infinispan] (default task-72) Session mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI not found  
2019-10-17 10:06:42,409 INFO  [io.undertow.request.dump] (default task-72)   
----------------------------REQUEST---------------------------  
               URI=/index.html  
            cookie=JSESSIONID=mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI.starscream:starscream-wildfly  
            method=GET  
--------------------------RESPONSE--------------------------  
            status=200  
==============================================================  
2019-10-17 10:06:42,411 TRACE [org.wildfly.clustering.web.infinispan] (default task-72) Session mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI will expire in 14400 sec  
2019-10-17 10:06:44,333 WARN  [org.springframework.web.servlet.PageNotFound] (default task-72) No mapping found for HTTP request with URI [/j_security_check] in DispatcherServlet with name 'dispatcher'  
2019-10-17 10:06:44,347 TRACE [org.wildfly.clustering.web.infinispan] (default task-72) Session mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI will expire in 14401 sec  
2019-10-17 10:06:44,357 INFO  [io.undertow.request.dump] (default task-72)   
----------------------------REQUEST---------------------------  
               URI=/j_security_check  
            cookie=JSESSIONID=mUInjx6SmUXCXz9CJDN3IYVE8it9RGI9fMXYKTtI.starscream:starscream-wildfly  
            method=POST  
--------------------------RESPONSE--------------------------  
            status=404  

这发生在同一个节点上,我收到了上述会话的响应,过了一会儿就找不到会话了,最终收到 j_security_check 的 404。

问题是重定向的请求试图在上一个请求完成提交之前读取会话。删除交易和锁定标签解决它。