@@ -1159,116 +1159,6 @@ func (s *mutableStateSuite) TestActivityTimeoutDeletion_AllTimersDeletedOnComple
11591159 s .True (foundHeartbeat , "Heartbeat should be deleted on completion (if still exists)" )
11601160}
11611161
1162- func (s * mutableStateSuite ) TestActivityTimeoutDeletion_PerAttemptTimersDeletedOnRetry () {
1163- // Test that when activity is retried, per-attempt timeout tasks (ScheduleToStart, StartToClose, Heartbeat)
1164- // are deleted but ScheduleToClose is preserved since it spans all retry attempts.
1165- s .mockEventsCache .EXPECT ().PutEvent (gomock .Any (), gomock .Any ()).AnyTimes ()
1166-
1167- // Schedule and start an activity with retry policy
1168- _ , activityInfo , err := s .mutableState .AddActivityTaskScheduledEvent (
1169- int64 (2 ), // workflowTaskCompletedEventID
1170- & commandpb.ScheduleActivityTaskCommandAttributes {
1171- ActivityId : "activity" ,
1172- ActivityType : & commonpb.ActivityType {Name : "type" },
1173- TaskQueue : & taskqueuepb.TaskQueue {Name : "tq" },
1174- RetryPolicy : & commonpb.RetryPolicy {InitialInterval : durationpb .New (time .Second )},
1175- },
1176- false ,
1177- )
1178- s .NoError (err )
1179-
1180- _ , err = s .mutableState .AddActivityTaskStartedEvent (activityInfo , activityInfo .ScheduledEventId , "" , "" , nil , nil , nil )
1181- s .NoError (err )
1182-
1183- // Create mock timeout tasks for all types
1184- workflowKey := s .mutableState .GetWorkflowKey ()
1185- scheduledEventID := activityInfo .ScheduledEventId
1186-
1187- mockScheduleToCloseTask := & tasks.ActivityTimeoutTask {
1188- WorkflowKey : workflowKey ,
1189- TaskID : 200 ,
1190- TimeoutType : enumspb .TIMEOUT_TYPE_SCHEDULE_TO_CLOSE ,
1191- EventID : scheduledEventID ,
1192- Stamp : activityInfo .Stamp ,
1193- }
1194- mockScheduleToStartTask := & tasks.ActivityTimeoutTask {
1195- WorkflowKey : workflowKey ,
1196- TaskID : 201 ,
1197- TimeoutType : enumspb .TIMEOUT_TYPE_SCHEDULE_TO_START ,
1198- EventID : scheduledEventID ,
1199- Stamp : activityInfo .Stamp ,
1200- }
1201- mockStartToCloseTask := & tasks.ActivityTimeoutTask {
1202- WorkflowKey : workflowKey ,
1203- TaskID : 202 ,
1204- TimeoutType : enumspb .TIMEOUT_TYPE_START_TO_CLOSE ,
1205- EventID : scheduledEventID ,
1206- Stamp : activityInfo .Stamp ,
1207- }
1208- mockHeartbeatTask := & tasks.ActivityTimeoutTask {
1209- WorkflowKey : workflowKey ,
1210- TaskID : 203 ,
1211- TimeoutType : enumspb .TIMEOUT_TYPE_HEARTBEAT ,
1212- EventID : scheduledEventID ,
1213- Stamp : activityInfo .Stamp ,
1214- }
1215-
1216- // Store all tasks
1217- if s .mutableState .activityTimeoutTasks == nil {
1218- s .mutableState .activityTimeoutTasks = make (map [int64 ]* activityTimeoutTasks )
1219- }
1220- s .mutableState .activityTimeoutTasks [scheduledEventID ] = & activityTimeoutTasks {
1221- ScheduleToStartTimeoutTask : mockScheduleToStartTask ,
1222- ScheduleToCloseTimeoutTask : mockScheduleToCloseTask ,
1223- StartToCloseTimeoutTask : mockStartToCloseTask ,
1224- HeartbeatTimeoutTask : mockHeartbeatTask ,
1225- }
1226-
1227- // Retry the activity
1228- retryState , err := s .mutableState .RetryActivity (activityInfo , & failurepb.Failure {})
1229- s .NoError (err )
1230- s .Equal (enumspb .RETRY_STATE_IN_PROGRESS , retryState )
1231-
1232- // Verify that per-attempt timeout tasks are in the deletion list
1233- del := s .mutableState .BestEffortDeleteTasks
1234- s .Contains (del , tasks .CategoryTimer )
1235-
1236- foundScheduleToClose := false
1237- foundStartToClose := false
1238- foundScheduleToStart := false
1239- foundHeartbeat := false
1240- for _ , key := range del [tasks .CategoryTimer ] {
1241- if key == mockScheduleToCloseTask .GetKey () {
1242- foundScheduleToClose = true
1243- }
1244- if key == mockStartToCloseTask .GetKey () {
1245- foundStartToClose = true
1246- }
1247- if key == mockScheduleToStartTask .GetKey () {
1248- foundScheduleToStart = true
1249- }
1250- if key == mockHeartbeatTask .GetKey () {
1251- foundHeartbeat = true
1252- }
1253- }
1254-
1255- // Per-attempt timers should be deleted
1256- s .True (foundStartToClose , "StartToClose should be deleted on retry" )
1257- s .True (foundScheduleToStart , "ScheduleToStart should be deleted on retry" )
1258- s .True (foundHeartbeat , "Heartbeat should be deleted on retry" )
1259-
1260- // ScheduleToClose should NOT be deleted (it spans all retry attempts)
1261- s .False (foundScheduleToClose , "ScheduleToClose should NOT be deleted on retry (spans all attempts)" )
1262-
1263- // Verify the in-memory storage reflects the deletions
1264- timeoutTasks := s .mutableState .activityTimeoutTasks [scheduledEventID ]
1265- s .NotNil (timeoutTasks , "Activity timeout tasks map entry should still exist after retry" )
1266- s .Nil (timeoutTasks .ScheduleToStartTimeoutTask , "ScheduleToStart task reference should be nil" )
1267- s .Nil (timeoutTasks .StartToCloseTimeoutTask , "StartToClose task reference should be nil" )
1268- s .Nil (timeoutTasks .HeartbeatTimeoutTask , "Heartbeat task reference should be nil" )
1269- s .NotNil (timeoutTasks .ScheduleToCloseTimeoutTask , "ScheduleToClose task reference should be preserved" )
1270- }
1271-
12721162func (s * mutableStateSuite ) TestDeleteScheduleToStartTimeout_BothPathsWhenActivityStarts () {
12731163 // Test that ScheduleToStart is deleted for both transient and non-transient activity starts
12741164 s .mockEventsCache .EXPECT ().PutEvent (gomock .Any (), gomock .Any ()).AnyTimes ()
0 commit comments