{"record":{"id":"d9c230ea5bd67308","repo":"temporalio/temporal","slug":"upsertworkflowexecution-unexpected-numrows-v-up","errorCode":null,"errorMessage":"UpsertWorkflowExecution unexpected numRows (%v) updates","messagePattern":"UpsertWorkflowExecution unexpected numRows \\((.+?)\\) updates","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/persistence/visibility/store/sql/visibility_store.go","lineNumber":177,"sourceCode":"func (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 {\n\t\treturn err\n\t}\n\tnoRowsAffected, err := result.RowsAffected()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif noRowsAffected > 2 { // either adds a new or deletes old row and adds new row\n\t\treturn fmt.Errorf(\"UpsertWorkflowExecution unexpected numRows (%v) updates\", noRowsAffected)\n\t}\n\treturn nil\n}\n\nfunc (s *VisibilityStore) DeleteWorkflowExecution(\n\tctx context.Context,\n\trequest *manager.VisibilityDeleteWorkflowExecutionRequest,\n) error {\n\t_, err := s.sqlStore.DB.DeleteFromVisibility(ctx, sqlplugin.VisibilityDeleteFilter{\n\t\tNamespaceID: request.NamespaceID.String(),\n\t\tRunID:       request.RunID,\n\t})\n\tif err != nil {\n\t\treturn convertSQLError(\"DeleteWorkflowExecution operation failed.\", err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/persistence/visibility/store/sql/visibility_store.go#L159-L195","documentation":"Error \"UpsertWorkflowExecution unexpected numRows (%v) updates\" thrown in temporalio/temporal.","triggerScenarios":"Thrown at common/persistence/visibility/store/sql/visibility_store.go:177 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"}