The reason that index Json is wiped out sometimes may be related to the fact that during shutdown on during a memory error when we are writing the index Jason they may be some race condition where a second right is cold after the in-memory object that's written to disk is already emptied. This might happen because we have multiple cleanup functions that execute possibly multiple times on shutdown. It may not be this cause cuz this bug is being hard to reproduce but the changes that I'm bringing down from upstream consist of unifying the cleanup functions and performing a check that we are not writing an empty object this may not solve the issue but it also make us some way to address it or it may completely solve it. In any case it's more solid to have a cleanup function like this so I'm bringing the changes down.
The reason that index Json is wiped out sometimes may be related to the fact that during shutdown on during a memory error when we are writing the index Jason they may be some race condition where a second right is cold after the in-memory object that's written to disk is already emptied. This might happen because we have multiple cleanup functions that execute possibly multiple times on shutdown. It may not be this cause cuz this bug is being hard to reproduce but the changes that I'm bringing down from upstream consist of unifying the cleanup functions and performing a check that we are not writing an empty object this may not solve the issue but it also make us some way to address it or it may completely solve it. In any case it's more solid to have a cleanup function like this so I'm bringing the changes down.