Wildfly 17 Distributed Infinispan Cache Session not found
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
WildFly 17, the latest in the series of WildFly application servers, boasts a multitude of impressive features and capabilities. One significant feature is its integration with Infinispan, an open-source data grid platform that allows WildFly to effectively manage distributed caches. This integration greatly enhances session scalability and reliability across distributed environments. Despite these advantages, issues such as the "Distributed Infinispan Cache Session not found" error can occasionally arise, leading to challenges in session state management across a cluster. This article delves into the cause of such issues and provides troubleshooting guidance.
Understanding Distributed Caching in WildFly with Infinispan
WildFly uses Infinispan to handle session caching in a distributed environment, which is essential for maintaining session data consistency across different nodes in a cluster. Infinispan effectively manages data through local caching on each node coupled with replication or distribution of data across the cluster according to defined caching configurations.
A common deployment scenario employs a replicated cache mode where all nodes hold a copy of the cached data, ensuring quick session access and fault tolerance. Alternatively, a distributed cache mode is used where data is spread out across various nodes depending on factors such as memory load and network latency, optimizing resource utilization and scalability.
Problem: "Session Not Found" in Distributed Infinispan Caches
The “Session not found” problem typically arises due to misconfigurations or faults in the distributed environment settings. This can manifest when a session is saved in one node's cache but is not adequately replicated or distributed to other nodes where subsequent requests might be routed.
Root Cause Analysis
Identifying the root cause of session data mishaps involves checking several system and configuration aspects:
- Configuration of Infinispan: Incorrect cache configuration or properties can hinder proper session replication or distribution.
- Network Issues: Network latency or interruptions can prevent a node from participating fully in the cluster, causing mismatches in session states.
- Session Handling in Application Deployment: Improper handling of session IDs within applications or changing session IDs without synchronization can lead to session loss.
Troubleshooting and Solutions
To address the missing session data in a distributed cache, consider the following troubleshooting steps and solutions:
- Review Cache Container Configurations: Ensure that the cache-container used to configure clustering for session replication in
standalone.xmlordomain.xmlaccurately specifies the cache mode (e.g., replicated, distributed) and includes proper tuning of attributes such asowners,segments, andl1-lifespanfor distributed caches. - Cluster Health Check: Verify that all nodes are healthy and communications are intact using management CLI (Command-Line Interface) or admin console checks. Use commands like
/subsystem=infinispan/cache-container=web:read-attribute(name=cluster-status)to validate cluster status. - Examine Application Deployment Settings: Ensure session management within your application is correctly configured to use distributed caching. Look for specific session management configurations that might be overriding cluster-wide settings.
- Logs and Metrics Monitoring: Check server logs for errors related to Infinispan or clustering. Utilize application monitoring to trace session creation, usage, and replication across nodes.
- Simulation and Testing: Simulate the environment and use cases in a controlled setup to identify specific causes and verify fixes.
Summary Table
| Issue Component | Checkpoints |
| Configuration | - Cache mode set correctly (replicated/distributed)
- Attributes like owners, segments |
| Network | - No interruptions - Adequate latency |
| Application Deployment | - Session management integration with Infinispan |
| Health and Monitoring | - Cluster status and health check via CLI or console - Server logs and metrics monitoring |
Conclusion
Distributed sessions using Infinispan in WildFly are robust for scalability and reliability, but require careful configuration and management. Understanding the components involved and maintaining system checks helps mitigate issues like “Session not found”. Always ensure that your system's configuration reflects the nature of your distributed environment to harness the full potential of WildFly with Infinispan.
Related reading
- Will Hazelcast IMap block when waiting for an entry in transit?
- Will replicated data in cluster use same memory space in every system?
- Will Schema change of a replicated object will affect replication?
- With exactly once semantics, is the Generals Paradox solved now?
- Will Try / Finally without the Catch bubble the exception?
- wiremock issue when upgrading to Spring Boot 3
- Work distribution with Kafka Streams
- Working example of Spring Cloud Gateway with Redis session management?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.