Skip to content
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

Better handle event reset in LoggingService #11279

Conversation

YuliiaKovalova
Copy link
Member

Fixes #
https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2320135/

Context

Reset() method invocation sometimes causes exception System.IO.IOException: 'The handle is invalid.'.
Very likely it happens on application shutdown.
The assumption is:

  • ShutdownComponent starts and gets the _lockObject
  • It cleans up/disposes the events
  • Meanwhile our logging thread is trying to use those same events without checking _lockObject in context of StartLoggingEventProcessing()

Changes Made

use the same lock in StartLoggingEventProcessing() to protect a handle from invalid state.

Testing

n/a

@SimaTian
Copy link
Member

SimaTian commented Jan 14, 2025

Can you try benchmarking this and checking how this behaves on a multithreaded build please?
I've tried running this on OrchardCore with 10 processes and it failed to finish any of the runs I've tried - it runs much slower at a glance, and then finally it stalls indefinitely. I suspect a deadlock but I'm not deep enough in the code to know for sure.
Steps to reproduce:

  • attempt to clean via artifacts\bin\bootstrap\core\dotnet.exe build OrchardCore.sln -maxcpucount:10 -tl:true -t:Clean
  • It normally finishes within ~7 seconds
  • however it's locked for more than half of a minute or so.

had to kill dotnet externally to unlock, not responding even to Ctrl + C

@SimaTian SimaTian self-requested a review January 14, 2025 12:36
@YuliiaKovalova YuliiaKovalova marked this pull request as draft January 14, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants