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

Add binlog_status for http api and TIDB_SERVERS_INFO table #13025

Merged
merged 29 commits into from Nov 6, 2019

Conversation

zier-one
Copy link
Contributor

@zier-one zier-one commented Oct 30, 2019

What problem does this PR solve?

Users can check if all of tidb servers is enable binlog conveniently.

What is changed and how it works?

add a item named binlog_enabled into ServerInfo, and display it on http api and TIDB_SERVERS_INFO.

Manual test

When binlog is not enable

curl http://127.0.0.1:10080/info/all

{
 "servers_num": 2,
 "owner_id": "29a65ec0-d931-4f9e-a212-338eaeffab96",
 "is_all_server_version_consistent": true,
 "all_servers_info": {
  "29a65ec0-d931-4f9e-a212-338eaeffab96": {
   "version": "5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty",
   "git_hash": "8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e",
   "ddl_id": "29a65ec0-d931-4f9e-a212-338eaeffab96",
   "ip": "",
   "listening_port": 4000,
   "status_port": 10080,
   "lease": "45s",
   "binlog_status": "Off"
  },
  "cd13c9eb-c3ee-4887-af9b-e64f3162d92c": {
   "version": "5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty",
   "git_hash": "8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e",
   "ddl_id": "cd13c9eb-c3ee-4887-af9b-e64f3162d92c",
   "ip": "",
   "listening_port": 4001,
   "status_port": 10081,
   "lease": "45s",
   "binlog_status": "Off"
  }
 }
}
mysql> select * from information_schema.TIDB_SERVERS_INFO;
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
| DDL_ID                               | IP   | PORT | STATUS_PORT | LEASE | VERSION                                       | GIT_HASH                                 | BINLOG_STATUS |
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
| 29a65ec0-d931-4f9e-a212-338eaeffab96 |      | 4000 |       10080 | 45s   | 5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty | 8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e | Off           |
| cd13c9eb-c3ee-4887-af9b-e64f3162d92c |      | 4001 |       10081 | 45s   | 5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty | 8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e | Off           |
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
2 rows in set (0.00 sec)

When binlog is enable

curl http://127.0.0.1:10080/info/all
{
 "servers_num": 2,
 "owner_id": "b45f2a44-3794-459d-b969-4453b5cf4820",
 "is_all_server_version_consistent": true,
 "all_servers_info": {
  "419b3208-d6c0-4466-ae38-8895904c1483": {
   "version": "5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty",
   "git_hash": "8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e",
   "ddl_id": "419b3208-d6c0-4466-ae38-8895904c1483",
   "ip": "",
   "listening_port": 4001,
   "status_port": 10081,
   "lease": "45s",
   "binlog_status": "On"
  },
  "b45f2a44-3794-459d-b969-4453b5cf4820": {
   "version": "5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty",
   "git_hash": "8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e",
   "ddl_id": "b45f2a44-3794-459d-b969-4453b5cf4820",
   "ip": "",
   "listening_port": 4000,
   "status_port": 10080,
   "lease": "45s",
   "binlog_status": "On"
  }
 }
}
mysql> select * from information_schema.TIDB_SERVERS_INFO;
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
| DDL_ID                               | IP   | PORT | STATUS_PORT | LEASE | VERSION                                       | GIT_HASH                                 | BINLOG_STATUS |
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
| 419b3208-d6c0-4466-ae38-8895904c1483 |      | 4001 |       10081 | 45s   | 5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty | 8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e | On            |
| b45f2a44-3794-459d-b969-4453b5cf4820 |      | 4000 |       10080 | 45s   | 5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty | 8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e | On            |
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
2 rows in set (0.00 sec)

When binlog is enable and ignore-error is enable, but write binlog failure

curl http://127.0.0.1:10080/info/all

{
 "servers_num": 2,
 "owner_id": "4ebdeaea-70f0-472c-9ca9-8a237aa22b10",
 "is_all_server_version_consistent": true,
 "all_servers_info": {
  "142744c8-69b4-4779-8113-3c69200d6c16": {
   "version": "5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty",
   "git_hash": "8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e",
   "ddl_id": "142744c8-69b4-4779-8113-3c69200d6c16",
   "ip": "",
   "listening_port": 4001,
   "status_port": 10081,
   "lease": "45s",
   "binlog_status": "Skipping"
  },
  "4ebdeaea-70f0-472c-9ca9-8a237aa22b10": {
   "version": "5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty",
   "git_hash": "8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e",
   "ddl_id": "4ebdeaea-70f0-472c-9ca9-8a237aa22b10",
   "ip": "",
   "listening_port": 4000,
   "status_port": 10080,
   "lease": "45s",
   "binlog_status": "Skipping"
  }
 }
}
mysql> select * from information_schema.TIDB_SERVERS_INFO;
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
| DDL_ID                               | IP   | PORT | STATUS_PORT | LEASE | VERSION                                       | GIT_HASH                                 | BINLOG_STATUS |
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
| 4ebdeaea-70f0-472c-9ca9-8a237aa22b10 |      | 4000 |       10080 | 45s   | 5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty | 8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e | Skipping      |
| 142744c8-69b4-4779-8113-3c69200d6c16 |      | 4001 |       10081 | 45s   | 5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty | 8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e | Skipping      |
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
2 rows in set (0.00 sec)

