StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

Lock contention is found in our service

Open wangxiujuan opened this issue 7 years ago • 1 comments

We are using "StackExchange.Redis" version="2.0.601". Found AwareLock::Contention in different APIs. I have read the blog https://blog.marcgravell.com/2019/02/fun-with-spiral-of-death.html and checked our code. Besides this blog, what other clues I can start to investigate this issue?

  1. clr.dll!AwareLock::Contention clr.dll!Monitor.Contention (Lock) Pipelines.Sockets.Unofficial.DedicatedThreadPoolPipeScheduler!Schedule System.IO.Pipelines.Pipe!FlushAsync System.IO.Pipelines.Pipe+DefaultPipeWriter!FlushAsync StackExchange.Redis.PhysicalConnection!FlushAsync StackExchange.Redis.PhysicalBridge!WriteMessageTakingWriteLockAsync StackExchange.Redis.PhysicalBridge!TryWriteAsync StackExchange.Redis.ServerEndPoint!TryWriteAsync StackExchange.Redis.ConnectionMultiplexer!ExecuteAsyncImpl StackExchange.Redis.RedisBase!ExecuteAsync StackExchange.Redis.RedisDatabase!KeyTimeToLiveAsync Micrsoft.ActivityService.CacheClient.Redis.LocalRedisService+d__15!MoveNext LocalRedisService Redis CacheClient ActivityService Async/Task Calls by Namespace All Stacks (Inclusive Time Merged)

  2. clr.dll!AwareLock::Contention clr.dll!Monitor.Contention (Lock) Pipelines.Sockets.Unofficial.DedicatedThreadPoolPipeScheduler!Schedule System.IO.Pipelines.Pipe!FlushAsync System.IO.Pipelines.Pipe+DefaultPipeWriter!FlushAsync StackExchange.Redis.PhysicalConnection!FlushAsync StackExchange.Redis.PhysicalBridge!WriteMessageTakingWriteLockAsync StackExchange.Redis.PhysicalBridge!TryWriteAsync StackExchange.Redis.ServerEndPoint!TryWriteAsync StackExchange.Redis.ConnectionMultiplexer!ExecuteAsyncImpl StackExchange.Redis.RedisBase!ExecuteAsync StackExchange.Redis.RedisDatabase!StringDecrementAsync Microsoft.ActivityService.CacheClient.Redis.LocalRedisService+d__12!MoveNext LocalRedisService Redis CacheClient ActivityService Microsoft Async/Task Calls by Namespace All Stacks (Inclusive Time Merged)

3.clr.dll!AwareLock::Contention clr.dll!Monitor.Contention (Lock) Pipelines.Sockets.Unofficial.DedicatedThreadPoolPipeScheduler!Schedule System.IO.Pipelines.Pipe!FlushAsync System.IO.Pipelines.Pipe+DefaultPipeWriter!FlushAsync StackExchange.Redis.PhysicalConnection!FlushAsync StackExchange.Redis.PhysicalBridge!WriteMessageTakingWriteLockAsync StackExchange.Redis.PhysicalBridge!TryWriteAsync StackExchange.Redis.ServerEndPoint!TryWriteAsync StackExchange.Redis.ConnectionMultiplexer!ExecuteAsyncImpl StackExchange.Redis.RedisBase!ExecuteAsync StackExchange.Redis.RedisDatabase!StringGetAsync Microsoft.ActivityService.CacheClient.Redis.LocalRedisService+d__3!MoveNext LocalRedisService Redis CacheClient ActivityService Microsoft Async/Task Calls by Namespace All Stacks (Inclusive Time Merged)

  1. clr.dll!AwareLock::Contention clr.dll!Monitor.Contention (Lock) Pipelines.Sockets.Unofficial.DedicatedThreadPoolPipeScheduler!Schedule System.IO.Pipelines.Pipe!FlushAsync System.IO.Pipelines.Pipe+DefaultPipeWriter!FlushAsync StackExchange.Redis.PhysicalConnection!FlushAsync StackExchange.Redis.PhysicalBridge!WriteMessageTakingWriteLockAsync StackExchange.Redis.PhysicalBridge!TryWriteAsync StackExchange.Redis.ServerEndPoint!TryWriteAsync StackExchange.Redis.ConnectionMultiplexer!ExecuteAsyncImpl StackExchange.Redis.RedisBase!ExecuteAsync Microsoft.ActivityService.CacheClient.Redis.LocalRedisService+d__11!MoveNext LocalRedisService Redis CacheClient ActivityService Microsoft Async/Task Calls by Namespace All Stacks (Inclusive Time Merged)

wangxiujuan avatar Aug 18 '19 06:08 wangxiujuan

The fact that the various threads are using a shared lock to coordinate their efforts isn't an issue to investigate in this case - it's a proper use of the mechanism and expect behavior :) Think of it this way: the threads are all active, they have to be somewhere in their stacks, you're seeing this particular spot.

Closing this out just to cleanup since this is behaving as it should :)

NickCraver avatar Mar 14 '20 15:03 NickCraver