You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "RongtongJin (via GitHub)" <gi...@apache.org> on 2023/04/11 08:24:59 UTC

[GitHub] [rocketmq] RongtongJin opened a new pull request, #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

RongtongJin opened a new pull request, #6571:
URL: https://github.com/apache/rocketmq/pull/6571

   **Make sure set the target branch to `develop`**
   
   ## What is the purpose of the change
   
   <!--
   If this PR fixes a GitHub issue, please add `fixes #<XXX>` or `closes #<XXX>`. Please refer to the documentation for more information:
   https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
   -->
   
   fix #6570
   
   ## Brief changelog
   
   We will only increase the queueOffset if the append message is successful.
   
   ## 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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on pull request #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1519220393

   @lizhanhui If we don't have enough time to review this PR currently, I suggest submitting another PR that fixes the bug in the original way first. That fix is minimally invasive and follows the current writing process. Then we can further review how to optimize performance in this PR.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on pull request #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1505116162

   > This fix is too complex and less performant. How about this way: Before entering the critical region, validate and serialize the messages, with consume queue offset filled with place holders. In the critical region, allocate offsets as before and replace place-holders with them. This way, critical region is minimized and CPU-intensive serialization can be parallel at the same time.
   
   Hi @lizhanhui, my fix do not change the logic of entering the critical region, but the operation of validate and serialize the messages can indeed be moved outside of topicQueueLock, I will try it.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ISSUE #6570] Optimizing the process of putting messages to improve performance [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance
URL: https://github.com/apache/rocketmq/pull/6571


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1528791586

   @caigy Completed the modification of all review comments.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on pull request #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "lizhanhui (via GitHub)" <gi...@apache.org>.
lizhanhui commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1505120923

   > > This fix is too complex and less performant. How about this way: Before entering the critical region, validate and serialize the messages, with consume queue offset filled with place holders. In the critical region, allocate offsets as before and replace place-holders with them. This way, critical region is minimized and CPU-intensive serialization can be parallel at the same time.
   > 
   > Hi @lizhanhui, my fix do not change the logic of entering the critical region, but the operation of validate and serialize the messages can indeed be moved outside of topicQueueLock, I will try it.
   
   Okay. Considering the lock is global, any extra complication should be taken seriously. Looking forward to your optimized solution.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on pull request #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1512585951

   Hi @lizhanhui, I have completed the modification. Moving the serialization operation outside the lock for general messages (messages not related to BCQ and LMQ) is simple, and this is the solution implemented in version 4.x. However, since LMQ and BCQ were introduced after version 5.0, they need to overwrite the queueOffset-related properties during putting message, which caused the current changes. Therefore, for these two types of messages (BCQ and LMQ), when serializing outside the lock, the properties are not written, and properties are serialized  and written after the queueOffset is truly determined in lock. This also makes the append process somewhat complicated. I have done some testing and it is currently running normally. Plz feel free to review.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ISSUE #6570] Optimizing the process of putting messages to improve performance [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-2453233826

   This PR is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ISSUE #6570] Optimizing the process of putting messages to improve performance [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-2461053858

   This PR was closed because it has been inactive for 3 days since being marked as stale.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "caigy (via GitHub)" <gi...@apache.org>.
caigy commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1180284493


