sentry-dotnet
sentry-dotnet copied to clipboard
Process isolation in offline caching
Testing around with an implementation for #1067. I took some guidance from the existing draft PR, and made some adjustments. I put this up to see how you feel about the general approach before it gets too far. Open to any and all feedback.
| Fails | |
|---|---|
| :no_entry_sign: | Please consider adding a changelog entry for the next release. |
Instructions and example for changelog
Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.
Example:
- Process isolation in offline caching ([#1209](https://github.com/getsentry/sentry-dotnet/pull/1209))
If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.
Generated by :no_entry_sign: dangerJS against 87de2f37e1eca9ae9924dabb0ddaad06b90c8aa5
I was thinking right now and maybe we could simply leave an open File stream for each process. The idea is simple, each process will have an open file, let's call it "SentryWatcher", once an instance is opened, it'll try to delete this file, if the process is open, the FILE stream will stay open and it'll throw an IOException because the file is open by another process and cannot be opened. And in case of the process is not running, you'll be able to delete it and with that, you'll be sure that the isolated process is no longer active.
Another approach would be to use FileSystemWatcher to make some sort of communication system across processes, The idea is the same but you don't keep your FILE stream open, instead, you react from it getting changed (for example getting deleted) and react by creating the watched file, the other process will notice the file is back with externalWatcher.WaitForChanged(WatcherChangeTypes.Created, 1000) and will assume the process is active.
Two ideas that could replace the current System.Diagnostics checks for inactive Processes.