-
Notifications
You must be signed in to change notification settings - Fork 125
Feature/support atomic append #346
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
Open
cortex-bt
wants to merge
13
commits into
serilog:dev
Choose a base branch
from
cortex-bt:feature/support-atomic-append
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bb22663
updated to use FileSystemAclExtensions.Create() to append to file
cortex-bt 6cf1330
added net7 as well
cortex-bt ccd907b
added to list
cortex-bt af13b14
removed net7 for now
cortex-bt 3245d2f
no need for checks
cortex-bt 93f873f
ensuring net6 uses os_mutex
cortex-bt 4627ad3
checking for platform required for .net8 to work
cortex-bt 7691dcb
creating new branch as we are only interested on .net8
cortex-bt 89bc34f
removed whitespace
cortex-bt 6822f79
added tests for atomic operations
cortex-bt 7141e6d
added tests for multiple users accessing file sink writes to
cortex-bt c13bb1a
simplified statements
cortex-bt 8e7ba53
shoulde be a == instead of !=
cortex-bt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break
shared
flag support on non-Windows platforms; we'd need to fall back to the OS mutex variant in the non-Windows cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about reverting back to using new FileStream in the if statement for no windows platforms. So net8/9 would work with the CreateFile method while the rest still work as before using the FileStream ?
e.g
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
_fileOutput = CreateFile(
_path,
FileMode.Append,
FileSystemRights.AppendData,
FileShare.ReadWrite,
length,
FileOptions.None);
_fileStreamBufferLength = length;
}
else
{
_fileOutput = new FileStream(
_path,
FileMode.Append,
FileSystemRights.AppendData,
FileShare.ReadWrite,
length,
FileOptions.None);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OS mutex would still need to be used; the machinery around atomic append and the mutex ensure writes are not overlapping, which otherwise creates garbled logs when multiple processes share the same log file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so then something like this in the csproj would be more appropriate
So for windows platforms it enables ATOMIC_APPEND and for non-Windows OS_MUTEX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSPROJ settings like that are applied at build time, but the same packaged
net8.0
andnet9.0
binaries need to run on both platforms. The example above would just make the package work only for the same OS as the build server.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any recommendations on how we could fall back to the OS mutex variant in the non-Windows cases? Or is this something that needs further planning?