fuyou001 commented on code in PR #8915:
URL: https://github.com/apache/rocketmq/pull/8915#discussion_r1841648217


##########
common/src/main/java/org/apache/rocketmq/common/config/AbstractRocksDBStorage.java:
##########
@@ -121,14 +121,16 @@ protected void initWriteOptions() {
         this.writeOptions = new WriteOptions();
         this.writeOptions.setSync(false);
         this.writeOptions.setDisableWAL(true);
-        this.writeOptions.setNoSlowdown(true);
+        // https://github.com/facebook/rocksdb/wiki/Write-Stalls
+        this.writeOptions.setNoSlowdown(false);
     }
 
     protected void initAbleWalWriteOptions() {
         this.ableWalWriteOptions = new WriteOptions();
         this.ableWalWriteOptions.setSync(false);
         this.ableWalWriteOptions.setDisableWAL(false);
-        this.ableWalWriteOptions.setNoSlowdown(true);
+        // https://github.com/facebook/rocksdb/wiki/Write-Stalls
+        this.ableWalWriteOptions.setNoSlowdown(false);

Review Comment:
   No fast failure, may be block



##########
store/src/main/java/org/apache/rocketmq/store/queue/RocksGroupCommitService.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.queue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import org.apache.rocketmq.common.ServiceThread;
+import org.apache.rocketmq.store.DispatchRequest;
+import org.rocksdb.RocksDBException;
+
+public class RocksGroupCommitService extends ServiceThread {
+
+    private static final int MAX_BUFFER_SIZE = 100_000;
+
+    private static final int PREFERRED_DISPATCH_REQUEST_COUNT = 256;
+
+    private final LinkedBlockingQueue<DispatchRequest> buffer;
+
+    private final RocksDBConsumeQueueStore store;
+
+    private final List<DispatchRequest> requests = new 
ArrayList<>(PREFERRED_DISPATCH_REQUEST_COUNT);
+
+    public RocksGroupCommitService(RocksDBConsumeQueueStore store) {
+        this.store = store;
+        this.buffer = new LinkedBlockingQueue<>(MAX_BUFFER_SIZE);
+    }
+
+    @Override
+    public String getServiceName() {
+        return "RocksGroupCommit";
+    }
+
+    @Override
+    public void run() {
+        log.info("{} service started", this.getServiceName());
+        while (!this.isStopped()) {
+            try {
+                this.waitForRunning(10);
+                this.doCommit();
+            } catch (Exception e) {
+                log.warn("{} service has exception. ", this.getServiceName(), 
e);
+            }
+        }
+        log.info("{} service end", this.getServiceName());
+    }
+
+    public void putRequest(final DispatchRequest request) throws 
InterruptedException {
+        while (!buffer.offer(request, 3, TimeUnit.SECONDS)) {
+            log.warn("RocksGroupCommitService#buffer is full, 3s elapsed 
before space becomes available");
+        }
+        this.wakeup();
+    }
+
+    private void doCommit() {
+        boolean interrupted = false;

Review Comment:
   interrupted param no used



##########
broker/src/main/java/org/apache/rocketmq/broker/config/v2/ConfigStorage.java:
##########
@@ -105,6 +141,15 @@ public byte[] get(ByteBuffer key) throws RocksDBException {
 
     public void write(WriteBatch writeBatch) throws RocksDBException {
         db.write(ableWalWriteOptions, writeBatch);
+        accountWriteOpsForWalFlush();
+    }
+
+    private void accountWriteOpsForWalFlush() throws RocksDBException {
+        int writeCount = writeOpsCounter.incrementAndGet();
+        if (writeCount >= messageStoreConfig.getRocksdbFlushWalFrequency()) {
+            this.db.flushWal(false);

Review Comment:
   may be flushWal(true) 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-unsubscr...@rocketmq.apache.org

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

Reply via email to