##########
store/src/main/java/org/apache/rocketmq/store/CommitLog.java:
##########
@@ -1966,4 +1994,12 @@ public void cleanSwappedMap(long forceCleanSwapIntervalMs) {
     public FlushManager getFlushManager() {
         return flushManager;
     }
+
+    public static boolean isMultiDispatchMsg(MessageExtBrokerInner msg) {
+        return !StringUtils.isBlank(msg.getProperty(MessageConst.PROPERTY_INNER_MULTI_DISPATCH)) && !msg.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX);

Review Comment:
   It may be more simple to use `isNotBlank()` directly.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ni-ze commented on pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "ni-ze (via GitHub)" <gi...@apache.org>.
ni-ze commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1525111786

   TGTM~


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on a diff in pull request #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "lizhanhui (via GitHub)" <gi...@apache.org>.
lizhanhui commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1163955750


##########
store/src/main/java/org/apache/rocketmq/store/queue/BatchConsumeQueue.java:
##########
@@ -809,10 +818,11 @@ private MappedFile searchTimeFromFiles(long timestamp) {
     }
 
     /**
-     * Find the offset of which the value is equal or larger than the given targetValue.
-     * If there are many values equal to the target, then find the earliest one.
+     * Find the offset of which the value is equal or larger than the given targetValue. If there are many values equal

Review Comment:
   As you are changing the doc, let's make it proper: 
   If there are multiple values equal to the target, return the earliest one.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on pull request #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "lizhanhui (via GitHub)" <gi...@apache.org>.
lizhanhui commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1505089544

   This fix is too complex and less performant.
   How about this way: Before entering the critical region, validate and serialize the messages, with consume queue offset filled with place holders.  In the critical region, allocate offsets as before and replace place-holders with them. 
   This way, critical region is minimized and CPU-intensive serialization can be parallel at the same time.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1177772890


##########
store/src/main/java/org/apache/rocketmq/store/CommitLog.java:
##########
@@ -815,89 +809,72 @@ public CompletableFuture<PutMessageResult> asyncPutMessage(final MessageExtBroke
             }
         }
 
-        topicQueueLock.lock(topicQueueKey);
-        try {
+        PutMessageThreadLocal putMessageThreadLocal = this.putMessageThreadLocal.get();

Review Comment:
   > 
   
   Yes, we serialize outside of the lock, so each thread will have a ByteBuf for storing serialized data.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "caigy (via GitHub)" <gi...@apache.org>.
caigy commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1179060390


##########
common/src/main/java/org/apache/rocketmq/common/message/MessageExtBrokerInner.java:
##########
@@ -27,6 +27,8 @@ public class MessageExtBrokerInner extends MessageExt {
 
     private ByteBuffer encodedBuff;
 
+    private volatile boolean isEncodeCompleted;

Review Comment:
   `encodeCompleted` may be more appropriate.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1519459500

   > @lizhanhui If we don't have enough time to review this PR currently, I suggest submitting another PR that fixes the bug in the original way first. That fix is minimally invasive and follows the current writing process. Then we can further review how to optimize performance in this PR.
   
   Original way to fix the issue #6641,  the main purpose of this PR is to optimize the process of putting messages to improve performance.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "lizhanhui (via GitHub)" <gi...@apache.org>.
lizhanhui commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1522962510

   > @lizhanhui If we don't have enough time to review this PR currently, I suggest submitting another PR that fixes the bug in the original way first. That fix is minimally invasive and follows the current writing process. Then we can further review how to optimize performance in this PR.
   
   I am kind of busy recently and it is OK to create a new pull request for the optimization and dedicate this one to bugfix.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "caigy (via GitHub)" <gi...@apache.org>.
caigy commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1179103350


##########
store/src/main/java/org/apache/rocketmq/store/MultiDispatch.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.store;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExtBrokerInner;
+
+/**
+ * MultiDispatch for lmq, not-thread-safe
+ */
+public class MultiDispatch {
+    private final StringBuilder keyBuilder = new StringBuilder();
+    private final DefaultMessageStore messageStore;
+
+    public MultiDispatch(DefaultMessageStore messageStore) {
+        this.messageStore = messageStore;
+    }
+
+    public String queueKey(String queueName, MessageExtBrokerInner msgInner) {
+        keyBuilder.setLength(0);
+        keyBuilder.append(queueName);
+        keyBuilder.append('-');
+        int queueId = msgInner.getQueueId();
+        if (messageStore.getMessageStoreConfig().isEnableLmq() && MixAll.isLmq(queueName)) {
+            queueId = 0;
+        }
+        keyBuilder.append(queueId);
+        return keyBuilder.toString();
+    }
+
+    public void wrapMultiDispatch(final MessageExtBrokerInner msg) {
+        String multiDispatchQueue = msg.getProperty(MessageConst.PROPERTY_INNER_MULTI_DISPATCH);
+        String[] queues = multiDispatchQueue.split(MixAll.MULTI_DISPATCH_QUEUE_SPLITTER);
+        Long[] queueOffsets = new Long[queues.length];
+        for (int i = 0; i < queues.length; i++) {
+            String key = queueKey(queues[i], msg);
+            if (messageStore.getMessageStoreConfig().isEnableLmq() && MixAll.isLmq(key)) {
+                queueOffsets[i] = messageStore.getQueueStore().getLmqQueueOffset(key);
+            }
+        }
+        MessageAccessor.putProperty(msg, MessageConst.PROPERTY_INNER_MULTI_QUEUE_OFFSET,
+            StringUtils.join(queueOffsets, MixAll.MULTI_DISPATCH_QUEUE_SPLITTER));
+    }
+
+
+    public void updateMultiQueueOffset(final MessageExtBrokerInner msgInner) {
+        String multiDispatchQueue = msgInner.getProperty(MessageConst.PROPERTY_INNER_MULTI_DISPATCH);
+        String[] queues = multiDispatchQueue.split(MixAll.MULTI_DISPATCH_QUEUE_SPLITTER);
+        for (String queue : queues) {
+            String key = queueKey(queue, msgInner);
+            if (messageStore.getMessageStoreConfig().isEnableLmq() && MixAll.isLmq(key)) {
+                messageStore.getQueueStore().increaseLmqOffset(key, (short) 1);

Review Comment:
   Extract `(short) 1` as constant.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on a diff in pull request #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "lizhanhui (via GitHub)" <gi...@apache.org>.
lizhanhui commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1163959454


##########
store/src/main/java/org/apache/rocketmq/store/CommitLog.java:
##########
@@ -892,6 +892,10 @@ public CompletableFuture<PutMessageResult> asyncPutMessage(final MessageExtBroke
             } finally {
                 putMessageLock.unlock();
             }
+            // Increase queue offset when messages are successfully written
+            if (AppendMessageStatus.PUT_OK.equals(result.getStatus())) {

Review Comment:
   Why is it safe to increase the offset without put-message-lock?



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on pull request #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1518467546

   @lizhanhui Plz help review~


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ShadowySpirits commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "ShadowySpirits (via GitHub)" <gi...@apache.org>.
ShadowySpirits commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1177471593


##########
store/src/main/java/org/apache/rocketmq/store/CommitLog.java:
##########
@@ -815,89 +809,72 @@ public CompletableFuture<PutMessageResult> asyncPutMessage(final MessageExtBroke
             }
         }
 
-        topicQueueLock.lock(topicQueueKey);
-        try {
+        PutMessageThreadLocal putMessageThreadLocal = this.putMessageThreadLocal.get();

Review Comment:
   Is there a race issue? I notice you use thread local variable out of the critical region. 



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "caigy (via GitHub)" <gi...@apache.org>.
caigy commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1179099003


##########
store/src/main/java/org/apache/rocketmq/store/MultiDispatch.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.store;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExtBrokerInner;
+
+/**
+ * MultiDispatch for lmq, not-thread-safe
+ */
+public class MultiDispatch {
+    private final StringBuilder keyBuilder = new StringBuilder();
+    private final DefaultMessageStore messageStore;
+
+    public MultiDispatch(DefaultMessageStore messageStore) {
+        this.messageStore = messageStore;
+    }
+
+    public String queueKey(String queueName, MessageExtBrokerInner msgInner) {
+        keyBuilder.setLength(0);

Review Comment:
   If adopting `StringBuilder` for better performance, calling `delete()` to clear it may be better.
   Ref: https://www.baeldung.com/java-clear-stringbuilder-stringbuffer



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "caigy (via GitHub)" <gi...@apache.org>.
caigy commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1180287884


##########
store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java:
##########
@@ -731,10 +729,7 @@ private boolean checkMultiDispatchQueue(DispatchRequest dispatchRequest) {
         }
         String multiDispatchQueue = prop.get(MessageConst.PROPERTY_INNER_MULTI_DISPATCH);
         String multiQueueOffset = prop.get(MessageConst.PROPERTY_INNER_MULTI_QUEUE_OFFSET);
-        if (StringUtils.isBlank(multiDispatchQueue) || StringUtils.isBlank(multiQueueOffset)) {
-            return false;
-        }
-        return true;
+        return !StringUtils.isBlank(multiDispatchQueue) && !StringUtils.isBlank(multiQueueOffset);

Review Comment:
   It's more comprehensive to use `StringUtils.isNotBlank()`.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ISSUE #6570] Optimizing the process of putting messages to improve performance [rocketmq]

Posted by "lzkisok (via GitHub)" <gi...@apache.org>.
lzkisok commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1784759095

   大概什么时候能合并并发布新版本,谢谢


-- 
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: commits-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 #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "fuyou001 (via GitHub)" <gi...@apache.org>.
fuyou001 commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1164893592


##########
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java:
##########
@@ -2039,11 +2039,21 @@ public boolean isSyncMaster() {
     }
 
     @Override
-    public void assignOffset(MessageExtBrokerInner msg, short messageNum) {
+    public void assignOffset(MessageExtBrokerInner msg) {
         final int tranType = MessageSysFlag.getTransactionValue(msg.getSysFlag());
 
         if (tranType == MessageSysFlag.TRANSACTION_NOT_TYPE || tranType == MessageSysFlag.TRANSACTION_COMMIT_TYPE) {

Review Comment:
   refactor it as a method for determining message types maybe 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: commits-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 #6571: [ISSUE #6570] Fix the issue that expectLogicOffset is greater than currentLogicOffset in consumeQueue build when the message is illegal

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#issuecomment-1503037393

   ## [Codecov](https://codecov.io/gh/apache/rocketmq/pull/6571?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 [#6571](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8fa3f39) into [develop](https://codecov.io/gh/apache/rocketmq/commit/7dc9942fe20dfee8841221e55c904f872c994d38?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7dc9942) will **increase** coverage by `0.02%`.
   > The diff coverage is `78.12%`.
   
   ```diff
   @@              Coverage Diff              @@
   ##             develop    #6571      +/-   ##
   =============================================
   + Coverage      43.08%   43.11%   +0.02%     
   - Complexity      8991     8995       +4     
   =============================================
     Files           1107     1107              
     Lines          78257    78292      +35     
     Branches       10201    10209       +8     
   =============================================
   + Hits           33718    33755      +37     
   + Misses         40316    40301      -15     
   - Partials        4223     4236      +13     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...n/java/org/apache/rocketmq/store/MessageStore.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL01lc3NhZ2VTdG9yZS5qYXZh) | `0.00% <ø> (ø)` | |
   | [...ketmq/store/plugin/AbstractPluginMessageStore.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL3BsdWdpbi9BYnN0cmFjdFBsdWdpbk1lc3NhZ2VTdG9yZS5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...main/java/org/apache/rocketmq/store/CommitLog.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL0NvbW1pdExvZy5qYXZh) | `65.07% <66.66%> (-0.17%)` | :arrow_down: |
   | [...apache/rocketmq/store/queue/BatchConsumeQueue.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL3F1ZXVlL0JhdGNoQ29uc3VtZVF1ZXVlLmphdmE=) | `70.37% <75.00%> (+0.16%)` | :arrow_up: |
   | [...n/java/org/apache/rocketmq/store/ConsumeQueue.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL0NvbnN1bWVRdWV1ZS5qYXZh) | `66.29% <76.19%> (+0.06%)` | :arrow_up: |
   | [...org/apache/rocketmq/store/DefaultMessageStore.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL0RlZmF1bHRNZXNzYWdlU3RvcmUuamF2YQ==) | `46.79% <80.00%> (+0.07%)` | :arrow_up: |
   | [...ache/rocketmq/store/queue/QueueOffsetOperator.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL3F1ZXVlL1F1ZXVlT2Zmc2V0T3BlcmF0b3IuamF2YQ==) | `80.48% <91.66%> (ø)` | |
   | [...pache/rocketmq/store/dledger/DLedgerCommitLog.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL2RsZWRnZXIvRExlZGdlckNvbW1pdExvZy5qYXZh) | `76.90% <100.00%> (+0.09%)` | :arrow_up: |
   | [...apache/rocketmq/store/queue/ConsumeQueueStore.java](https://codecov.io/gh/apache/rocketmq/pull/6571?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL3F1ZXVlL0NvbnN1bWVRdWV1ZVN0b3JlLmphdmE=) | `48.75% <100.00%> (+0.55%)` | :arrow_up: |
   
   ... and [13 files with indirect coverage changes](https://codecov.io/gh/apache/rocketmq/pull/6571/indirect-changes?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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "caigy (via GitHub)" <gi...@apache.org>.
caigy commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1179082137


##########
store/src/main/java/org/apache/rocketmq/store/MultiDispatch.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.store;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExtBrokerInner;
+
+/**
+ * MultiDispatch for lmq, not-thread-safe
+ */
+public class MultiDispatch {
+    private final StringBuilder keyBuilder = new StringBuilder();
+    private final DefaultMessageStore messageStore;
+
+    public MultiDispatch(DefaultMessageStore messageStore) {
+        this.messageStore = messageStore;
+    }
+
+    public String queueKey(String queueName, MessageExtBrokerInner msgInner) {
+        keyBuilder.setLength(0);
+        keyBuilder.append(queueName);
+        keyBuilder.append('-');
+        int queueId = msgInner.getQueueId();
+        if (messageStore.getMessageStoreConfig().isEnableLmq() && MixAll.isLmq(queueName)) {
+            queueId = 0;
+        }
+        keyBuilder.append(queueId);
+        return keyBuilder.toString();
+    }
+
+    public void wrapMultiDispatch(final MessageExtBrokerInner msg) {
+        String multiDispatchQueue = msg.getProperty(MessageConst.PROPERTY_INNER_MULTI_DISPATCH);
+        String[] queues = multiDispatchQueue.split(MixAll.MULTI_DISPATCH_QUEUE_SPLITTER);
+        Long[] queueOffsets = new Long[queues.length];

Review Comment:
   It seems unnecessary to use  `Long` instead of the primitive type, as `ConsumeQueueStore.getLmqQueueOffset()` returns `long`.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #6571: [ISSUE #6570] Optimizing the process of putting messages to improve performance

Posted by "caigy (via GitHub)" <gi...@apache.org>.
caigy commented on code in PR #6571:
URL: https://github.com/apache/rocketmq/pull/6571#discussion_r1179075334


##########
store/src/main/java/org/apache/rocketmq/store/MultiDispatch.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.store;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExtBrokerInner;
+
+/**
+ * MultiDispatch for lmq, not-thread-safe
+ */
+public class MultiDispatch {
+    private final StringBuilder keyBuilder = new StringBuilder();
+    private final DefaultMessageStore messageStore;
+
+    public MultiDispatch(DefaultMessageStore messageStore) {
+        this.messageStore = messageStore;
+    }
+
+    public String queueKey(String queueName, MessageExtBrokerInner msgInner) {
+        keyBuilder.setLength(0);
+        keyBuilder.append(queueName);
+        keyBuilder.append('-');
+        int queueId = msgInner.getQueueId();
+        if (messageStore.getMessageStoreConfig().isEnableLmq() && MixAll.isLmq(queueName)) {
+            queueId = 0;
+        }
+        keyBuilder.append(queueId);
+        return keyBuilder.toString();
+    }
+
+    public void wrapMultiDispatch(final MessageExtBrokerInner msg) {
+        String multiDispatchQueue = msg.getProperty(MessageConst.PROPERTY_INNER_MULTI_DISPATCH);
+        String[] queues = multiDispatchQueue.split(MixAll.MULTI_DISPATCH_QUEUE_SPLITTER);
+        Long[] queueOffsets = new Long[queues.length];
+        for (int i = 0; i < queues.length; i++) {
+            String key = queueKey(queues[i], msg);
+            if (messageStore.getMessageStoreConfig().isEnableLmq() && MixAll.isLmq(key)) {

Review Comment:
   `messageStore.getMessageStoreConfig().isEnableLmq()` can be moved outside to loop.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org