Skip to content

Commit 01ad0d5

Browse files
authored
new map if SubStateMachinesByType is nil (temporalio#7653)
## What changed? create new map if SubStateMachinesByType is nil after applySnapshot. ## Why? SubStateMachinesByType in replication task might be nil (due to proto.Clone of empty map). ## How did you test it? unit test and local test. ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) -->
1 parent 6f48ae8 commit 01ad0d5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

service/history/workflow/mutable_state_impl.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ func NewMutableStateInChain(
575575
}
576576

577577
func (ms *MutableStateImpl) mustInitHSM() {
578+
if ms.executionInfo.SubStateMachinesByType == nil {
579+
ms.executionInfo.SubStateMachinesByType = make(map[string]*persistencespb.StateMachineMap)
580+
}
581+
578582
// Error only occurs if some initialization path forgets to register the workflow state machine.
579583
stateMachineNode, err := hsm.NewRoot(ms.shard.StateMachineRegistry(), StateMachineType, ms, ms.executionInfo.SubStateMachinesByType, ms)
580584
if err != nil {

service/history/workflow/mutable_state_impl_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,8 +4459,10 @@ func (s *mutableStateSuite) TestApplySnapshot() {
44594459
targetMS.closeTransactionTrackLastUpdateVersionedTransition(historyi.TransactionPolicyActive)
44604460

44614461
snapshot := s.buildSnapshot(targetMS)
4462+
s.Nil(snapshot.ExecutionInfo.SubStateMachinesByType)
44624463
err = currentMS.ApplySnapshot(snapshot)
44634464
s.NoError(err)
4465+
s.NotNil(currentMS.GetExecutionInfo().SubStateMachinesByType)
44644466

44654467
s.verifyMutableState(currentMS, targetMS, originMS)
44664468
}

0 commit comments

Comments
 (0)