-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Improve WaitForPos errors, don't include Result struct in message #15962
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
ee2b51d
to
c3d4c57
Compare
Signed-off-by: Rafer Hazen <[email protected]>
c3d4c57
to
6053c5e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15962 +/- ##
==========================================
+ Coverage 68.47% 68.61% +0.13%
==========================================
Files 1562 1562
Lines 197062 198642 +1580
==========================================
+ Hits 134933 136289 +1356
- Misses 62129 62353 +224 ☔ View full report in Codecov by Sentry. |
@@ -426,7 +426,8 @@ func TestWaitForPosError(t *testing.T) { | |||
|
|||
dbClient.ExpectRequest("select pos, state, message from _vt.vreplication where id=1", &sqltypes.Result{Rows: [][]sqltypes.Value{{}}}, nil) | |||
err = vre.WaitForPos(context.Background(), 1, "MariaDB/0-1-1084") | |||
want = "unexpected result: &{[] 0 0 [[]] 0 }" | |||
want = fmt.Sprintf("unexpected result: %v", &sqltypes.Result{Rows: [][]sqltypes.Value{{}}}) |
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.
@rafer I think we should actually fix the error message generated here. I don't think it's very clear what this is in the first place. The error message does not seem very user friendly if it contains &{[] 0 0 [[]] 0 }
. I don't think that's meaningful in any way for a Vitess user?
Something along these lines maybe, so instead of:
case len(qr.Rows) > 1 || len(qr.Rows[0]) != 3:
return fmt.Errorf("unexpected result: %v", qr)
We do something like:
case len(qr.Rows) > 1:
return fmt.Errorf("more rows received than expected, got %v instead of 1", len(qr.Rows))
case len(qr.Rows[0]) != 3:
return fmt.Errorf("more columns received than expected, got %v instead of 3", len(qr.Rows[0]))
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.
Alternatively, just printing qr.Rows
instead of the whole qr
already makes it look a lot better as well, since rows have a proper .String()
implementation for debugging.
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.
Update 👍
Signed-off-by: Rafer Hazen <[email protected]>
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.
Thanks, @rafer ! ❤️
return fmt.Errorf("vreplication stream received more rows than expected, got %v instead of 1", len(qr.Rows)) | ||
case len(qr.Rows[0]) != 3: | ||
return fmt.Errorf("vreplication stream received an unexpected number of columns, got %v instead of 3", len(qr.Rows[0])) |
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.
Super nitty, but we could use %d instead of %v here.
Signed-off-by: Rafer Hazen <[email protected]>
Description
Add more specific errors when
WaitForPos
receives an unexpected number of rows or columns. No longer prints the raw Result object (which isn't a particularly descriptive error for end users).Immediate motivation is to make tests less brittle when
Result
object is modified (in downstream forks).Related Issue(s)
N/A
Checklist
Deployment Notes