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

[R4R]support Index service recovery and indexHeight in Status api #106

Merged
merged 6 commits into from
Aug 13, 2019

Conversation

unclezoro
Copy link
Collaborator

@unclezoro unclezoro commented Jul 29, 2019

Description

  1. Will recover index data from restart or crash
  2. Add field--'indexHeight' to status api.
  3. Add indexHegiht metrics.

Rationale

This pr have pass though following testcases:

  1. Upgrade from old binary, no recover will do. checked
  2. If previous do not use index and now change to use index, no recover will do. checked
  3. If index data lost, will recover. checked
  4. If data have indexed, but did't write the height, redo index have no side effect. checked
  5. Rpc api have changed. checked
  6. Metrics have changed. checked
  7. write to statedb will not cause consensus issue. checked

Example

api of 'Status ' changed:

{
"jsonrpc": "2.0",
"id": "",
"result": {
...
"sync_info": {
  		"latest_block_hash": "F51538DA498299F4C57AC8162AAFA0254CE08286",
  		"latest_app_hash": "0000000000000000",
  		"latest_block_height": "18",
  		"latest_block_time": "2018-09-17T11:42:19.149920551Z",
  		"catching_up": false,
  		"index_height": "18"
  	},
...
}

Changes

Preflight checks

  • build passed (make build)
  • tests passed (make test)

Already reviewed by

...

Related issues

@xzjcool @Kaiqiang all other sdk need change the 'status' api response.

@unclezoro unclezoro changed the base branch from master to develop July 29, 2019 13:39
@unclezoro unclezoro force-pushed the index branch 4 times, most recently from c4ed633 to b291b1b Compare July 30, 2019 03:32
@unclezoro unclezoro changed the title [WIP]Index [R4R]support Index service recovery and indexHeight in Status api Jul 30, 2019
state/index.go Show resolved Hide resolved
state/index.go Show resolved Hide resolved
state/index.go Show resolved Hide resolved
state/index.go Outdated Show resolved Hide resolved
@rickyyangz
Copy link
Contributor

as discussed, please check whether it has any performance impact in high tps

state/index.go Show resolved Hide resolved
node/node.go Show resolved Hide resolved
state/index.go Outdated Show resolved Hide resolved
// if never store `indexHeight` in index db, will return -1.
func (ih *IndexHub) GetIndexedHeight() int64 {
rawHeight := ih.stateDB.Get(indexHeight)
if rawHeight == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

remember to fix the state_recover tool

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure

@unclezoro unclezoro merged commit 5401e0d into develop Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants