-
Notifications
You must be signed in to change notification settings - Fork 725
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
server/api/admin: change the tso parameter of ResetTS to string #1896
Conversation
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
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.
LGTM. except CI.
Codecov Report
@@ Coverage Diff @@
## master #1896 +/- ##
==========================================
+ Coverage 77.79% 77.83% +0.04%
==========================================
Files 163 163
Lines 16333 16337 +4
==========================================
+ Hits 12706 12716 +10
+ Misses 2617 2614 -3
+ Partials 1010 1007 -3
Continue to review full report at Codecov.
|
/merge |
/run-all-tests |
@5kbpers merge failed. |
/run-integration-common-test |
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
17721c1
to
641fe42
Compare
@@ -59,13 +59,18 @@ func (h *adminHandler) ResetTS(w http.ResponseWriter, r *http.Request) { | |||
if err := apiutil.ReadJSONRespondError(h.rd, w, r.Body, &input); err != nil { | |||
return | |||
} | |||
ts, ok := input["tso"].(float64) | |||
if !ok || ts < 0 { | |||
tsValue, ok := input["tso"].(string) |
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.
Why not use uint64
as the type?
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.
There is no such thing in js spec. 😕
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.
Considering this: https://play.golang.org/p/8-COmwYna7T
I think it is supported in go.
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.
I think it also works by defining var input map[string]uint64
.
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.
@5kbpers cc
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.
I'm afraid of it does not work in other languages, eg, rust, as it's not specified in json spec.
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.
@overvenus The language does not matter much, maybe the encoding library does. However, there should be no precision loss when encoding a number because that JSON is based on text not binary.
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.
If you encode a large number into JSON, it is just a sequence of digitals. IMO there is no reason for an encoding library to lose precision.
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
PTAL @shafreeck @overvenus |
/run-all-tests |
cherry pick to release-3.1 in PR #1909 |
… (#1909) Signed-off-by: 5kbpers <tangminghua@pingcap.com>
Signed-off-by: 5kbpers tangminghua@pingcap.com
What problem does this PR solve?
the JSON lib can only marshall number to
float64
type, which may lose precision when converting the tso parameter fromuint64
tofloat64
.What is changed and how it works?
This PR changes the tso parameter of ResetTS to string to avoid precision losing.
Check List
Tests
Code changes