Fix misleading error in batch for live migration#1764
Merged
makalaaneesh merged 7 commits intomainfrom Oct 21, 2024
Merged
Conversation
sanyamsinghal
approved these changes
Oct 21, 2024
| // This ideally needs to be fixed in pgx library. | ||
| errorMsg := "" | ||
| if i == 0 { | ||
| errorMsg = fmt.Sprintf("error preparing statements for events in batch (%s) or when executing event with vsn(%d)", batch.ID(), batch.Events[i].Vsn) |
Contributor
There was a problem hiding this comment.
is printing start and end of the batch enough here? or should we print the VSNs of all events in that batch.
Collaborator
Author
There was a problem hiding this comment.
Yeah, thought of this @sanyamsinghal , but I plan to add debug logs for every statement in a subsequent PR, which I thought would be more valuable than simply listing all the VSNs here.
Let me know if you think I should still add it here as well!
Contributor
There was a problem hiding this comment.
Yeah, i think we can add it here also, since it won't flood the logs, just the last line in case of failures.
We can use debug logs for more level of details(like logging particular events)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using pgx SendBatch, there can be two types of errors thrown:
No matter which statement in the batch has an issue, the error will be thrown on calling br.Exec() for the first time.
Examples - constraint violation, etc.
In this case, we get the error on the appropriate br.Exec() call associated with the statement that failed.
Therefore, if error is thrown on the first br.Exec() call, it could be either of the above cases. Modified the logs to indicate this as part of this PR.
Reference - jackc/pgx#872
This ideally needs to be fixed in pgx library, and has been partially fixed in jackc/pgx#1441 (pgx v5)