vaijosh commented on code in PR #3164:
URL: https://github.com/apache/hugegraph/pull/3164#discussion_r3995820616


##########
hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/business/BusinessHandlerImpl.java:
##########
@@ -1415,10 +1422,27 @@ public boolean dbCompaction(String graphName, int id, 
String tableName) {
                         log.info("Partition {} dbCompaction started", id);
                         if (tableName.isEmpty()) {
                             lock(path);
-                            setState(id, doing);
-                            log.info("Partition {}-{} got lock, dbCompaction 
start", id, path);
-                            op.compactRange();
-                            setState(id, compactionDone);
+                            ReentrantLock rangeLock =
+                                    compactionRangeLock.computeIfAbsent(id,
+                                                                        k -> 
new ReentrantLock());
+                            if (!rangeLock.tryLock()) {

Review Comment:
   Thanks @bitflicker64. I have implemented the suggested changed.
   I kept compactionRangeLockWaitMillis = 10_000. I don't think config to 
adjust compactionRangeLockWaitMillis is necessary.
   
    saveSnapshot() should be very fast, so the lock is normally held for well 
under a second, and at most a few seconds even under slow or heavily loaded 
disk conditions. A 10-second timeout provides a generous margin over the 
expected lock-hold time while still preventing the lock from being held 
indefinitely.
   



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