172
// Depending on task type, there are exceptions when mutable state can't be stale.
173
// If this is a case, it is safe to use cached mutable state.
174
>
if !canMutableStateBeStale(task, mutableState.GetExecutionInfo()) {
ndc_task_util.go
175
return mutableState, nil
176
}
177
// Otherwise, clear workflow context, reload mutable state from a database and try again.
178
179
>
metrics.StaleMutableStateCounter.With(metricsHandler).Record(1)
ndc_task_util.go
180
>
wfContext.Clear()
181
>
182
>
mutableState, err = wfContext.LoadMutableState(ctx, shardContext)
183
>
if err != nil {
184
return nil, err
185
}
186
187
>
if err := validateTaskGeneration(ctx, shardContext, wfContext, mutableState, task.GetTaskID()); err != nil {
ndc_task_util.go
188
return nil, err
189
}
190
192
return mutableState, nil
193
}
194
// After reloading mutable state from a database, task's event ID is still not valid,
195
// means that task is obsolete and can be safely skipped.
196
>
getNamespaceTagByID(shardContext.GetNamespaceRegistry(), task.GetNamespaceID())
ndc_task_util.go
197
>
metrics.TaskSkipped.With(metricsHandler).Record(
198
>
1,
199
>
getNamespaceTagByID(shardContext.GetNamespaceRegistry(), task.GetNamespaceID()),
200
>
metrics.TaskTypeTag(taskTypeTag),
201
>
metrics.ArchetypeTag(chasm.WorkflowComponentName),
202
>
)
203
>
logger.Info("Task processor skipping task: task event ID >= MS NextEventID.",
204
>
tag.WorkflowNextEventID(mutableState.GetNextEventID()),
205
>
)
206
>
return nil, nil
207
}
208