Prevent too many ProcessBacklog() from being scheduled by devbv · Pull Request #1574 · StackExchange/StackExchange.Redis
This PR prevents the situation that a consumer makes the number of backlog 1->0 infinitely and many producers schedule new ProcessBacklog() after they make the number of backlog 0->1.
The situation could lead a starvation of thread pool and a lot of timeout when we use transaction heavily. (#1572)
devbv
changed the title
Prevent too many ProcesBacklog() from being scheduled
Prevent too many ProcessBacklog() from being scheduled
@mgravell I am also seeing these errors in my logs. They are a semi related to the issue solved with #1585 in that in these timeout scenarios seems to cascade and build upon each other, and the library struggles to recover.
I would also be interested in seeing your opinion on getting this change in as well

Additional info for better understanding. This is stacktrace of threads when the timeout is occurred. You can see 9 of 10 worker threads are stopped at MutexSlim.TakeWithTimeout called by PhysicalBridge.ProcessBacklog()
This is reproduced from the sample code on #1572
mgravell added a commit that referenced this pull request
Nov 13, 2020This is a great find, and could explain a lot, but I'm not sure that the approach is the best way of solving it - I'm playing with an alternative strategy in #1612 - but: even if I merge that, I'll still give credit for the research here; much appreciated!
mgravell added a commit that referenced this pull request
Nov 13, 2020* alternative implementation along the lines of #1574: - make the backlog processor async - check for work *before* trying to get the lock * release notes
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