imbajin commented on code in PR #3309:
URL: https://github.com/apache/hugegraph/pull/3309#discussion_r4250773459


##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/UnitTestSuite.java:
##########
@@ -244,12 +251,19 @@
         RocksDBSessionTest.class,
         RocksDBCountersTest.class,
         RocksDBTableQueryByIdsTest.class,
+        RocksDBStdSessionsLifecycleTest.class,
+        RocksDBIteratorPoolTest.class,
+
+        /* memory */
+        MemoryAllocateTest.class,

Review Comment:
   Verified in the current source: MemoryAllocateTest is excluded from the 
default unit suite, and the PR description explicitly identifies it as an 
unregistered allocation stress test. The ordinary suite retains 
MemoryManageTest and ConsumersTest.



##########
hugegraph-store/hg-store-test/src/main/java/org/apache/hugegraph/store/rocksdb/SessionOperatorTest.java:
##########
@@ -0,0 +1,268 @@
+/*
+ * 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.hugegraph.store.rocksdb;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.hugegraph.rocksdb.access.DBStoreException;
+import org.apache.hugegraph.rocksdb.access.RocksDBSession;
+import org.apache.hugegraph.rocksdb.access.RocksDBSession.BackendColumn;
+import org.apache.hugegraph.rocksdb.access.ScanIterator;
+import org.apache.hugegraph.rocksdb.access.SessionOperator;
+import org.apache.hugegraph.rocksdb.access.SessionOperatorImpl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+public class SessionOperatorTest extends BaseRocksDbTest {
+
+    private static final String TABLE = "tbl";
+    private static final String GRAPH = "op-graph";
+
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+
+    private ExecutorService prober;
+    private String dataPath;
+    private RocksDBSession session;
+    private int probes;
+
+    private static byte[] b(String s) {
+        return s.getBytes(StandardCharsets.UTF_8);
+    }
+
+    private static List<String> keys(ScanIterator it) {
+        List<String> keys = new ArrayList<>();
+        try {
+            while (it.hasNext()) {
+                BackendColumn col = it.next();
+                keys.add(new String(col.name, StandardCharsets.UTF_8));
+            }
+        } finally {
+            it.close();
+        }
+        return keys;
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        this.prober = Executors.newSingleThreadExecutor(r -> {
+            Thread t = new Thread(r, "cf-lock-prober");
+            t.setDaemon(true);
+            return t;
+        });
+        this.dataPath = this.folder.newFolder("data").getAbsolutePath();
+        this.session = new RocksDBSession(hConfig, this.dataPath, GRAPH, 0);
+        this.session.checkTable(TABLE);
+    }
+
+    @After
+    public void tearDown() {
+        if (this.session != null) {
+            this.session.close();
+        }
+        this.prober.shutdownNow();

Review Comment:
   Verified in the current source: teardown releases the read-lock holds owned 
by the test thread before closing the session, and the class has a 60-second 
timeout. This addresses the lock-upgrade hang described here.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to