2881099 / csredis

.NET Core or .NET Framework 4.0+ client for Redis and Redis Sentinel (2.8) and Cluster. Includes both synchronous and asynchronous clients.
MIT License
2.01k stars 414 forks source link

分布式锁在释放锁后,没有删除对应的KEY。导致再次获取锁的时候要等待上次锁超时的后才能获取 #454

Closed yundou147 closed 2 years ago

yundou147 commented 2 years ago

var lockResult = RedisHelper.Lock("init_db_lock", 3) ockResult.Unlock();

观察redis数据发现 没有删除对应的key (看源码内部是:CSRedisClientLock:init_db_lock)

导致结果:再次获取锁的时候要等待上次锁超时的后才能获取

yundou147 commented 2 years ago

已实际测试,已导致我程序每次启动都要卡很久

yundou147 commented 2 years ago

我现在解决方法是: if (lockResult.Unlock()) { RedisHelper.Del("CSRedisClientLock:init_db_lock"); }

2881099 commented 2 years ago

Unlock 会删掉 CSRedisClientLock:init_db_lock 的,你看看是不是自己程序重新加了锁。

yundou147 commented 2 years ago

Unlock 会删掉 CSRedisClientLock:init_db_lock 的,你看看是不是自己程序重新加了锁。

我看了key key没有删除掉 但是这个key的value 是空的

2881099 commented 2 years ago

你单独写一个 console app 测试,看会不会删