-
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
optimize: use expire key instead hash when using redis as registry center #4176
Conversation
7d17f16
to
161f7ca
Compare
Codecov Report
@@ Coverage Diff @@
## develop #4176 +/- ##
=============================================
- Coverage 48.55% 48.53% -0.03%
Complexity 3791 3791
=============================================
Files 724 724
Lines 24236 24239 +3
Branches 2970 2971 +1
=============================================
- Hits 11768 11764 -4
- Misses 11229 11232 +3
- Partials 1239 1243 +4
|
...iscovery-redis/src/main/java/io/seata/discovery/registry/redis/RedisRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
The scheduled task renew triggers pub / sub every time, even if the serverlist is not changed |
@slievrly Do you mean that we can optimize the logic? we update the And, you remind me that there is another problem after I use string key instead hash. |
7ca43b1
to
6993106
Compare
6993106
to
abe0717
Compare
…/seata into develop � Conflicts: � discovery/seata-discovery-redis/src/main/java/io/seata/discovery/registry/redis/RedisRegistryServiceImpl.java
I add some code in my local version of seata public class RedisRegistryServiceImpl implements RegistryService<RedisListener> {
List<InetSocketAddress> lookupByCluster(String clusterName) {
// ......
Set<InetSocketAddress> addrSet = CLUSTER_ADDRESS_MAP.getOrDefault(clusterName, Collections.emptySet());
LOGGER.info("返回的addrSet是:[{}]", addrSet);
return new ArrayList<>(addrSet);
}
private void updateClusterAddressMap(Jedis jedis, String redisRegistryKey) {
// ......
if (!newAddressSet.equals(CLUSTER_ADDRESS_MAP.get(clusterName))) {
LOGGER.info("update map :[{}] --> [{}]", CLUSTER_ADDRESS_MAP.get(clusterName), newAddressSet);
CLUSTER_ADDRESS_MAP.put(clusterName, newAddressSet);
}
}
} this is what I see on client side
|
...iscovery-redis/src/main/java/io/seata/discovery/registry/redis/RedisRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
506a138
to
173b3e0
Compare
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
Ⅰ. Describe what this PR did
use expire key instead hash when using redis as registry cente.
hash version:
expire String key version:
the redis registry key live 5 seconds, the heart-beat thread pool will auto refresh key every 2 seconds
Ⅱ. Does this pull request fix one issue?
fixes #4100
Ⅲ. Why don't you add test cases (unit test/integration test)?
I may need a sample to write unit test.
I 've tested with seata-samples
Ⅳ. Describe how to verify it
test with seata-samples
check redis
Ⅴ. Special notes for reviews