]
Wolf-Dieter Fink commented on WFLY-10463:
-----------------------------------------
If I look to the client there are two loops,
Outer loop do a lookup for a SFSB, inner loop call this SFSB 10 times.
The SFSB proxy will stick to one node with the 10 invocations. The bean is not removed
(which end in passivation forever BTW)
After that a new proxy is created from the InitialContext, as we don't have a way to
suppress cluster (no annotation needed) the context received the cluster view, so if the
nodes get clustered correct, the client will see both after the first invocation.
Because of that each lookup will randomly pick one of both nodes here, so the invocation
jumps.
The only way to prevent is to use TX stickyness, in this case the client need to lookup a
Tx and surround all invocations with that.
But this is not recommended as it will keep resources and locks for the complete
transaction time and the client might not cleanup the transaction which cause issues.
Finally I think the behaviour is expected and spec compliant.
Weak affinity set up by EJB client 4 is not followed with invocations
running against stateful bean deploment on WildFly 13
---------------------------------------------------------------------------------------------------------------------------
Key: WFLY-10463
URL:
https://issues.jboss.org/browse/WFLY-10463
Project: WildFly
Issue Type: Bug
Components: Clustering, EJB
Affects Versions: 13.0.0.Beta1
Environment: WildFly 13 beta runtimes. EJB client version does not matter (tested
with {{org.wildfly:wildfly-ejb-client-bom:12.0.0.Final}}).
Reporter: Michal Jurc
Assignee: Paul Ferraro
Priority: Blocker
Fix For: 13.0.0.CR1
Attachments: repro.zip
Remote EJB client with {{InitialContext}} setting up weak affinity will not hold up the
affinity, resulting in a behaviour that's different to previous releases of WildFly.
In previous versions of WildFly, {{java.naming.provider.url}} property of
{{InitialContext}} was enough to enforce weak affinity to a node in remote EJB client.
This is a regression compared to WildFly 12. The client version does not change the
behaviour, which leads me to believe the issue is server-side.
Update: The issue affects only stateful bean invocations.
{code}
while (true) {
try {
final Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
WildFlyInitialContextFactory.class.getName());
props.put(Context.PROVIDER_URL,
"remote+http://127.0.0.1:8080");
final InitialContext ejbCtx = new InitialContext(props);
final HelloBeanRemote bean = (HelloBeanRemote) ejbCtx
.lookup("ejb:/server/HelloBean!" +
HelloBeanRemote.class.getName() + "?stateful");
for (int i = 0; i < 10; i++) {
System.out.println(bean.hello());
}
} catch(Exception e) {
System.out.println("Call failed!!!!");
e.printStackTrace();
}
final Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
WildFlyInitialContextFactory.class.getName());
props.put(Context.PROVIDER_URL, "remote+http://127.0.0.1:8080");
{code}
{code}11:56:02,452 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling
invoke(module = /server/HelloBean, strong affinity = Cluster "ejb", weak
affinity = Node "node1"):
node1, 0
11:56:02,460 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 1
11:56:02,465 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 2
11:56:02,472 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 3
11:56:02,477 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 4
11:56:02,488 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 5
11:56:02,496 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 6
11:56:02,502 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 7
11:56:02,507 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 8
11:56:02,515 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node1"):
node1, 9
11:56:03,535 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 0
11:56:03,544 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 1
11:56:03,555 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 2
11:56:03,561 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 3
11:56:03,568 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 4
11:56:03,586 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 5
11:56:03,595 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 6
11:56:03,602 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 7
11:56:03,616 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 8
11:56:03,628 DEBUG [org.jboss.ejb.client.EJBInvocationHandler:164] Calling invoke(module
= /server/HelloBean, strong affinity = Cluster "ejb", weak affinity = Node
"node2"):
node2, 9
{code}