[
https://issues.apache.org/jira/browse/DERBY-1439?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Knut Anders Hatlen updated DERBY-1439:
--------------------------------------
Attachment: patch1.diff
I tried the naive approach to removing AntiGC (see the attached patch1.diff),
but that led to many IllegalThreadStateExceptions in suites.All. This can also
be seen by shutting down the only booted database and rebooting it in the same
JVM:
ij> connect 'jdbc:derby:db1;create=true';
ij> connect 'jdbc:derby:db1;shutdown=true';
ERROR 08006: Database 'db1' shutdown.
ij> connect 'jdbc:derby:db1';
ERROR XJ040: Failed to start database 'db1' with class loader
sun.misc.launcher$appclassloa...@fabe9, see the next exception for details.
ERROR XJ001: Java exception: ': java.lang.IllegalThreadStateException'.
The problem with removing AntiGC is that BaseMonitor has a daemon ThreadGroup
in which all service threads are started. Since the thread group is a daemon
group, it will be destroyed automatically when its thread count becomes zero.
AntiGC would prevent the thread group from being destroyed as long as the
driver was loaded, since it would stay alive until the driver was unloaded and
keep the thread count greater than zero. When there is no AntiGC thread to keep
up the thread count, it may go down to zero on database shutdown, as in the
example above, even if the driver is still loaded. The next attempt to start a
service thread will then fail, since one cannot add threads to a destroyed
thread group.
I suppose we could make the thread group a non-daemon group and destroy it
manually when the driver is unloaded, but then we'd first have to wait for all
service threads to complete, which may introduce possibilities for hangs on
system shutdown (for example because of DERBY-594). Another option may be to
detect that this has happened and create a new daemon group when needed.
> Investigate removing the antiGC thread in embedded Derby
> --------------------------------------------------------
>
> Key: DERBY-1439
> URL: https://issues.apache.org/jira/browse/DERBY-1439
> Project: Derby
> Issue Type: Improvement
> Components: Services
> Reporter: Daniel John Debrunner
> Priority: Minor
> Attachments: patch1.diff
>
>
> The antiGC thread was originally created to avoid the DriverManager class
> being garbage collected when no refrences existed to it and it had loaded the
> embedded JDBC driver (and hence shutting down the engine). This was an issue
> with JDK 1.1. Since Derby does not support jdk1.1 and garbage collection of
> classes is clearly defined, it is possible the thread serves no useful
> purpose.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.