Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

fix(logging): Prevent IO ex concurrent writes #1057

Conversation

CrispyDrone
Copy link
Contributor

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Bug fix.

⤵️ What is the current behavior?

File.AppendText takes an exclusive write lock on a file. This means
that when multiple writes are occurring at the same time, an
IOException is thrown saying: "The process cannot access the file X
because it is being used by another process".

💥 Does this PR introduce a breaking change?

No.

This fix will only work as long as the logger is used as a "singleton" throughout the application as the lock is not a static property. I decided against making it static because the constructor has file path as a parameter.

🐛 Recommendations for testing

Use --logfile. This caused issues especially in the package update lookup process as it's parallelized.

`File.AppendText` takes an exclusive write lock on a file. This means
that when multiple writes are occurring at the same time, an
`IOException` is thrown saying: "The process cannot access the file X
because it is being used by another process".
@skolima
Copy link
Collaborator

skolima commented Nov 21, 2020

Looks good. Thank you for your contribution.

@skolima skolima merged commit 599803c into NuKeeperDotNet:master Nov 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants