Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] PD PartitionCache lockGraph method opposite to the expected behavior. #2639

Closed
1 task done
haohao0103 opened this issue Aug 14, 2024 · 1 comment · Fixed by #2640
Closed
1 task done

[Bug] PD PartitionCache lockGraph method opposite to the expected behavior. #2639

haohao0103 opened this issue Aug 14, 2024 · 1 comment · Fixed by #2640
Labels
bug Something isn't working

Comments

@haohao0103
Copy link
Contributor

Bug Type (问题类型)

logic (逻辑设计问题)

Before submit

  • 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Environment (环境信息)

  • Server Version: 1.5.0 (Apache Release Version)
  • Backend: HStore

Expected & Actual behavior (期望与实际表现)

PartitionCache->lockGraph()

while (lock.compareAndSet(false, true)) {
            Thread.onSpinWait();
        }

the while condition (lock. compareAndSet (false, true)) will enter the loop when compactAndSet succeeds, which is opposite to the expected behavior.

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

@haohao0103 haohao0103 added the bug Something isn't working label Aug 14, 2024
Copy link

dosubot bot commented Aug 14, 2024

To fix the logic design issue in the lockGraph method of the PartitionCache class, you need to change the condition in the while loop. The compareAndSet method returns true if it successfully sets the value, meaning the lock was acquired, so the loop should exit. The correct condition should be !lock.compareAndSet(false, true).

Here is the corrected lockGraph method:

public void lockGraph(String graphName) {
    var lock = getOrCreateGraphLock(graphName);
    while (!lock.compareAndSet(false, true)) {
        Thread.onSpinWait();
    }
}

This change ensures that the loop will continue spinning only if the compareAndSet method fails to acquire the lock [1].

To continue talking to Dosu, mention @dosu.

haohao0103 added a commit to haohao0103/incubator-hugegraph that referenced this issue Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant