imbajin commented on code in PR #3164:
URL: https://github.com/apache/hugegraph/pull/3164#discussion_r3903582547
##########
hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/snapshot/SnapshotHandler.java:
##########
@@ -96,7 +96,9 @@ public void onSnapshotSave(final SnapshotWriter writer)
throws HgStoreException
Integer groupId = partitionEngine.getGroupId();
AtomicInteger state = businessHandler.getState(groupId);
if (state != null && state.get() == BusinessHandler.doing) {
- return;
+ throw new HgStoreException(
Review Comment:
⚠️ Blocking: yes. This guard is a non-atomic check followed by the save at
line 105. `dbCompaction` runs asynchronously, initializes `compactionState` at
`BusinessHandlerImpl.java:1414`, then sets `doing` at `1418` before
`compactRange()` at `1420`; it does not synchronize with this check. If
compaction starts after `getState()` returns (including while the state entry
is still null), this path still calls `saveSnapshot` during compaction, so the
change does not guarantee that overlapping snapshots are rejected. Please
coordinate the state transition and snapshot save with the same per-partition
lock or another atomic protocol, or re-check the state under such a lock
immediately before saving. Evidence: exact head `SnapshotHandler.java:97-105`
and `BusinessHandlerImpl.java:1408-1421`.
--
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]