@@ -480,60 +480,68 @@ func mockStorePool(
480
480
decommissionedStoreIDs []roachpb.StoreID ,
481
481
suspectedStoreIDs []roachpb.StoreID ,
482
482
) {
483
- storePool .DetailsMu .Lock ()
484
- defer storePool .DetailsMu .Unlock ()
485
-
486
483
liveNodeSet := map [roachpb.NodeID ]livenesspb.NodeLivenessStatus {}
487
- storePool .DetailsMu .StoreDetails = map [roachpb.StoreID ]* storepool.StoreDetail {}
488
484
for _ , storeID := range aliveStoreIDs {
489
485
liveNodeSet [roachpb .NodeID (storeID )] = livenesspb .NodeLivenessStatus_LIVE
490
- detail := storePool .GetStoreDetailLocked (storeID )
486
+ detail := storePool .GetStoreDetail (storeID )
487
+ detail .Lock ()
491
488
detail .Desc = & roachpb.StoreDescriptor {
492
489
StoreID : storeID ,
493
490
Node : roachpb.NodeDescriptor {NodeID : roachpb .NodeID (storeID )},
494
491
}
492
+ detail .Unlock ()
495
493
}
496
494
for _ , storeID := range unavailableStoreIDs {
497
495
liveNodeSet [roachpb .NodeID (storeID )] = livenesspb .NodeLivenessStatus_UNAVAILABLE
498
- detail := storePool .GetStoreDetailLocked (storeID )
496
+ detail := storePool .GetStoreDetail (storeID )
497
+ detail .Lock ()
499
498
detail .Desc = & roachpb.StoreDescriptor {
500
499
StoreID : storeID ,
501
500
Node : roachpb.NodeDescriptor {NodeID : roachpb .NodeID (storeID )},
502
501
}
502
+ detail .Unlock ()
503
503
}
504
504
for _ , storeID := range deadStoreIDs {
505
505
liveNodeSet [roachpb .NodeID (storeID )] = livenesspb .NodeLivenessStatus_DEAD
506
- detail := storePool .GetStoreDetailLocked (storeID )
506
+ detail := storePool .GetStoreDetail (storeID )
507
+ detail .Lock ()
507
508
detail .Desc = & roachpb.StoreDescriptor {
508
509
StoreID : storeID ,
509
510
Node : roachpb.NodeDescriptor {NodeID : roachpb .NodeID (storeID )},
510
511
}
512
+ detail .Unlock ()
511
513
}
512
514
for _ , storeID := range decommissioningStoreIDs {
513
515
liveNodeSet [roachpb .NodeID (storeID )] = livenesspb .NodeLivenessStatus_DECOMMISSIONING
514
- detail := storePool .GetStoreDetailLocked (storeID )
516
+ detail := storePool .GetStoreDetail (storeID )
517
+ detail .Lock ()
515
518
detail .Desc = & roachpb.StoreDescriptor {
516
519
StoreID : storeID ,
517
520
Node : roachpb.NodeDescriptor {NodeID : roachpb .NodeID (storeID )},
518
521
}
522
+ detail .Unlock ()
519
523
}
520
524
for _ , storeID := range decommissionedStoreIDs {
521
525
liveNodeSet [roachpb .NodeID (storeID )] = livenesspb .NodeLivenessStatus_DECOMMISSIONED
522
- detail := storePool .GetStoreDetailLocked (storeID )
526
+ detail := storePool .GetStoreDetail (storeID )
527
+ detail .Lock ()
523
528
detail .Desc = & roachpb.StoreDescriptor {
524
529
StoreID : storeID ,
525
530
Node : roachpb.NodeDescriptor {NodeID : roachpb .NodeID (storeID )},
526
531
}
532
+ detail .Unlock ()
527
533
}
528
534
529
535
for _ , storeID := range suspectedStoreIDs {
530
536
liveNodeSet [roachpb .NodeID (storeID )] = livenesspb .NodeLivenessStatus_LIVE
531
- detail := storePool .GetStoreDetailLocked (storeID )
537
+ detail := storePool .GetStoreDetail (storeID )
538
+ detail .Lock ()
532
539
detail .LastUnavailable = storePool .Clock ().Now ()
533
540
detail .Desc = & roachpb.StoreDescriptor {
534
541
StoreID : storeID ,
535
542
Node : roachpb.NodeDescriptor {NodeID : roachpb .NodeID (storeID )},
536
543
}
544
+ detail .Unlock ()
537
545
}
538
546
539
547
// Set the node liveness function using the set we constructed.
@@ -1380,16 +1388,20 @@ func TestAllocatorRebalanceDeadNodes(t *testing.T) {
1380
1388
}
1381
1389
1382
1390
// Initialize 8 stores: where store 6 is the target for rebalancing.
1383
- sp .DetailsMu .Lock ()
1384
- sp .GetStoreDetailLocked (1 ).Desc .Capacity = ranges (100 )
1385
- sp .GetStoreDetailLocked (2 ).Desc .Capacity = ranges (100 )
1386
- sp .GetStoreDetailLocked (3 ).Desc .Capacity = ranges (100 )
1387
- sp .GetStoreDetailLocked (4 ).Desc .Capacity = ranges (100 )
1388
- sp .GetStoreDetailLocked (5 ).Desc .Capacity = ranges (100 )
1389
- sp .GetStoreDetailLocked (6 ).Desc .Capacity = ranges (0 )
1390
- sp .GetStoreDetailLocked (7 ).Desc .Capacity = ranges (100 )
1391
- sp .GetStoreDetailLocked (8 ).Desc .Capacity = ranges (100 )
1392
- sp .DetailsMu .Unlock ()
1391
+ updateDescCapacity := func (storeID roachpb.StoreID , capacity roachpb.StoreCapacity ) {
1392
+ sd := sp .GetStoreDetail (storeID )
1393
+ sd .Lock ()
1394
+ sd .Desc .Capacity = capacity
1395
+ sd .Unlock ()
1396
+ }
1397
+ updateDescCapacity (1 , ranges (100 ))
1398
+ updateDescCapacity (2 , ranges (100 ))
1399
+ updateDescCapacity (3 , ranges (100 ))
1400
+ updateDescCapacity (4 , ranges (100 ))
1401
+ updateDescCapacity (5 , ranges (100 ))
1402
+ updateDescCapacity (6 , ranges (0 ))
1403
+ updateDescCapacity (7 , ranges (100 ))
1404
+ updateDescCapacity (8 , ranges (100 ))
1393
1405
1394
1406
// Each test case should describe a repair situation which has a lower
1395
1407
// priority than the previous test case.
0 commit comments