imbajin commented on code in PR #2911:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2911#discussion_r2531930430


##########
hugegraph-server/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseStore.java:
##########
@@ -402,6 +402,8 @@ public void truncate() {
                     "Failed to truncate table for '%s' store", e, this.store);
         }
 
+        this.init();

Review Comment:
   ‼️ **Critical: Potential race condition and incomplete fix**
   
   The `init()` call after `truncate()` may not fully solve the meta table 
issue. Consider:
   
   1. **Race condition**: If another operation accesses the store between 
truncate and init, it could fail
   2. **Incomplete initialization**: `init()` might not restore all meta table 
entries that were cleared by truncate
   3. **Missing transaction boundary**: This operation should be atomic
   
   **Suggestion**: Instead of clearing the meta table and re-initializing, the 
truncate operation should selectively clear only data tables, not meta tables. 
Check how other backends (RocksDB, MySQL) handle this.



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/hbase/HbaseUnitTest.java:
##########
@@ -0,0 +1,58 @@
+/*
+ *
+ *  * 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.unit.hbase;
+
+import org.apache.hugegraph.testutil.Assert;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class HbaseUnitTest extends BaseHbaseUnitTest {
+
+    private static final String GRAPH_NAME = "test_graph";
+
+    @Before
+    public void setUp(){
+        this.provider.open(GRAPH_NAME);
+        this.provider.init();
+    }
+
+    @After
+    public void teardown(){
+        if (this.store != null) {
+            this.store.close();
+        }
+        if (this.provider != null) {
+            this.provider.close();
+        }
+    }
+
+    @Test

Review Comment:
   ⚠️ **Test coverage insufficient**
   
   The test only verifies version equality but doesn't validate:
   
   1. **Meta table content**: Check that specific meta entries (like backend 
version, graph name, etc.) are preserved
   2. **Data table clearing**: Verify that actual graph data (vertices, edges) 
are properly cleared
   3. **Concurrent operations**: Test behavior when truncate is called during 
other operations
   
   **Suggestion**:
   ```java
   @Test
   public void testHbaseMetaVersion(){
       // Insert some test data
       // ... add vertices/edges ...
       
       String beforeVersion = this.store.storedVersion();
       // Get other meta entries
       
       this.store.truncate();
       
       String afterVersion = this.store.storedVersion();
       Assert.assertEquals(beforeVersion, afterVersion);
       
       // Verify data is cleared but meta is intact
       // ... check vertices/edges are gone ...
       // ... check other meta entries preserved ...
   }
   ```



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