Skip to content

Commit

Permalink
utils: fix value out of range for getting server_id (pingcap#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
csuzhangxc authored and lichunzhu committed Apr 7, 2020
1 parent fd19e12 commit a38e8ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/utils/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func GetServerID(db *sql.DB) (uint32, error) {
return 0, err
}

serverID, err := strconv.ParseInt(serverIDStr, 10, 32)
serverID, err := strconv.ParseUint(serverIDStr, 10, 32)
return uint32(serverID), terror.ErrInvalidServerID.Delegate(err, serverIDStr)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/utils/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func (t *testUtilsSuite) TestGetAllServerID(c *C) {
}, {
2,
[]uint32{},
}, {
4294967295, // max server-id.
[]uint32{},
},
}

Expand Down

0 comments on commit a38e8ff

Please sign in to comment.