{"record":{"id":"8ace5168afb417fb","repo":"temporalio/temporal","slug":"recordworkflowexecutionclosed-unexpected-numrows","errorCode":null,"errorMessage":"RecordWorkflowExecutionClosed unexpected numRows (%v) updated","messagePattern":"RecordWorkflowExecutionClosed unexpected numRows \\((.+?)\\) updated","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/persistence/visibility/store/sql/visibility_store.go","lineNumber":151,"sourceCode":"\t\treturn err\n\t}\n\n\trow.CloseTime = &request.CloseTime\n\trow.HistoryLength = &request.HistoryLength\n\trow.HistorySizeBytes = &request.HistorySizeBytes\n\trow.ExecutionDuration = new(request.ExecutionDuration.Nanoseconds())\n\trow.StateTransitionCount = &request.StateTransitionCount\n\n\tresult, err := s.sqlStore.DB.ReplaceIntoVisibility(ctx, row)\n\tif err != nil {\n\t\treturn err\n\t}\n\tnoRowsAffected, err := result.RowsAffected()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"RecordWorkflowExecutionClosed rowsAffected error: %v\", err)\n\t}\n\tif noRowsAffected > 2 { // either adds a new row or deletes old row and adds new row\n\t\treturn fmt.Errorf(\n\t\t\t\"RecordWorkflowExecutionClosed unexpected numRows (%v) updated\",\n\t\t\tnoRowsAffected,\n\t\t)\n\t}\n\treturn nil\n}\n\nfunc (s *VisibilityStore) UpsertWorkflowExecution(\n\tctx context.Context,\n\trequest *store.InternalUpsertWorkflowExecutionRequest,\n) error {\n\trow, err := s.generateVisibilityRow(request.InternalVisibilityRequestBase)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresult, err := s.sqlStore.DB.ReplaceIntoVisibility(ctx, row)\n\tif err != nil {","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/persistence/visibility/store/sql/visibility_store.go#L133-L169","documentation":"Error \"RecordWorkflowExecutionClosed unexpected numRows (%v) updated\" thrown in temporalio/temporal.","triggerScenarios":"Thrown at common/persistence/visibility/store/sql/visibility_store.go:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}