You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by "haohao0103 (via GitHub)" <gi...@apache.org> on 2024/08/14 02:50:01 UTC

[I] [Bug] PD PartitionCache lockGraph method opposite to the expected behavior. [incubator-hugegraph]

haohao0103 opened a new issue, #2639:
URL: https://github.com/apache/incubator-hugegraph/issues/2639

   ### Bug Type (问题类型)
   
   logic (逻辑设计问题)
   
   ### Before submit
   
   - [X] 我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与 [FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (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_


-- 
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: dev-unsubscribe@hugegraph.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] PD PartitionCache lockGraph method opposite to the expected behavior. [incubator-hugegraph]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #2639:
URL: https://github.com/apache/incubator-hugegraph/issues/2639#issuecomment-2287759825

   <!-- Answer -->
   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:
   
   ```java
   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 <sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-pd/hg-pd-common/src/main/java/org/apache/hugegraph/pd/common/PartitionCache.java)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [I] [Bug] PD PartitionCache lockGraph method opposite to the expected behavior. [incubator-hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin closed issue #2639: [Bug] PD PartitionCache lockGraph method opposite to the expected behavior.
URL: https://github.com/apache/incubator-hugegraph/issues/2639


-- 
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: dev-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org