New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convenience start methods must shutdown on problems #44
Comments
Wrapped the additional startup logic in EmbeddedStorageManager#start after calling StorageManager#start with a try-catch and an exception handling that terminates all active threads and closes open files. |
As described in #4, there is still a difference between the queryable information of being shutdown and the state of actually being completely inactive and having no more files opened.
Probably all 3 of these. Then, the problem should be gone and the complex cases of shutting down, being shut down and being really inactive should be conveniently handleable. |
StorageLockedFile already has a user-count mechanism, albeit a too simplistic one. The user count is a simple int. Necessary is a "usages" count per user, e.g. the storage channel instance is a user, the backup handler is another user. Shutting down the storage clears all usages of the channel instance but not those of the backup handler. Only when the total usage count is 0 can a file really be closed. Of course this mechanism has to be properly synchronized since multiple threads are calling it with arbitrary timing. This also means that there must be a "closingDecrement" method that decrements the usage count and immediately closes the file if it removed the last usage. |
Implemented a proper "user" registration, including a checking close() method, a corresponding tryClose() method, lock-protected unregisterClosing variants, including closing logic. Testing showed some forgotten details (initial the file manager being initially registered as a user at data file instance creation time). Those have been fixed, now. The current reason is: The test already waits for the storage to be inactive. This is going to be ... "fun"... |
The Windows ressource monitor shows that the file handle is indeed released. Albeit after a suprisingly long time (~30 seconds) while it still writes to the file with the tiniest bandwith (slowly dropping from ~500 to ~150 B/s). This is all very, very wird. |
After more research:
Yet, still, the file keeps reappearing. Also weird: |
The reason was a still existing user count, but swallowed by "closeSilent" logic. Nevertheless: closeSilent is a naive pestilence that has to be exterminated sooner rather than later. Tested. Works. |
Works in JUnit tests as well, so this issue can be closed. |
Bane of convenience methods:
If complex logic is hidden in a short methode, there is no way to add a try-catch and care for cleanup (e.g. shutdown a started storage instance). So the convenience methods have to handle such cases.
Especially ensuring that all file handles are closed.
Maybe even with an internal "forceAbort" or something like that, in case task processing does not work anymore.
The text was updated successfully, but these errors were encountered: