Semaphore cannot be released in AdalAuthenticator
See original GitHub issueVersion
4.4.3
Describe the bug
The bot is running SDK Microsoft.Bot.Builder 4.4.3
in a Linux docker env of base image dotnet:2.1-runtime
.
We see the semaphore error SemaphoreFullException
with error message “Adding the specified count to the semaphore would cause it to exceed its maximum count”, which suggests semaphore is released more than acquired. From the code in AdalAuthenticator.fs
, we do not see the reason how it can happen. Moreover we pulled the botbuilder source code into our application and added some logging around the AdalAuthenticator code to do a test. When the issue happened, semaphore was acquired successfully by waitOne()
and when Release()
function was called the first time after acquired, it failed and went to retry.
The issue happened mostly after a production deployment. We guess it’s because of a spike of the traffic. However, we could not reliably reproduce the issue.
We also tried to replace Semaphore
with SemaphoreSlim
since the later doesn’t use system calls, which might be the issue. After we used SemaphoreSlim
, we cannot reproduce the issue anymore but it doesn’t mean it’s fixed since we could not reliably reproduce the issue before as I said.
I’d like to get some thoughts from community or anyone else has experienced the same issue. Should we change it to SemaphoreSlim
since it is supposed to be more suitable for the use case? I know @carlosscastro has made a lot of testings when submitted the PR https://github.com/microsoft/botbuilder-dotnet/pull/1299. Do you have any suggestions on this? Thanks
[bug]
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thanks for reporting this @chaoteng, and for the thorough description! Let me take a look and analyze under which conditions this might happen.
This has been released earlier this week as part of the C# 4.5.2 SDK.
Please re-open if the issue persists.