Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate key error on host batch insertion #2292

Merged
merged 6 commits into from
Feb 4, 2025
Merged

Conversation

badgersrus
Copy link
Contributor

Why this change is needed

Getting a lot of batch duplicate key errors on the UAT validators due to bad error handling

What changes were made as part of this PR

  • return nil if the record exists and check for it in the dbTx.Commit() as well
  • add storage unit test for the logic

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

Copy link
Collaborator

@tudor-malene tudor-malene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small change

}
return fmt.Errorf("could not add batch to host. Cause: %w", err)
}

if err := dbtx.Write(); err != nil {
if errors.Is(err, errutil.ErrAlreadyExists) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has to check over the text. The error here will be returned directly from the db

Copy link
Collaborator

@tudor-malene tudor-malene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@badgersrus badgersrus merged commit d887681 into main Feb 4, 2025
2 checks passed
@badgersrus badgersrus deleted the will/batch-race-fix branch February 4, 2025 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants