-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: support RedisLocker#acquireLock use LUA mode #3472
feature: support RedisLocker#acquireLock use LUA mode #3472
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3472 +/- ##
=============================================
- Coverage 52.09% 51.76% -0.33%
+ Complexity 3498 3484 -14
=============================================
Files 637 638 +1
Lines 21105 21154 +49
Branches 2618 2619 +1
=============================================
- Hits 10994 10951 -43
- Misses 9025 9117 +92
Partials 1086 1086
|
sb.append(" end "); | ||
sb.append("for i =1, keySize do "); | ||
sb.append(" if(array[i] == 'no') then "); | ||
sb.append("redis.call('HSET',KEYS[i],'").append(XID).append("',ARGV[(i-1)*7+4]);"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please optimize the string as a constant
…acquireLock # Conflicts: # server/src/main/java/io/seata/server/storage/redis/lock/RedisLocker.java
} catch (IOException e) { | ||
return; | ||
} | ||
ACQUIRE_LOCK_SHA = jedis.scriptLoad(acquireLockLuaByFile.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) { 放到这比较合适,避免压根文件不存在时还创建一个连接
if (ACQUIRE_LOCK_SHA == null) { | ||
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) { | ||
File luaFile = FileLoader.load(REDIS_LUA_FILE_NAME); | ||
if (luaFile != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议增加日志明确目前竞争锁走的是lua还是pipeline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…into optimize_redislock#acquireLock
# Conflicts: # changes/1.5.0.md
args.add(needLockXid); | ||
for (LockDO lockDO : needLockDOs) { | ||
keys.add(buildLockKey(lockDO.getRowKey())); | ||
args.add(lockDO.getXid()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已经删除重复参数
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## develop #3472 +/- ##
=============================================
+ Coverage 51.89% 51.97% +0.07%
+ Complexity 3537 3506 -31
=============================================
Files 639 639
Lines 21414 21183 -231
Branches 2664 2627 -37
=============================================
- Hits 11113 11010 -103
+ Misses 9193 9082 -111
+ Partials 1108 1091 -17 |
Ⅰ. Describe what this PR did
Use Lua to ensure atomicity
Ⅱ. Does this pull request fix one issue?
no
Ⅲ. Why don't you add test cases (unit test/integration test)?
jedis mock not support jedis.eval
Ⅳ. Describe how to verify it
acquireLock
Ⅴ. Special notes for reviews