chenyulin0719 commented on code in PR #840:
URL: https://github.com/apache/yunikorn-core/pull/840#discussion_r1561278402


##########
pkg/scheduler/partition.go:
##########
@@ -591,14 +590,12 @@ func (pc *PartitionContext) updatePartitionResource(delta 
*resources.Resource) {
 // This locks the partition. The partition may not be locked when we process 
the allocation
 // additions to the node as that takes further app, queue or node locks
 func (pc *PartitionContext) addNodeToList(node *objects.Node) error {
-       pc.Lock()
-       defer pc.Unlock()
-       // Node can be added to the system to allow processing of the 
allocations
        if err := pc.nodes.AddNode(node); err != nil {
                return fmt.Errorf("failed to add node %s to partition %s, 
error: %v", node.NodeID, pc.Name, err)
        }
+       pc.Lock()
+       defer pc.Unlock()

Review Comment:
   Wbg we postponed the partition lock to this point. 
   
   The reason is that we don't want any go routine holding partition lock 
before changing  pc.nodes? 



##########
pkg/scheduler/partition.go:
##########
@@ -591,14 +590,12 @@ func (pc *PartitionContext) updatePartitionResource(delta 
*resources.Resource) {
 // This locks the partition. The partition may not be locked when we process 
the allocation
 // additions to the node as that takes further app, queue or node locks
 func (pc *PartitionContext) addNodeToList(node *objects.Node) error {
-       pc.Lock()
-       defer pc.Unlock()
-       // Node can be added to the system to allow processing of the 
allocations
        if err := pc.nodes.AddNode(node); err != nil {
                return fmt.Errorf("failed to add node %s to partition %s, 
error: %v", node.NodeID, pc.Name, err)
        }
+       pc.Lock()
+       defer pc.Unlock()

Review Comment:
   Why we postponed the partition lock to this point. 
   
   The reason is that we don't want any go routine holding partition lock 
before changing  pc.nodes? 



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

Reply via email to