-
1. Re: Teiid standalone stop client threads
shawkins May 23, 2019 11:31 AM (in response to mtawk)Any xnio threads from the admin client would be created by the jboss dmr client libraries. Calling admin.close should clean up any resources created - it's the only handle to close given to use by the library. The library also appears to have reference/finalizer logic to ensure cleanup, so it should cleanup even if you don't call close as long as the clients are garbage collected. Is it possible that some admin clients are not being closed, and not being garbage collected?
-
2. Re: Teiid standalone stop client threads
mtawk May 24, 2019 5:29 AM (in response to shawkins)The admin.close is not terminating the threads. They remain hanging even after 10 minutes
we tried with a simple example like the below, and all the threads remained hanging after admin.close() as long as the jvm is not terminated
public static void main(String[] args) throws Exception {
Admin admin = AdminFactory.getInstance().createAdmin("127.0.0.1", 9990, "teiiduser", "teiidpass".toCharArray());
admin.close();
boolean stopProcess = false;
while (!stopProcess) {
Thread.sleep(2000);
}
}
-
3. Re: Teiid standalone stop client threads
shawkins May 24, 2019 3:07 PM (in response to mtawk)The example won't complete because the main thread never completes.
All the XNIO threads you show above are daemon threads, so they will go away once the main thread completes.
Retry your example as:
public static void main(String[] args) throws Exception {
Admin admin = AdminFactory.getInstance().createAdmin("127.0.0.1", 9990, "teiiduser", "teiidpass".toCharArray());
admin.close();
// if there are non-daemon threads, this process won't die at this point
}
-
4. Re: Teiid standalone stop client threads
mtawk May 27, 2019 10:24 AM (in response to shawkins)The issue is that those threads are remaining as long as the JVM is not terminated.
In the case of a web application hosted over Tomcat, if you stop/start the web application using Tomcat manager (Tomcat server is still using the same JVM), those threads are not removed, and accordingly, the web application is not starting properly.
We are forced to restart Tomcat server for those threads to be garbage collected.
Note that the above issue does not occur when Teiid is embedded in the web application.
-
5. Re: Teiid standalone stop client threads
shawkins May 27, 2019 9:17 PM (in response to mtawk)So the issue is not that you have some non-daemon threads preventing the vm from exiting, but that you are in a container environment and running the admin client spawns threads, which Tomcat does not like. As far as I can tell this is by design with XNIO. Those threads are effectively managed as a thread pool and as accessed via a static context, so they are assumed to be shared for the entire vm.
This is probably something to ask on the WildFly forum - if there is any mechanism to control how XNIO manages its threads for the admin client.
-
6. Re: Teiid standalone stop client threads
mtawk Jun 5, 2019 5:28 AM (in response to shawkins)I have asked the question in the wildfly forum: Unable to terminate Daemon XNIO threads created by Teiid admin client
They say there might be a way to allow clients to specify an application level for XNIO executor service.
Could this help in resolving the issue?
-
7. Re: Teiid standalone stop client threads
shawkins Jun 5, 2019 9:38 AM (in response to mtawk)We're essentially saying the same thing. This is by design for the Remoting/XNIO library, which is used underneath the DMR library, which is used by the Teiid admin client. The DMR library offers no methods nor documentation on controlling the XNIO behavior. I can only see a hack of a solution at the present time, which I added to the other thread.
-
8. Re: Teiid standalone stop client threads
shawkins Jun 6, 2019 8:23 AM (in response to shawkins)To understand things a little better, what does your classloading situation look like? Are the jboss dependencies in the web app, or are they in a common classloader? It seems like a simple solution is to move at least the xnio library to a higher classloader such that the static instance would be associated with the whole tomcat instance and not a particular web context.