This is an automated email from the ASF dual-hosted git repository.

jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new c961edd2fd  [ISSUE  #8945] Remove unnecessary operations from the 
critical section
c961edd2fd is described below

commit c961edd2fd3f5c2c4907c1ed6be953be2d8a2b4f
Author: hqbfz <125714719+3424672...@users.noreply.github.com>
AuthorDate: Mon Nov 18 16:46:34 2024 +0800

     [ISSUE  #8945] Remove unnecessary operations from the critical section
    
    Co-authored-by: wanghuaiyuan <wanghuaiy...@xiaomi.com>
---
 .../java/org/apache/rocketmq/store/dledger/DLedgerCommitLog.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git 
a/store/src/main/java/org/apache/rocketmq/store/dledger/DLedgerCommitLog.java 
b/store/src/main/java/org/apache/rocketmq/store/dledger/DLedgerCommitLog.java
index e617343f9a..5f4ef08374 100644
--- 
a/store/src/main/java/org/apache/rocketmq/store/dledger/DLedgerCommitLog.java
+++ 
b/store/src/main/java/org/apache/rocketmq/store/dledger/DLedgerCommitLog.java
@@ -568,15 +568,16 @@ public class DLedgerCommitLog extends CommitLog {
         AppendFuture<AppendEntryResponse> dledgerFuture;
         EncodeResult encodeResult;
 
+        encodeResult = this.messageSerializer.serialize(msg);
+        if (encodeResult.status != AppendMessageStatus.PUT_OK) {
+            return CompletableFuture.completedFuture(new 
PutMessageResult(PutMessageStatus.MESSAGE_ILLEGAL, new 
AppendMessageResult(encodeResult.status)));
+        }
+
         String topicQueueKey = msg.getTopic() + "-" + msg.getQueueId();
         topicQueueLock.lock(topicQueueKey);
         try {
             defaultMessageStore.assignOffset(msg);
 
-            encodeResult = this.messageSerializer.serialize(msg);
-            if (encodeResult.status != AppendMessageStatus.PUT_OK) {
-                return CompletableFuture.completedFuture(new 
PutMessageResult(PutMessageStatus.MESSAGE_ILLEGAL, new 
AppendMessageResult(encodeResult.status)));
-            }
             putMessageLock.lock(); //spin or ReentrantLock ,depending on store 
config
             long elapsedTimeInLock;
             long queueOffset;

Reply via email to