@@ -35,6 +35,7 @@ import (
35
35
commonpb "go.temporal.io/api/common/v1"
36
36
"go.temporal.io/api/enums/v1"
37
37
"go.temporal.io/api/serviceerror"
38
+ "go.uber.org/multierr"
38
39
"golang.org/x/exp/maps"
39
40
40
41
"go.temporal.io/server/api/adminservice/v1"
@@ -1482,8 +1483,7 @@ func (s *ContextImpl) handleReadError(err error) error {
1482
1483
case * persistence.ShardOwnershipLostError :
1483
1484
// Shard is stolen, trigger shutdown of history engine.
1484
1485
// Handling of max read level doesn't matter here.
1485
- s .transition (contextRequestStop {})
1486
- return err
1486
+ return multierr .Combine (err , s .transition (contextRequestStop {}))
1487
1487
1488
1488
default :
1489
1489
return err
@@ -1517,8 +1517,7 @@ func (s *ContextImpl) handleWriteErrorAndUpdateMaxReadLevelLocked(err error, new
1517
1517
case * persistence.ShardOwnershipLostError :
1518
1518
// Shard is stolen, trigger shutdown of history engine.
1519
1519
// Handling of max read level doesn't matter here.
1520
- s .transition (contextRequestStop {})
1521
- return err
1520
+ return multierr .Combine (err , s .transition (contextRequestStop {}))
1522
1521
1523
1522
default :
1524
1523
// We have no idea if the write failed or will eventually make it to persistence. Try to re-acquire
@@ -1527,8 +1526,7 @@ func (s *ContextImpl) handleWriteErrorAndUpdateMaxReadLevelLocked(err error, new
1527
1526
// reliably check the outcome by performing a read. If we fail, we'll shut down the shard.
1528
1527
// Note that reacquiring the shard will cause the max read level to be updated
1529
1528
// to the new range (i.e. past newMaxReadLevel).
1530
- s .transition (contextRequestLost {})
1531
- return err
1529
+ return multierr .Combine (err , s .transition (contextRequestLost {}))
1532
1530
}
1533
1531
}
1534
1532
@@ -1551,18 +1549,24 @@ func (s *ContextImpl) createEngine() Engine {
1551
1549
1552
1550
// start should only be called by the controller.
1553
1551
func (s * ContextImpl ) start () {
1554
- s .transition (contextRequestAcquire {})
1552
+ if err := s .transition (contextRequestAcquire {}); err != nil {
1553
+ s .contextTaggedLogger .Error ("Failed to start shard" , tag .Error (err ))
1554
+ }
1555
1555
}
1556
1556
1557
1557
func (s * ContextImpl ) Unload () {
1558
- s .transition (contextRequestStop {})
1558
+ if err := s .transition (contextRequestStop {}); err != nil {
1559
+ s .contextTaggedLogger .Error ("Failed to unload shard" , tag .Error (err ))
1560
+ }
1559
1561
}
1560
1562
1561
1563
// finishStop should only be called by the controller.
1562
1564
func (s * ContextImpl ) finishStop () {
1563
1565
// After this returns, engineFuture.Set may not be called anymore, so if we don't get see
1564
1566
// an Engine here, we won't ever have one.
1565
- s .transition (contextRequestFinishStop {})
1567
+ if err := s .transition (contextRequestFinishStop {}); err != nil {
1568
+ s .contextTaggedLogger .Error ("Failed to stop shard" , tag .Error (err ))
1569
+ }
1566
1570
1567
1571
// use a context that we know is cancelled so that this doesn't block
1568
1572
engine , _ := s .engineFuture .Get (s .lifecycleCtx )
@@ -2064,7 +2068,9 @@ func (s *ContextImpl) acquireShard() {
2064
2068
2065
2069
// On any error, initiate shutting down the shard. If we already changed state
2066
2070
// because we got a ShardOwnershipLostError, this won't do anything.
2067
- s .transition (contextRequestStop {})
2071
+ if err := s .transition (contextRequestStop {}); err != nil {
2072
+ s .contextTaggedLogger .Error ("Error stopping shard" , tag .Error (err ))
2073
+ }
2068
2074
}
2069
2075
}
2070
2076
0 commit comments