You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "qianye1001 (via GitHub)" <gi...@apache.org> on 2026/06/16 12:54:55 UTC

[PR] [ISSUE #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   Fixes #10489
   
   ## Summary
   - Add remoting/client/proxy support for BatchChangeInvisibleTime with a batch header scoped to one topic and consumer group for broker-side auth.
   - Add broker batch handling for PopConsumer KV change invisible time, including buffer-aware cache handling and delete-before-put RocksDB batch semantics.
   - Wire proxy batch call sites for receipt handle renew/cleanup, receive write-back failure nack, and filtered TO_RETURN messages, gated by `enableBatchChangeInvisibleTime`.
   
   ## Tests
   - `mvn -pl common,remoting,client,broker,proxy -DskipTests compile test-compile`
   - `mvn -pl common,remoting,client,broker,proxy -DfailIfNoTests=false -Dtest=BatchChangeInvisibleTimeTest,MQClientAPIImplTest#testBatchChangeInvisibleTimeAsyncSendsRequestHeader+testProcessBatchChangeInvisibleTimeResponse,ChangeInvisibleTimeProcessorTest#testProcessBatchRequestRejectsMismatchedTopicOrGroup+testProcessBatchKvRequestDoesNotBuildSingleHeader+testProcessBatchRequestConvertsBadEntryToPerEntryFailure+testProcessBatchRequestRejectsOversizedBody,PopConsumerCacheTest,PopConsumerRocksdbStoreTest,ConsumerProcessorTest#testBatchChangeInvisibleTimeSplitByRealTopic+testBatchChangeInvisibleTime+testBatchChangeInvisibleTimeSplitOversizedBrokerGroup,ReceiveMessageResponseStreamWriterTest#testWriteBackFailureShouldBatchChangeInvisibleTime,ReceiptHandleProcessorTest#testBatchRenewMessage+testBatchClearGroup test`
   - `mvn -pl common,remoting,client,broker,proxy -DfailIfNoTests=false -Dtest=ReceiveMessageResponseStreamWriterTest,ReceiptHandleProcessorTest test`
   


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   ## [Codecov](https://app.codecov.io/gh/apache/rocketmq/pull/10519?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `62.41218%` with `321 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 48.22%. Comparing base ([`b4d92c0`](https://app.codecov.io/gh/apache/rocketmq/commit/b4d92c06b7a5995d1b6a8211c40e411372fe9a64?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`646d6ba`](https://app.codecov.io/gh/apache/rocketmq/commit/646d6ba6f1be44ad6a8f3934bf69075899324d7b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on develop.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/rocketmq/pull/10519?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...broker/processor/ChangeInvisibleTimeProcessor.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fbroker%2Fprocessor%2FChangeInvisibleTimeProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcHJvY2Vzc29yL0NoYW5nZUludmlzaWJsZVRpbWVQcm9jZXNzb3IuamF2YQ==) | 50.30% | [65 Missing and 16 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...tmq/proxy/service/message/LocalMessageService.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=proxy%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fproxy%2Fservice%2Fmessage%2FLocalMessageService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L3NlcnZpY2UvbWVzc2FnZS9Mb2NhbE1lc3NhZ2VTZXJ2aWNlLmphdmE=) | 0.00% | [60 Missing :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...cketmq/proxy/processor/ReceiptHandleProcessor.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=proxy%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fproxy%2Fprocessor%2FReceiptHandleProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L3Byb2Nlc3Nvci9SZWNlaXB0SGFuZGxlUHJvY2Vzc29yLmphdmE=) | 58.62% | [19 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...he/rocketmq/proxy/processor/ConsumerProcessor.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=proxy%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fproxy%2Fprocessor%2FConsumerProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L3Byb2Nlc3Nvci9Db25zdW1lclByb2Nlc3Nvci5qYXZh) | 80.55% | [16 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [.../apache/rocketmq/test/client/rmq/RMQPopClient.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=test%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Ftest%2Fclient%2Frmq%2FRMQPopClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-dGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvdGVzdC9jbGllbnQvcm1xL1JNUVBvcENsaWVudC5qYXZh) | 0.00% | [20 Missing :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...g/apache/rocketmq/client/impl/MQClientAPIImpl.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fclient%2Fimpl%2FMQClientAPIImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jbGllbnQvaW1wbC9NUUNsaWVudEFQSUltcGwuamF2YQ==) | 64.00% | [12 Missing and 6 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...q/proxy/service/message/ClusterMessageService.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=proxy%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fproxy%2Fservice%2Fmessage%2FClusterMessageService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L3NlcnZpY2UvbWVzc2FnZS9DbHVzdGVyTWVzc2FnZVNlcnZpY2UuamF2YQ==) | 0.00% | [17 Missing :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...g/apache/rocketmq/broker/pop/PopConsumerCache.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fbroker%2Fpop%2FPopConsumerCache.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcG9wL1BvcENvbnN1bWVyQ2FjaGUuamF2YQ==) | 78.37% | [8 Missing and 8 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...apache/rocketmq/broker/pop/PopConsumerService.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fbroker%2Fpop%2FPopConsumerService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcG9wL1BvcENvbnN1bWVyU2VydmljZS5qYXZh) | 74.54% | [7 Missing and 7 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...2/consumer/ReceiveMessageResponseStreamWriter.java](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&filepath=proxy%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Frocketmq%2Fproxy%2Fgrpc%2Fv2%2Fconsumer%2FReceiveMessageResponseStreamWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L2dycGMvdjIvY29uc3VtZXIvUmVjZWl2ZU1lc3NhZ2VSZXNwb25zZVN0cmVhbVdyaXRlci5qYXZh) | 71.73% | [11 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | ... and [9 more](https://app.codecov.io/gh/apache/rocketmq/pull/10519?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##             develop   #10519      +/-   ##
   =============================================
   + Coverage      48.12%   48.22%   +0.09%     
   - Complexity     13352    13512     +160     
   =============================================
     Files           1377     1383       +6     
     Lines         100720   101536     +816     
     Branches       13012    13112     +100     
   =============================================
   + Hits           48476    48967     +491     
   - Misses         46309    46568     +259     
   - Partials        5935     6001      +66     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/rocketmq/pull/10519?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   The remaining 2 CI failures are unrelated flaky tests:
   
   - **bazel-compile**: `OffsetResetIT` — not modified by this PR, known flaky integration test
   - **maven-compile (macos)**: `ServiceThreadTest.serviceThreadShouldNotLoseWakeupUnderStress` — not modified by this PR, timing jitter on macOS runner
   
   Re-running both jobs.


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   comment


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   @fuyou001 Thanks, agreed. Fixed in d1d6e3e8ddbc13224a216fa1473e55225eb27ec1.
   
   The proxy fallback is now restricted to the explicit unsupported case only: the real exception must be an `MQBrokerException` with `ResponseCode.REQUEST_CODE_NOT_SUPPORTED`. For ambiguous failures such as timeout/transport failure/lost response, `processBrokerChangeInvisibleTime` now completes the batch entries with `INTERNAL_SERVER_ERROR` and does not retry single `changeInvisibleTime`, so it will not create a second CK with a new `changedPopTime` after the broker may already have applied the batch.
   
   Added regression coverage in `ConsumerProcessorTest` for both paths:
   - `testBatchChangeInvisibleTimeFallbackOnlyWhenRequestCodeNotSupported`
   - `testBatchChangeInvisibleTimeDoesNotFallbackOnAmbiguousFailure`
   
   Verified locally:
   - `mvn -pl proxy -am -DfailIfNoTests=false -Dtest=ConsumerProcessorTest test`
   - `mvn -pl broker -am -DfailIfNoTests=false -Dtest=ChangeInvisibleTimeProcessorTest test`
   
   Comment addressed: https://github.com/apache/rocketmq/pull/10519#issuecomment-4741426672


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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


##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/BatchChangeInvisibleTimeRequestBody.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.remoting.protocol.body;
+
+import java.util.List;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+public class BatchChangeInvisibleTimeRequestBody extends RemotingSerializable {

Review Comment:
   need to check if the batch size exceeds the length limit of the frequency.



-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   comment


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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


##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RequestCode.java:
##########
@@ -82,6 +82,7 @@ public class RequestCode {
     public static final int BATCH_ACK_MESSAGE = 200151;
     public static final int PEEK_MESSAGE = 200052;
     public static final int CHANGE_MESSAGE_INVISIBLETIME = 200053;
+    public static final int BATCH_CHANGE_MESSAGE_INVISIBLETIME = 200153;

Review Comment:
   suggest change



-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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


##########
broker/src/main/java/org/apache/rocketmq/broker/pop/PopConsumerService.java:
##########
@@ -517,21 +518,67 @@ public void changeInvisibilityDuration(long popTime, long invisibleTime, long ch
         if (skipWrite) {
             log.info("PopConsumerService change invisibility skip, time={}, " +
                 "groupId={}, topicId={}, queueId={}, offset={}", popTime, groupId, topicId, queueId, offset);
-        } else {
-            this.popConsumerStore.writeRecords(Collections.singletonList(ckRecord));
         }
 
+        List<PopConsumerRecord> ckRecords = skipWrite ? Collections.emptyList() : Collections.singletonList(ckRecord);
+        List<PopConsumerRecord> ackRecords = Collections.singletonList(ackRecord);
         if (brokerConfig.isEnablePopBufferMerge() && popConsumerCache != null) {
-            if (popConsumerCache.deleteRecords(Collections.singletonList(ackRecord)).isEmpty()) {
-                return;
+            popConsumerCache.writeAndDeleteRecords(ckRecords, ackRecords);
+        } else {
+            this.popConsumerStore.writeAndDeleteRecords(ckRecords, ackRecords);
+        }
+    }
+
+    public void batchChangeInvisibilityDuration(List<ChangeInvisibleTimeRequestEntry> changeRecords) {

Review Comment:
   changeInvisibilityDuration can call batchChangeInvisibilityDuration



-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   **[P1] Preserve input ordering when returning batch change-invisible-time results**
   
   `batchChangeInvisibleTime` does not preserve the order of `handleMessageList`: expired-handle results are appended first, while the remaining results are appended later in `HashMap` group iteration order. However, `ReceiptHandleProcessor.batchChangeInvisibleTime` consumes the returned list by index and completes the future for `indexes.get(i)` with `results.get(i)`.
   
   When a renewal batch contains handles from different brokers/real topics, or contains an expired handle, a result can therefore be assigned to a different message. This may update message A with message B receipt handle and cause subsequent renew/ack operations to target the wrong offset.
   
   Please preserve the original input order in the returned result list, or correlate each result with its `ReceiptHandleMessage` instead of consuming results positionally. A regression test should cover interleaved broker/topic groups and an expired handle.


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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


##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RequestCode.java:
##########
@@ -82,6 +82,7 @@ public class RequestCode {
     public static final int BATCH_ACK_MESSAGE = 200151;
     public static final int PEEK_MESSAGE = 200052;
     public static final int CHANGE_MESSAGE_INVISIBLETIME = 200053;
+    public static final int BATCH_CHANGE_MESSAGE_INVISIBLETIME = 200153;

Review Comment:
   和 batch ack 一样的逻辑,就用这个吧



-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   **[P1] Do not fall back to single requests after an ambiguous batch failure**
   
   `processBrokerChangeInvisibleTime` falls back to individual `changeInvisibleTime` calls for every exception from `batchChangeInvisibleTime`, including timeouts, connection resets, and lost responses. Those failures do not prove that the broker did not apply the batch. The broker may have already persisted the new CK records and only the response failed to reach the proxy.
   
   Retrying each entry with the original receipt handle is not idempotent: each execution generates a new `changedPopTime`, so the fallback can create a second CK while the CK created by the successful batch remains. Both CKs may later revive the same message, causing duplicate delivery.
   
   Please restrict fallback to an explicit response proving that the broker does not support the batch request code. Transport failures and timeouts should not be retried this way unless the operation is made idempotent, for example with a request identifier deduplicated by the broker. A regression test should cover the case where the broker applies the batch but the client future completes with a timeout.


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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


##########
broker/src/main/java/org/apache/rocketmq/broker/processor/ChangeInvisibleTimeProcessor.java:
##########
@@ -186,6 +206,248 @@ public CompletableFuture<RemotingCommand> processRequestAsync(final Channel chan
         });
     }
 
+    protected CompletableFuture<RemotingCommand> processBatchRequestAsync(final Channel channel,
+        RemotingCommand request, boolean brokerAllowSuspend) {
+        RemotingCommand response = RemotingCommand.createResponseCommand(null);
+        response.setCode(ResponseCode.SUCCESS);
+        response.setOpaque(request.getOpaque());
+
+        BatchChangeInvisibleTimeRequestHeader batchRequestHeader;
+        try {
+            batchRequestHeader = (BatchChangeInvisibleTimeRequestHeader)
+                request.decodeCommandCustomHeader(BatchChangeInvisibleTimeRequestHeader.class);
+        } catch (Throwable t) {
+            response.setCode(ResponseCode.MESSAGE_ILLEGAL);
+            response.setRemark("batch change invisible time request header is invalid");
+            return CompletableFuture.completedFuture(response);
+        }
+
+        BatchChangeInvisibleTimeRequestBody requestBody =
+            BatchChangeInvisibleTimeRequestBody.decode(request.getBody(), BatchChangeInvisibleTimeRequestBody.class);
+        List<ChangeInvisibleTimeRequestEntry> requestEntries = requestBody == null || requestBody.getEntries() == null ?
+            Collections.emptyList() : requestBody.getEntries();
+        int batchMaxNum = Math.max(1, brokerController.getBrokerConfig().getBatchChangeInvisibleTimeMaxNum());
+        if (requestEntries.size() > batchMaxNum) {
+            response.setCode(ResponseCode.MESSAGE_ILLEGAL);
+            response.setRemark(String.format("batch change invisible time entries exceed limit: %d",
+                batchMaxNum));
+            return CompletableFuture.completedFuture(response);
+        }
+
+        ChangeInvisibleTimeResponseEntry[] responseEntries = new ChangeInvisibleTimeResponseEntry[requestEntries.size()];
+        for (int i = 0; i < requestEntries.size(); i++) {
+            responseEntries[i] = buildFailedResponseEntry(ResponseCode.SYSTEM_ERROR);
+        }
+        List<CompletableFuture<Void>> futures = new ArrayList<>();
+
+        if (!validateBatchRequestEntries(batchRequestHeader, requestEntries)) {
+            response.setCode(ResponseCode.MESSAGE_ILLEGAL);
+            response.setRemark("batch change invisible time entries must use the same topic and consumerGroup as request header");
+            return CompletableFuture.completedFuture(response);
+        }
+
+        if (brokerController.getBrokerConfig().isPopConsumerKVServiceEnable()) {
+            List<ChangeInvisibleTimeRequestEntry> kvChangeRecords = new ArrayList<>();
+            List<Integer> kvIndexes = new ArrayList<>();
+            List<ChangeInvisibleTimeResponseEntry> kvSuccessEntries = new ArrayList<>();
+            for (int i = 0; i < requestEntries.size(); i++) {
+                ChangeInvisibleTimeRequestEntry requestEntry = requestEntries.get(i);
+                if (tryAppendBatchKvChange(channel, requestEntry, i, responseEntries, kvChangeRecords,
+                    kvIndexes, kvSuccessEntries)) {
+                    continue;
+                }
+                appendSingleBatchEntry(channel, requestEntry, request.getOpaque(), brokerAllowSuspend,
+                    responseEntries, futures, i);
+            }
+
+            if (!kvChangeRecords.isEmpty()) {
+                try {
+                    brokerController.getPopConsumerService().batchChangeInvisibilityDuration(kvChangeRecords);
+                    for (int i = 0; i < kvIndexes.size(); i++) {
+                        responseEntries[kvIndexes.get(i)] = kvSuccessEntries.get(i);
+                    }
+                } catch (Throwable t) {
+                    POP_LOGGER.error("batch change invisibility duration failed", t);
+                    for (Integer index : kvIndexes) {
+                        responseEntries[index] = buildFailedResponseEntry(ResponseCode.SYSTEM_ERROR);
+                    }
+                }
+            }
+        } else {
+            for (int i = 0; i < requestEntries.size(); i++) {
+                appendSingleBatchEntry(channel, requestEntries.get(i), request.getOpaque(), brokerAllowSuspend,
+                    responseEntries, futures, i);
+            }
+        }
+
+        return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).thenApply(ignored -> {
+            BatchChangeInvisibleTimeResponseBody responseBody = new BatchChangeInvisibleTimeResponseBody();
+            responseBody.setEntries(Arrays.asList(responseEntries));
+            response.setBody(responseBody.encode());
+            return response;
+        });
+    }
+
+    protected boolean validateBatchRequestEntries(BatchChangeInvisibleTimeRequestHeader batchRequestHeader,

Review Comment:
   How about renaming it to normalizeAndValidateBatchRequestEntries to reflect that it mutates the input requestEntries (back-filling consumerGroup / topic from the header)?



-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   @fuyou001 Thanks for the detailed analysis. I considered this one and I do not plan to address it in this batch-change PR.
   
   The reason is that this is not a new correctness model introduced by the batch path. The existing single `changeInvisibilityDuration` path already follows the same pattern: write the new CK, try to remove the old CK from the pop buffer, and then delete the old CK from RocksDB when needed. A concurrent cleanup can theoretically race with that path as well, so fixing this properly would be a broader PopConsumerCache ownership/cleanup change, not a batch-change-specific fix.
   
   Making the ownership transfer atomic would likely require coordinating renewal/change and cleanup with an additional lock or explicit ownership state transition on the hot path. For the batch path that cost is relatively high, especially because the observed impact is a low-probability duplicate delivery scenario and POP consumption already has at-least-once semantics. I would prefer not to add that synchronization cost in this PR.
   
   So for this PR I am keeping the batch behavior aligned with the existing single-change semantics and limiting the changes to reducing broker round trips and store writes/deletes. If we want to harden this race, I think it should be handled separately for both single and batch paths with a dedicated design and benchmark.
   
   Comment addressed: https://github.com/apache/rocketmq/pull/10519#issuecomment-4741428792


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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

   **[P1] Make cache ownership transfer atomic with concurrent cleanup**
   
   `PopConsumerCache.writeAndDeleteRecords` first classifies an old CK with `consumerRecords.contains(record)`, then performs the RocksDB write/delete batch, and only afterward calls `deleteRecords(bufferDeleteRecords)`. This check and removal are not atomic with `cleanupRecords`.
   
   A cleanup thread can move the old CK from `recordTreeMap` to `removeTreeMap`, flush it to RocksDB, and clear it from the cache after `contains` returned true but before the final cache deletion. The renewal path then writes the new CK without including the old CK in `storeDeleteRecords`; its final cache deletion fails, and that failure result is ignored. RocksDB can therefore retain both the old and new CK, potentially reviving the same message more than once. If the keys coincide, a late cleanup write can also overwrite the new value with the old one.
   
   Please coordinate cleanup and renewal through an atomic claim/removal or another explicit ownership state transition before deciding whether the old CK must be deleted from RocksDB. A concurrent regression test should pause between classification and deletion while cleanup stages and flushes the same record.


-- 
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 #10489] Support BatchChangeInvisibleTime to reduce network round-trips and RocksDB flushes [rocketmq]

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


##########
proxy/src/main/java/org/apache/rocketmq/proxy/processor/ConsumerProcessor.java:
##########
@@ -404,6 +434,150 @@ protected CompletableFuture<List<BatchAckResult>> processBrokerHandle(ProxyConte
             });
     }
 
+    public CompletableFuture<List<BatchChangeInvisibleTimeResult>> batchChangeInvisibleTime(
+        ProxyContext ctx,
+        List<ReceiptHandleMessage> handleMessageList,
+        String consumerGroup,
+        String topic,
+        long invisibleTime,
+        long timeoutMillis,
+        boolean suspend
+    ) {
+        CompletableFuture<List<BatchChangeInvisibleTimeResult>> future = new CompletableFuture<>();
+        try {
+            List<BatchChangeInvisibleTimeResult> batchResultList = new ArrayList<>(handleMessageList.size());
+            Map<String, List<ReceiptHandleMessage>> brokerHandleListMap = new HashMap<>();
+
+            for (ReceiptHandleMessage handleMessage : handleMessageList) {
+                if (handleMessage.getReceiptHandle().isExpired()) {
+                    batchResultList.add(new BatchChangeInvisibleTimeResult(handleMessage, EXPIRED_HANDLE_PROXY_EXCEPTION));
+                    continue;
+                }
+                ReceiptHandle handle = handleMessage.getReceiptHandle();
+                String realTopic = handle.getRealTopic(topic, consumerGroup);
+                String batchKey = handle.getBrokerName() + "@" + realTopic;
+                brokerHandleListMap.computeIfAbsent(batchKey, key -> new ArrayList<>())
+                    .add(handleMessage);
+            }
+
+            if (brokerHandleListMap.isEmpty()) {
+                return FutureUtils.addExecutor(CompletableFuture.completedFuture(batchResultList), this.executor);
+            }
+
+            CompletableFuture<List<BatchChangeInvisibleTimeResult>>[] futures = new CompletableFuture[brokerHandleListMap.size()];
+            int futureIndex = 0;
+            for (List<ReceiptHandleMessage> brokerHandleList : brokerHandleListMap.values()) {
+                futures[futureIndex++] = processBrokerChangeInvisibleTime(
+                    ctx, consumerGroup, topic, brokerHandleList, invisibleTime, timeoutMillis, suspend);
+            }
+            CompletableFuture.allOf(futures).whenComplete((val, throwable) -> {
+                if (throwable != null) {
+                    future.completeExceptionally(throwable);
+                    return;
+                }
+                for (CompletableFuture<List<BatchChangeInvisibleTimeResult>> resultFuture : futures) {
+                    batchResultList.addAll(resultFuture.join());

Review Comment:
   This changes the result ordering contract. `batchResultList` is built from expired handles first, then appends each broker/topic group using `HashMap.values()` iteration order. However, `ReceiptHandleProcessor.batchChangeInvisibleTime` consumes the returned list by index and completes `futureList.get(indexes.get(i))` with `results.get(i)`. If one renewal batch contains handles for multiple brokers, the result list can differ from the original `handleMessageList` order, causing a message to receive another message's renewed receipt handle. Please either preserve the original input order when building the result list, or have the caller map results back by `BatchChangeInvisibleTimeResult.getReceiptHandleMessage()` instead of by index.



-- 
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