I believe this is one causes leads shutdown to hang.
Because having a method to just iterate the mLiveDatabases array in the gLiveDatabasehashtable might not be a good idea, I'm working on finding the place which causes the issue if it's possible.
While reading the code, I'm a bit suspect the code in . So, the helper is held by the Database, the helper holds the callback, the Database will be removed in the CleanupMetadata later, and they all live in the Background thread. However, if the IPC is about to close the channel, there seems to be a chance to kill the Database object in the Background thread. In this case, the callback is not executed, all the stuff is destructed, and thus the Database is not removed from the table in the gLiveDatabaseHashtable.
I have a patch for testing to try to catch the Database, but if I cannot hit the problem, I'm thinking to provide a patch to fix this directly.
The procedure of the deletion of IPC subtree.