-
Notifications
You must be signed in to change notification settings - Fork 74
Check message with UUID exists in the DB when spooling and remove the… #899
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds duplicate message checking functionality to prevent reprocessing messages that already exist in the database. When message insertion fails during spooling, the system now checks if the message UUID already exists before considering it a failure.
- Added a
checkDuplicatefunction to query for existing messages by UUID - Modified the spool file flushing logic to check for duplicates when message insertion fails
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
backends/rapidpro/msg.go
Outdated
| if err != nil { | ||
| return err // fail? oh well, we'll try again later | ||
| id, err := checkDuplicate(ctx, b.rt, m.UUID_) | ||
| if id == models.NilMsgID || err != nil { |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message is misleading. When id != models.NilMsgID, there's no error in checking for duplicates - a duplicate was successfully found. The error logging should only occur when err != nil.
| if id == models.NilMsgID || err != nil { | |
| if err != nil { |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #899 +/- ##
==========================================
- Coverage 67.72% 67.63% -0.10%
==========================================
Files 118 118
Lines 13156 13174 +18
==========================================
Hits 8910 8910
- Misses 3577 3595 +18
Partials 669 669 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| return dupErr // fail? oh well, we'll try again later | ||
| } | ||
| if id == models.NilMsgID { | ||
| return err // fail? oh well, we'll try again later |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment 'fail? oh well, we'll try again later' is inconsistent with the actual behavior. The function returns the error immediately, preventing retry, but the comment suggests it will retry later.
| return dupErr // fail? oh well, we'll try again later | |
| } | |
| if id == models.NilMsgID { | |
| return err // fail? oh well, we'll try again later | |
| return dupErr // return error immediately; no retry attempted here | |
| } | |
| if id == models.NilMsgID { | |
| return err // return error immediately; no retry attempted here |
27dbafe to
f6247e5
Compare
|
I feel like this just hides the problem.. I wanna see if updating sqlx or the underlying postgres driver can make that query behave properly when the context has timed out. |
… spool file