Skip to content

Commit

Permalink
Handle SQL duplicate key case (#2410)
Browse files Browse the repository at this point in the history
* Correctly handle retry of history node / tree query
  • Loading branch information
wxing1292 authored Jan 24, 2022
1 parent 3377e64 commit 87dc0ef
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/persistence/sql/history_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ func (m *sqlExecutionStore) AppendHistoryNodes(
if err != nil {
return err
}
if rowsAffected != 1 {
return fmt.Errorf("expected 1 row to be affected for node table, got %v", rowsAffected)
if !(rowsAffected == 1 || rowsAffected == 2) {
return fmt.Errorf("expected 1 or 2 row to be affected for node table, got %v", rowsAffected)
}

result, err = tx.InsertIntoHistoryTree(ctx, treeRow)
Expand Down Expand Up @@ -309,8 +309,8 @@ func (m *sqlExecutionStore) ForkHistoryBranch(
if err != nil {
return err
}
if rowsAffected != 1 {
return fmt.Errorf("expected 1 row to be affected for tree table, got %v", rowsAffected)
if !(rowsAffected == 1 || rowsAffected == 2) {
return fmt.Errorf("expected 1 or 2 row to be affected for tree table, got %v", rowsAffected)
}
return nil
}
Expand Down

0 comments on commit 87dc0ef

Please sign in to comment.