Skip to content
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: Add table range api to http status server #20456

Merged
merged 4 commits into from
Oct 21, 2020
Merged

server: Add table range api to http status server #20456

merged 4 commits into from
Oct 21, 2020

Conversation

sunxiaoguang
Copy link
Contributor

@sunxiaoguang sunxiaoguang commented Oct 14, 2020

Signed-off-by: Xiaoguang Sun sunxiaoguang@zhihu.com

What problem does this PR solve?

Add table range api to http status server so users can easily query misc ranges information of a particular table.

What is changed and how it works?

Add /tables/{db}/{table}/ranges to http status server and return ranges information row and all indices of the table.

What's Changed:
Add /tables/{db}/{table}/ranges to http status server.

How it Works:
Compute row ranges based on table's id, indices ranges from table's metadata.

Related changes

Add routing information to server/http_status.go
Add handler to server/http_handler.go

Tests

  • Unit test
    server/http_handler_test.go
    TestRangesAPI
    TestListTableRanges

Side effects
None

Release note

  • No release note

Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
@sre-bot
Copy link
Contributor

sre-bot commented Oct 14, 2020

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@sre-bot
Copy link
Contributor

sre-bot commented Oct 14, 2020

@sunxiaoguang
Copy link
Contributor Author

/rebuild

@sre-bot
Copy link
Contributor

sre-bot commented Oct 14, 2020

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@sre-bot
Copy link
Contributor

sre-bot commented Oct 14, 2020

@sunxiaoguang sunxiaoguang changed the title Add table range api to http status server server: Add table range api to http status server Oct 14, 2020
@sunxiaoguang
Copy link
Contributor Author

/rebuild

Copy link
Contributor

@Yisaer Yisaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM.

err = decoder.Decode(&data)
c.Assert(err, IsNil)
c.Assert(data.TableName, Equals, "t")
c.Assert(len(data.Indices), Equals, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the indices name should also be asserted here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert added

@@ -320,6 +337,30 @@ func (ts *HTTPHandlerTestSuite) TestListTableRegions(c *C) {
c.Assert(err, IsNil)
}

func (ts *HTTPHandlerTestSuite) TestListTableRanges(c *C) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can merge this test into TestRangesAPI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's copied from TestListTableRegions which turns out to be a test for not existing table and a partitioned table which indeed is different test.

Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
server/http_handler.go Outdated Show resolved Hide resolved
return
}

writeData(w, createTableRanges(meta.ID, meta.Name.String(), meta.Indices))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same API will return different data structure responses for the partitioned tables. Can we use []*TableRanges{createTableRanges(meta.ID, meta.Name.String(), meta.Indices)} to make the API users use it friendly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is the way that table regions api does, I wouldn't mind make this api consistent as long as we don't care these two similar APIs handle partition tables in different way.

image

@lonng
Copy link
Contributor

lonng commented Oct 21, 2020

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 21, 2020
Copy link
Contributor

@Yisaer Yisaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 21, 2020
ti-srebot
ti-srebot previously approved these changes Oct 21, 2020
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
@lonng
Copy link
Contributor

lonng commented Oct 21, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 21, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 04d38f5 into pingcap:master Oct 21, 2020
@sunxiaoguang sunxiaoguang deleted the table_ranges branch October 21, 2020 06:03
ti-srebot pushed a commit that referenced this pull request Nov 12, 2020
Signed-off-by: Xiaoguang Sun <sunxiaoguang@zhihu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants