abelaska / jedis-lock

Jedis distributed lock support
203 stars 118 forks source link

i think these's a race condition error in this code #8

Open 823126028 opened 8 years ago

823126028 commented 8 years ago

if (currentLock.isExpiredOrMine(lockUUID)) { //when two process run to here,the first one get the lock,and return true,but he get the lock,but the second one will grab it; //the second one goto next recycle and get lock too,he really got the lock. //there is two process get the lock.....and when first one will release the second one's lock,you know then will always recyle like this. String oldValueStr = jedis.getSet(lockKeyPath, newLock.toString()); if (oldValueStr != null && oldValueStr.equals(currentValueStr)) { this.lock = newLock; return true; } } } i try to fix this , i think we should use watch to keep it in transaction