File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1497,6 +1497,7 @@ var (
14971497 WorkflowRunTimeoutOverrideCount = NewCounterDef ("workflow_run_timeout_overrides" )
14981498 ReplicationTaskCleanupCount = NewCounterDef ("replication_task_cleanup_count" )
14991499 ReplicationTaskCleanupFailure = NewCounterDef ("replication_task_cleanup_failed" )
1500+ MutableStateDirty = NewCounterDef ("mutable_state_dirty" )
15001501 MutableStateChecksumMismatch = NewCounterDef ("mutable_state_checksum_mismatch" )
15011502 MutableStateChecksumInvalidated = NewCounterDef ("mutable_state_checksum_invalidated" )
15021503 ClusterMetadataLockLatency = NewTimerDef ("cluster_metadata_lock_latency" )
Original file line number Diff line number Diff line change @@ -154,6 +154,13 @@ func NewImmutableHistoryBuilder(
154154 }
155155}
156156
157+ func (b * HistoryBuilder ) IsDirty () bool {
158+ return len (b .memEventsBatches ) > 0 ||
159+ len (b .memLatestBatch ) > 0 ||
160+ len (b .memBufferBatch ) > 0 ||
161+ len (b .scheduledIDToStartedID ) > 0
162+ }
163+
157164// NOTE:
158165// originalRunID is the runID when the WorkflowExecutionStarted event is written
159166// firstRunID is the very first runID along the chain of ContinueAsNew and Reset
Original file line number Diff line number Diff line change @@ -4378,6 +4378,17 @@ func (ms *MutableStateImpl) UpdateWorkflowStateStatus(
43784378func (ms * MutableStateImpl ) StartTransaction (
43794379 namespaceEntry * namespace.Namespace ,
43804380) (bool , error ) {
4381+ if ms .hBuilder .IsDirty () || len (ms .InsertTasks ) > 0 {
4382+ ms .logger .Error ("MutableState encountered dirty transaction" ,
4383+ tag .WorkflowNamespaceID (ms .executionInfo .NamespaceId ),
4384+ tag .WorkflowID (ms .executionInfo .WorkflowId ),
4385+ tag .WorkflowRunID (ms .executionState .RunId ),
4386+ tag .Value (ms .hBuilder ),
4387+ )
4388+ ms .metricsHandler .Counter (metrics .MutableStateChecksumInvalidated .GetMetricName ()).Record (1 )
4389+ return false , serviceerror .NewUnavailable ("MutableState encountered dirty transaction" )
4390+ }
4391+
43814392 namespaceEntry , err := ms .startTransactionHandleNamespaceMigration (namespaceEntry )
43824393 if err != nil {
43834394 return false , err
You can’t perform that action at this time.
0 commit comments