Why network thread needs to be stopped when fdb java client process is shutting down?

I have read this discussion and have also seen this PR .

On the continuation of the above

  1. Can someone let me know why it is needed to stop fdb network thread when the JVM using fdb java client itself is shutting down?

  2. Now that in fdb 6.3.x we will have an option to disable fdb shutdown hook, so what all things may go wrong if we disable the fdb java client shutdown hook and don’t stop the fdb network thread when JVM is going down?

From what I can tell, one of the concerns is that the network thread accesses some global state. When you don’t wait for the network thread to stop before terminating the program, then there can be a race between destruction of that global state and accesses of it from the network thread. There have been attempts to clean up some of these cases, and I think there’s a desire to eliminate this class of problem entirely, but for now we don’t make any guarantees.

In practice, I suspect most of the time you fail to shut down the network thread, nothing bad will happen. It may be possible that sometimes the client crashes during shutdown. Recently, we also saw that the serialization of some messages to the cluster was corrupted, which can result in crashes on the cluster or potentially worse. We fixed the one particular case where we’ve seen this problem, but I’m not sure I can definitively say that there aren’t others.

1 Like