]
Paul Ferraro commented on WFLY-8931:
------------------------------------
This is a regression caused by fix for
InfinispanSessionManager#getActiveSessions (active-sessions attribute
in CLI) returns an incorrect count on a coordinator node in cluster
-----------------------------------------------------------------------------------------------------------------------------------------
Key: WFLY-8931
URL:
https://issues.jboss.org/browse/WFLY-8931
Project: WildFly
Issue Type: Bug
Components: Clustering
Affects Versions: 11.0.0.Alpha1
Reporter: Paul Ferraro
Assignee: Paul Ferraro
Since EAP 7.0.1 coming with the fix for JBEAP-4646 (upstream WFLY-6453),
{{InfinispanSessionManager#getActiveSessions}} ({{active-sessions}} attribute on CLI) was
changed to return active session count with current node locality.
However, it returns an incorrect count on a cluster coordinator node. For example, when
two node cluster is configured, it returns total count of active sessions. This happens
regardless of using "dist" cache or using "repl" cache.
---
The followings are the related code. It appears {{ConsistentHashLocality#isLocal(key)}}
always returns {{true}} on a coordinator node and it causes incorrect active session
count.
{code:java|title=clustering/web/infinispan/src/main/java/org/wildfly/clustering/web/infinispan/session/InfinispanSessionManager.java}
268 @Override
269 public Set<String> getActiveSessions() {
270 // Omit remote sessions (i.e. when using DIST mode) as well as passivated
sessions
271 return this.getSessions(Flag.CACHE_MODE_LOCAL, Flag.SKIP_CACHE_LOAD);
272 }
:
280 private Set<String> getSessions(Flag... flags) {
281 try (Stream<? extends Key<String>> keys =
this.cache.getAdvancedCache().withFlags(flags).keySet().stream()) {
282 return keys.filter(this.filter.and(key ->
this.locality.isLocal(key))).map(key -> key.getValue()).collect(Collectors.toSet());
283 }
284 }
{code}
{code:java|title=clustering/infinispan/spi/src/main/java/org/wildfly/clustering/infinispan/spi/distribution/ConsistentHashLocality.java}
51 @Override
52 public boolean isLocal(Object key) {
53 if (this.localAddress == null) return true;
54 if (this.hash == null) return true;
55 return this.localAddress.equals(this.hash.locatePrimaryOwner(key));
56 }
{code}