Remove mutable state from cache when cleanup of mutable state, history events and visibility record are done
@@ -594,15 +594,15 @@ func (t *timerQueueProcessorBase) processDeleteHistoryEvent(task *persistence.Ti
switch clusterArchivalStatus {
case cluster.ArchivalDisabled:
t.metricsClient.IncCounter(metrics.HistoryProcessDeleteHistoryEventScope, metrics.WorkflowCleanupDeleteCount)
- return t.deleteWorkflow(task, msBuilder)
+ return t.deleteWorkflow(task, msBuilder, context)
case cluster.ArchivalPaused:
// TODO: @dandrew once archival backfill is in place cluster:paused && domain:enabled should be a nop rather than a delete
t.metricsClient.IncCounter(metrics.HistoryProcessDeleteHistoryEventScope, metrics.WorkflowCleanupDeleteCount)
- return t.deleteWorkflow(task, msBuilder)
+ return t.deleteWorkflow(task, msBuilder, context)
case cluster.ArchivalEnabled:
if domainArchivalStatus == workflow.ArchivalStatusDisabled {
t.metricsClient.IncCounter(metrics.HistoryProcessDeleteHistoryEventScope, metrics.WorkflowCleanupDeleteCount)
- return t.deleteWorkflow(task, msBuilder)
+ return t.deleteWorkflow(task, msBuilder, context)
}
t.metricsClient.IncCounter(metrics.HistoryProcessDeleteHistoryEventScope, metrics.WorkflowCleanupArchiveCount)
return t.archiveWorkflow(task, msBuilder, context)
@@ -610,7 +610,7 @@ func (t *timerQueueProcessorBase) processDeleteHistoryEvent(task *persistence.Ti
return nil
}
-func (t *timerQueueProcessorBase) deleteWorkflow(task *persistence.TimerTaskInfo, msBuilder mutableState) error {
+func (t *timerQueueProcessorBase) deleteWorkflow(task *persistence.TimerTaskInfo, msBuilder mutableState, context workflowExecutionContext) error {
err := t.deleteWorkflowExecution(task)
if err != nil {
return err
@@ -621,7 +621,14 @@ func (t *timerQueueProcessorBase) deleteWorkflow(task *persistence.TimerTaskInfo
return err
}
- return t.deleteWorkflowVisibility(task)
+ err = t.deleteWorkflowVisibility(task)
+ if err != nil {
+ return err
+ }
+ // calling clear here to force accesses of mutable state to read database
+ // if this is not called then callers will get mutable state even though its been removed from database
+ context.clear()
+ return nil
}
func (t *timerQueueProcessorBase) archiveWorkflow(task *persistence.TimerTaskInfo, msBuilder mutableState, context workflowExecutionContext) error {
