You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/10/13 07:05:07 UTC
[GitHub] [rocketmq] fuyou001 opened a new pull request, #5306: [ISSUE #5305] fix proxy TopicRouteService cache bug
fuyou001 opened a new pull request, #5306:
URL: https://github.com/apache/rocketmq/pull/5306
**Make sure set the target branch to `develop`**
## What is the purpose of the change
XXXXX
## Brief changelog
XX
## Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
- [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
- [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
- [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test` to make sure integration-test pass.
- [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] aaron-ai commented on a diff in pull request #5306: [ISSUE #5305] fix proxy TopicRouteService cache bug
Posted by GitBox <gi...@apache.org>.
aaron-ai commented on code in PR #5306:
URL: https://github.com/apache/rocketmq/pull/5306#discussion_r994542098
##########
proxy/src/test/java/org/apache/rocketmq/proxy/service/route/ClusterTopicRouteServiceTest.java:
##########
@@ -67,4 +77,45 @@ public void testGetTopicRouteForProxy() throws Throwable {
assertEquals(1, proxyTopicRouteData.getBrokerDatas().size());
assertEquals(addressList, proxyTopicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(MixAll.MASTER_ID));
}
+
+ @Test
+ public void testTopicRouteCaffeineCache() throws InterruptedException {
+ String key = "abc";
+ String value = key;
+ final AtomicBoolean throwException = new AtomicBoolean();
+ ThreadPoolExecutor cacheRefreshExecutor = ThreadPoolMonitor.createAndMonitor(
+ 10, 10, 30L, TimeUnit.SECONDS, "test", 10);
+ LoadingCache<String /* topicName */, String> topicCache = Caffeine.newBuilder().maximumSize(30).
+ refreshAfterWrite(2, TimeUnit.SECONDS).executor(cacheRefreshExecutor).build(new CacheLoader<String, String>() {
+ @Override public @Nullable String load(@NonNull String key) throws Exception {
+ try {
+ if (throwException.get()) {
+ throw new RuntimeException();
+ } else {
+ throwException.set(true);
+ return value;
+ }
+ } catch (Exception e) {
+ if (TopicRouteHelper.isTopicNotExistError(e)) {
+ return "";
+ }
+ throw e;
+ }
+ }
+
+ @Override
+ public @Nullable String reload(@NonNull String key, @NonNull String oldValue) throws Exception {
+ try {
+ return load(key);
+ } catch (Exception e) {
+ return oldValue;
+ }
+ }
+ });
+
+ System.out.println(topicCache.get(key));
Review Comment:
Use logging system rather than standard output in java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] xdkxlk commented on a diff in pull request #5306: [ISSUE #5305] fix proxy TopicRouteService cache bug
Posted by GitBox <gi...@apache.org>.
xdkxlk commented on code in PR #5306:
URL: https://github.com/apache/rocketmq/pull/5306#discussion_r994334559
##########
proxy/src/main/java/org/apache/rocketmq/proxy/service/route/TopicRouteService.java:
##########
@@ -88,6 +89,15 @@ public TopicRouteService(MQClientAPIFactory mqClientAPIFactory) {
throw e;
}
}
+
+ @Override public @Nullable MessageQueueView reload(@NonNull String key,
+ @NonNull MessageQueueView oldValue) throws Exception {
+ try {
+ return load(key);
+ } catch (Exception e) {
Review Comment:
Add a log here is better
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] codecov-commenter commented on pull request #5306: [ISSUE #5305] fix proxy TopicRouteService cache bug
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #5306:
URL: https://github.com/apache/rocketmq/pull/5306#issuecomment-1277164807
# [Codecov](https://codecov.io/gh/apache/rocketmq/pull/5306?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#5306](https://codecov.io/gh/apache/rocketmq/pull/5306?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (87b1a68) into [develop](https://codecov.io/gh/apache/rocketmq/commit/8d10c9601d137be397d17003634cceb89c949a69?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8d10c96) will **decrease** coverage by `0.00%`.
> The diff coverage is `0.00%`.
```diff
@@ Coverage Diff @@
## develop #5306 +/- ##
=============================================
- Coverage 43.20% 43.19% -0.01%
- Complexity 7807 7809 +2
=============================================
Files 998 998
Lines 69451 69454 +3
Branches 9169 9169
=============================================
+ Hits 30003 30004 +1
- Misses 35682 35683 +1
- Partials 3766 3767 +1
```
| [Impacted Files](https://codecov.io/gh/apache/rocketmq/pull/5306?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ocketmq/proxy/service/route/TopicRouteService.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L3NlcnZpY2Uvcm91dGUvVG9waWNSb3V0ZVNlcnZpY2UuamF2YQ==) | `61.81% <0.00%> (-3.57%)` | :arrow_down: |
| [...ketmq/common/protocol/body/ConsumerConnection.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vcHJvdG9jb2wvYm9keS9Db25zdW1lckNvbm5lY3Rpb24uamF2YQ==) | `95.83% <0.00%> (-4.17%)` | :arrow_down: |
| [...a/org/apache/rocketmq/filter/util/BloomFilter.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9maWx0ZXIvdXRpbC9CbG9vbUZpbHRlci5qYXZh) | `60.43% <0.00%> (-2.20%)` | :arrow_down: |
| [...mq/store/ha/autoswitch/AutoSwitchHAConnection.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL2hhL2F1dG9zd2l0Y2gvQXV0b1N3aXRjaEhBQ29ubmVjdGlvbi5qYXZh) | `70.43% <0.00%> (-1.35%)` | :arrow_down: |
| [.../apache/rocketmq/store/ha/DefaultHAConnection.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL2hhL0RlZmF1bHRIQUNvbm5lY3Rpb24uamF2YQ==) | `65.86% <0.00%> (-1.21%)` | :arrow_down: |
| [.../rocketmq/broker/filter/ConsumerFilterManager.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvZmlsdGVyL0NvbnN1bWVyRmlsdGVyTWFuYWdlci5qYXZh) | `72.19% <0.00%> (-0.90%)` | :arrow_down: |
| [...rocketmq/broker/processor/PopMessageProcessor.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcHJvY2Vzc29yL1BvcE1lc3NhZ2VQcm9jZXNzb3IuamF2YQ==) | `37.63% <0.00%> (-0.54%)` | :arrow_down: |
| [...che/rocketmq/test/lmq/benchmark/BenchLmqStore.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvdGVzdC9sbXEvYmVuY2htYXJrL0JlbmNoTG1xU3RvcmUuamF2YQ==) | `50.24% <0.00%> (-0.50%)` | :arrow_down: |
| [...ent/impl/consumer/DefaultLitePullConsumerImpl.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jbGllbnQvaW1wbC9jb25zdW1lci9EZWZhdWx0TGl0ZVB1bGxDb25zdW1lckltcGwuamF2YQ==) | `69.37% <0.00%> (-0.47%)` | :arrow_down: |
| [...cketmq/broker/processor/PopBufferMergeService.java](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcHJvY2Vzc29yL1BvcEJ1ZmZlck1lcmdlU2VydmljZS5qYXZh) | `37.44% <0.00%> (ø)` | |
| ... and [8 more](https://codecov.io/gh/apache/rocketmq/pull/5306/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] fuyou001 commented on a diff in pull request #5306: [ISSUE #5305] fix proxy TopicRouteService cache bug
Posted by GitBox <gi...@apache.org>.
fuyou001 commented on code in PR #5306:
URL: https://github.com/apache/rocketmq/pull/5306#discussion_r994481114
##########
proxy/src/main/java/org/apache/rocketmq/proxy/service/route/TopicRouteService.java:
##########
@@ -88,6 +89,15 @@ public TopicRouteService(MQClientAPIFactory mqClientAPIFactory) {
throw e;
}
}
+
+ @Override public @Nullable MessageQueueView reload(@NonNull String key,
+ @NonNull MessageQueueView oldValue) throws Exception {
+ try {
+ return load(key);
+ } catch (Exception e) {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] lizhanhui merged pull request #5306: [ISSUE #5305] fix proxy TopicRouteService cache bug
Posted by GitBox <gi...@apache.org>.
lizhanhui merged PR #5306:
URL: https://github.com/apache/rocketmq/pull/5306
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] fuyou001 commented on a diff in pull request #5306: [ISSUE #5305] fix proxy TopicRouteService cache bug
Posted by GitBox <gi...@apache.org>.
fuyou001 commented on code in PR #5306:
URL: https://github.com/apache/rocketmq/pull/5306#discussion_r994545963
##########
proxy/src/test/java/org/apache/rocketmq/proxy/service/route/ClusterTopicRouteServiceTest.java:
##########
@@ -67,4 +77,45 @@ public void testGetTopicRouteForProxy() throws Throwable {
assertEquals(1, proxyTopicRouteData.getBrokerDatas().size());
assertEquals(addressList, proxyTopicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(MixAll.MASTER_ID));
}
+
+ @Test
+ public void testTopicRouteCaffeineCache() throws InterruptedException {
+ String key = "abc";
+ String value = key;
+ final AtomicBoolean throwException = new AtomicBoolean();
+ ThreadPoolExecutor cacheRefreshExecutor = ThreadPoolMonitor.createAndMonitor(
+ 10, 10, 30L, TimeUnit.SECONDS, "test", 10);
+ LoadingCache<String /* topicName */, String> topicCache = Caffeine.newBuilder().maximumSize(30).
+ refreshAfterWrite(2, TimeUnit.SECONDS).executor(cacheRefreshExecutor).build(new CacheLoader<String, String>() {
+ @Override public @Nullable String load(@NonNull String key) throws Exception {
+ try {
+ if (throwException.get()) {
+ throw new RuntimeException();
+ } else {
+ throwException.set(true);
+ return value;
+ }
+ } catch (Exception e) {
+ if (TopicRouteHelper.isTopicNotExistError(e)) {
+ return "";
+ }
+ throw e;
+ }
+ }
+
+ @Override
+ public @Nullable String reload(@NonNull String key, @NonNull String oldValue) throws Exception {
+ try {
+ return load(key);
+ } catch (Exception e) {
+ return oldValue;
+ }
+ }
+ });
+
+ System.out.println(topicCache.get(key));
Review Comment:
> Use logging system rather than standard output in java
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org