When some of tidb server is old version which isn't support show binlog_status

curl http://127.0.0.1:10080/info/all

{
 "servers_num": 2,
 "owner_id": "e5998f02-bf2b-434f-80b9-48d3f6260fa1",
 "all_servers_diff_versions": [
  {
   "version": "5.7.25-TiDB-v4.0.0-alpha-638-g6fd74f3e4",
   "git_hash": "6fd74f3e4c42a61fa9dff1eaae4fcbad625f347a"
  },
  {
   "version": "5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty",
   "git_hash": "8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e"
  }
 ],
 "all_servers_info": {
  "dd480398-f595-4b35-8e33-773f6f15fae9": {
   "version": "5.7.25-TiDB-v4.0.0-alpha-638-g6fd74f3e4",
   "git_hash": "6fd74f3e4c42a61fa9dff1eaae4fcbad625f347a",
   "ddl_id": "dd480398-f595-4b35-8e33-773f6f15fae9",
   "ip": "",
   "listening_port": 4001,
   "status_port": 10081,
   "lease": "45s",
   "binlog_status": "Unknown"
  },
  "e5998f02-bf2b-434f-80b9-48d3f6260fa1": {
   "version": "5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty",
   "git_hash": "8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e",
   "ddl_id": "e5998f02-bf2b-434f-80b9-48d3f6260fa1",
   "ip": "",
   "listening_port": 4000,
   "status_port": 10080,
   "lease": "45s",
   "binlog_status": "On"
  }
 }
}
mysql> select * from information_schema.TIDB_SERVERS_INFO;
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
| DDL_ID                               | IP   | PORT | STATUS_PORT | LEASE | VERSION                                       | GIT_HASH                                 | BINLOG_STATUS |
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
| dd480398-f595-4b35-8e33-773f6f15fae9 |      | 4001 |       10081 | 45s   | 5.7.25-TiDB-v4.0.0-alpha-638-g6fd74f3e4       | 6fd74f3e4c42a61fa9dff1eaae4fcbad625f347a | Unknown       |
| e5998f02-bf2b-434f-80b9-48d3f6260fa1 |      | 4000 |       10080 | 45s   | 5.7.25-TiDB-v4.0.0-alpha-669-g8f2a09a52-dirty | 8f2a09a52fdcaf9d9bfd775d2c6023f363dc121e | On            |
+--------------------------------------+------+------+-------------+-------+-----------------------------------------------+------------------------------------------+---------------+
2 rows in set (0.00 sec)

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Port uint `json:"listening_port"`
StatusPort uint `json:"status_port"`
Lease string `json:"lease"`
BinlogEnabled bool `json:"binlog_enabled"`
Copy link
Member

Choose a reason for hiding this comment

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

If the tidb-server is disconneted with Pump and the user chooses to ignore the error, will the tidb-server update the binlog_enabled to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed PTAL again

@codecov
Copy link

codecov bot commented Oct 30, 2019

Codecov Report

Merging #13025 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #13025   +/-   ##
===========================================
  Coverage   80.1291%   80.1291%           
===========================================
  Files           469        469           
  Lines        111188     111188           
===========================================
  Hits          89094      89094           
  Misses        15209      15209           
  Partials       6885       6885

@ericsyh
Copy link
Contributor

ericsyh commented Oct 30, 2019

@leoppro Need to update the infoall api response sample in tidb_http_api.md

@tiancaiamao
Copy link
Contributor

/run-all-tests

@tiancaiamao
Copy link
Contributor

/run-all-tests

@zier-one zier-one changed the title Add binlog_enabled status for http api and TIDB_SERVERS_INFO table Add binlog_status for http api and TIDB_SERVERS_INFO table Oct 31, 2019
@zier-one
Copy link
Contributor Author

I will fix ci later

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 6, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

Your auto merge job has been accepted, waiting for 13152

@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

@leoppro merge failed.

@zier-one
Copy link
Contributor Author

zier-one commented Nov 6, 2019

/run-all-tests

@zier-one
Copy link
Contributor Author

zier-one commented Nov 6, 2019

/run-all-tests

@zier-one
Copy link
Contributor Author

zier-one commented Nov 6, 2019

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

Your auto merge job has been accepted, waiting for 13164

@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

/run-all-tests

@sre-bot sre-bot merged commit 903cd1f into pingcap:master Nov 6, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

cherry pick to release-3.0 failed

@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

cherry pick to release-3.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

cherry pick to release-2.1 failed

@zier-one zier-one deleted the check_binlog branch November 6, 2019 05:17
zier-one pushed a commit to zier-one/tidb that referenced this pull request Nov 6, 2019
…#13025)

# Conflicts:
#	domain/info.go
#	infoschema/tables.go
#	sessionctx/binloginfo/binloginfo.go
zier-one pushed a commit to zier-one/tidb that referenced this pull request Nov 6, 2019
…#13025)

# Conflicts:
#	domain/info.go
#	infoschema/tables.go
#	sessionctx/binloginfo/binloginfo.go
zier-one pushed a commit to zier-one/tidb that referenced this pull request Nov 6, 2019
…#13025)

# Conflicts:
#	domain/info.go
#	infoschema/tables.go
#	sessionctx/binloginfo/binloginfo.go

# Conflicts:
#	docs/tidb_http_api.md
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/binlog 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.

None yet

7 participants