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

Fixed issue: throw IOException: The process cannot access the file 'xxxx\log\Non-Session-Log.messages.current.log' because it is being used by another process. #890

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

VAllens
Copy link

@VAllens VAllens commented Sep 26, 2024

  • throw System.IOException: The process cannot access the file 'xxxx\log\Non-Session-Log.messages.current.log' because it is being used by another process. (Validation using ThreadedSocketAcceptorTests.TestRecreation unit test method)
  • When the Acceptor stops, the _isStarted field value should be set to false.
  • Since .NET runtime’s exceptions use culture information to set the Message value, the message value of the Exception should not be asserted, but rather the ErrorCode of the Exception. (Verify by switching the regional settings of the operating system to a non-English speaking country.)

…xxx\log\Non-Session-Log.messages.current.log' because it is being used by another process.
…ssage value, the message value of the Exception should not be asserted, but rather the ErrorCode of the Exception.
@CLAassistant
Copy link

CLAassistant commented Sep 26, 2024

CLA assistant check
All committers have signed the CLA.

@VAllens
Copy link
Author

VAllens commented Sep 26, 2024

This pull request is to fix this issue: #891

@gbirchmeier
Copy link
Member

On Windows I am able to replicate your the #891 bug. (Kind of embarrassed about that one)

However, when I run tests on this PR branch I'm still seeing issues. The tests themselves pass, but there's a failure on cleanup. It's not the same every time, but it's always variations of ObjectDisposedException. I'm still investigating.

@gbirchmeier
Copy link
Member

The exceptions I'm seeing are triggered when I run a sequence of SessionDynamicTest tests. Running just "DifferentPortForAcceptorTest" followed by "DynamicInitiator" will trigger it.

@VAllens
Copy link
Author

VAllens commented Sep 30, 2024

On Windows I am able to replicate your the #891 bug. (Kind of embarrassed about that one)

However, when I run tests on this PR branch I'm still seeing issues. The tests themselves pass, but there's a failure on cleanup. It's not the same every time, but it's always variations of ObjectDisposedException. I'm still investigating.

I also encountered ObjectDisposedException exception which occurs only during dotnet test command execution. And it behaves normally in Visual Studio UI.
But the ObjectDisposedException exception has nothing to do with this PR and occurs in the master branch as well.

@gbirchmeier
Copy link
Member

You're right, all tests pass in VS.

In addition to failing dotnet test, it also fails in Jetbrains Rider (my preferred IDE) on Windows. (Probably Rider is using dotnet test under the hood.)

At any rate, I need to fix that. The UTs need to pass on all these platforms.

@VAllens
Copy link
Author

VAllens commented Oct 1, 2024

You're right, all tests pass in VS.

In addition to failing dotnet test, it also fails in Jetbrains Rider (my preferred IDE) on Windows. (Probably Rider is using dotnet test under the hood.)

At any rate, I need to fix that. The UTs need to pass on all these platforms.

Okay

@VAllens
Copy link
Author

VAllens commented Oct 9, 2024

You're right, all tests pass in VS.

In addition to failing dotnet test, it also fails in Jetbrains Rider (my preferred IDE) on Windows. (Probably Rider is using dotnet test under the hood.)

At any rate, I need to fix that. The UTs need to pass on all these platforms.

Hi, Bro. :)
Any luck?

@VAllens
Copy link
Author

VAllens commented Oct 10, 2024

Initial analysis shows that the ObjectDisposedException is thrown when the SessionDynamicTest.DynamicInitiator method is executed.

Upon further analysis, one of the following two modifications will allow the dotnet test command to work properly and no longer throw exceptions:

  1. Comment line 108 of the SocketInitiatorThread.cs file.

  2. Add OperationCanceledException exception recognition to line 155 of the SocketInitiatorThread.cs file.

_currentReadTask = null;

if (ex.InnerException is OperationCanceledException)
{
    // Nothing read
    return 0;
}

var ioException = ex.InnerException as IOException;

I would suggest using the second way to fix the problem.

Also, I found out that an exception actually occurs when executing the test on the Visual Studio UI,
except that the exception is thrown at the end of the test,
so it's not caught by the test framework.

…SessionLog instance has been released, there are no side effects even if the OnEvent function is called unexpectedly.
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.

3 participants