@@ -216,35 +216,25 @@ func CompleteSession(ctx Context) {
216216 return
217217 }
218218
219- retryPolicy := & RetryPolicy {
220- InitialInterval : time .Second ,
221- BackoffCoefficient : 1.1 ,
222- MaximumInterval : time .Second * 10 ,
223- MaximumAttempts : 5 ,
224- }
225- ao := ActivityOptions {
226- ScheduleToStartTimeout : time .Second * 10 ,
227- StartToCloseTimeout : time .Second * 10 ,
228- RetryPolicy : retryPolicy ,
229- }
230-
231219 // first cancel both the creation activity and all user activities
232220 // this will cancel the ctx passed into this function
233221 sessionInfo .sessionCancelFunc ()
234222
235223 // then execute then completion activity using the completionCtx, which is not cancelled.
236- completionCtx := WithActivityOptions (sessionInfo .completionCtx , ao )
237- Go (completionCtx , func (completionCtx Context ) {
238- // even though the creation activity has been cancelled, the session worker doesn't know. The worker will wait until
239- // next heartbeat to figure out that the workflow is completed and then release the resource. We need to make sure the
240- // completion activity is executed before the workflow exits.
241- // run the activity in another coroutine so it won't block user workflow.
242- // the tasklist will be overrided to use the one stored in sessionInfo.
243- err := ExecuteActivity (completionCtx , sessionCompletionActivityName , sessionInfo .SessionID ).Get (completionCtx , nil )
244- if err != nil {
245- GetLogger (completionCtx ).Error ("Complete session activity failed" , zap .Error (err ))
246- }
224+ completionCtx := WithActivityOptions (sessionInfo .completionCtx , ActivityOptions {
225+ ScheduleToStartTimeout : time .Second * 3 ,
226+ StartToCloseTimeout : time .Second * 3 ,
247227 })
228+
229+ // even though the creation activity has been cancelled, the session worker doesn't know. The worker will wait until
230+ // next heartbeat to figure out that the workflow is completed and then release the resource. We need to make sure the
231+ // completion activity is executed before the workflow exits.
232+ // the tasklist will be overrided to use the one stored in sessionInfo.
233+ err := ExecuteActivity (completionCtx , sessionCompletionActivityName , sessionInfo .SessionID ).Get (completionCtx , nil )
234+ if err != nil {
235+ GetLogger (completionCtx ).Warn ("Complete session activity failed" , zap .Error (err ))
236+ }
237+
248238 sessionInfo .sessionState = sessionStateClosed
249239 getWorkflowEnvironment (ctx ).RemoveSession (sessionInfo .SessionID )
250240 GetLogger (ctx ).Debug ("Completed session" , zap .String ("sessionID" , sessionInfo .SessionID ))
0 commit comments