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: Gracefully Handle Add Participants Unique Constraint Error in Postgres #495

Merged
merged 4 commits into from
Nov 22, 2024

Conversation

VarKrishin
Copy link
Contributor

Relates to:

Risks

Low

Background

Table: participants
Error: :
Error adding participant error: duplicate key value violates unique constraint "participants_userId_roomId_key"

What does this PR do?

  1. Added a pre-exist check
  2. Added a error=='23505' check in catch block - incase of race conditions (func1 creates it before func2 in millisecond difference)

Error Code: 23505 => duplicate key value violates unique constraint

What kind of change is this?

Bug fix

Documentation changes needed?

No

Testing

Created an agent with different name and tested build - error handled gracefully

Where should a reviewer start?

packages/adapter-postgres/src/index.ts

Detailed testing steps

@VarKrishin VarKrishin changed the title Graceful handling of Add Participants Unique Constraint in Postgres (Error) Fix: Graceful handling of Add Participants Unique Constraint in Postgres (Error) Nov 22, 2024
@ponderingdemocritus
Copy link
Contributor

nice - fix the lock then lets merge

@VarKrishin
Copy link
Contributor Author

@ponderingdemocritus - updated with the latest pnpm lock in main branch

@VarKrishin VarKrishin changed the title Fix: Graceful handling of Add Participants Unique Constraint in Postgres (Error) Fix: Gracefully Handle Add Participants Unique Constraint Error in Postgres Nov 22, 2024
@VarKrishin VarKrishin changed the title Fix: Gracefully Handle Add Participants Unique Constraint Error in Postgres fix: Gracefully Handle Add Participants Unique Constraint Error in Postgres Nov 22, 2024
@ponderingdemocritus ponderingdemocritus merged commit 68a4dcd into elizaOS:main Nov 22, 2024
2 checks passed
@0xVitae
Copy link

0xVitae commented Nov 23, 2024

i am getting this error in npm package for 0.1.4-alpha.3

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.

3 participants