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

executor: Use JSON for structured field in ADMIN SHOW DDL #52921

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Apr 26, 2024

What problem does this PR solve?

Issue Number: close #52920

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

The DDL job information in the output of `ADMIN SHOW DDL` is now in JSON.

Test

Before

mysql> admin show ddl\G
*************************** 1. row ***************************
   SCHEMA_VER: 5055
     OWNER_ID: eef31ae6-14a2-4664-85d7-dc842ccd62e4
OWNER_ADDRESS: 192.168.1.229:4000
 RUNNING_JOBS: ID:10106, Type:add index, State:running, SchemaState:write reorganization, SchemaID:2, TableID:10104, RowCount:1447630, ArgLen:0, start time: 2024-04-26 11:20:02.291 +0200 CEST, Err:<nil>, ErrCount:0, SnapshotVersion:449347112749760513, LocalMode: false, UniqueWarnings:0
      SELF_ID: eef31ae6-14a2-4664-85d7-dc842ccd62e4
        QUERY: alter table t1 add index (c1(100))
1 row in set (0.00 sec)

After

mysql> ADMIN SHOW DDL\G
*************************** 1. row ***************************
   SCHEMA_VER: 5067
     OWNER_ID: 943efab7-b7f2-4819-9f9d-951538427aec
OWNER_ADDRESS: 192.168.1.229:4000
 RUNNING_JOBS: [{"id":10108,"type":7,"schema_id":2,"table_id":10104,"schema_name":"test","table_name":"t1","state":1,"warning":null,"err":null,"err_count":0,"row_count":0,"raw_args":[false,{"O":"c1_3","L":"c1_3"},[{"Column":{"Schema":{"O":"","L":""},"Table":{"O":"","L":""},"Name":{"O":"c1","L":"c1"}},"Length":111,"Desc":false,"Expr":null}],null,[],false],"schema_state":3,"snapshot_ver":449347534336819200,"real_start_ts":449347534330527746,"start_ts":449347534329217024,"dependency_id":0,"query":"alter table t1 add index (c1(111))","binlog":{"SchemaVersion":0,"DBInfo":null,"TableInfo":null,"FinishedTS":0,"MultipleTableInfos":null},"version":1,"reorg_meta":{"sql_mode":1436549152,"warnings":{},"warnings_count":{},"location":{"name":"Europe/Amsterdam","offset":0},"reorg_tp":3,"is_fast_reorg":true,"is_dist_reorg":true,"use_cloud_storage":false,"resource_group_name":"default","version":1,"target_scope":""},"multi_schema_info":null,"priority":1,"seq_num":0,"charset":"utf8mb4","collate":"utf8mb4_0900_ai_ci","admin_operator":0,"trace_info":{"connection_id":2097156,"session_alias":""},"bdr_role":"","cdc_write_source":0,"local_mode":false,"sql_mode":1436549152}]
      SELF_ID: 943efab7-b7f2-4819-9f9d-951538427aec
        QUERY: alter table t1 add index (c1(111))
1 row in set (0.00 sec)

mysql> SELECT JSON_PRETTY('[{"id":10108,"type":7,"schema_id":2,"table_id":10104,"schema_name":"test","table_name":"t1","state":1,"warning":null,"err":null,"err_count":0,"row_count":0,"raw_args":[false,{"O":"c1_3","L":"c1_3"},[{"Column":{"Schema":{"O":"","L":""},"Table":{"O":"","L":""},"Name":{"O":"c1","L":"c1"}},"Length":111,"Desc":false,"Expr":null}],null,[],false],"schema_state":3,"snapshot_ver":449347534336819200,"real_start_ts":449347534330527746,"start_ts":449347534329217024,"dependency_id":0,"query":"alter table t1 add index (c1(111))","binlog":{"SchemaVersion":0,"DBInfo":null,"TableInfo":null,"FinishedTS":0,"MultipleTableInfos":null},"version":1,"reorg_meta":{"sql_mode":1436549152,"warnings":{},"warnings_count":{},"location":{"name":"Europe/Amsterdam","offset":0},"reorg_tp":3,"is_fast_reorg":true,"is_dist_reorg":true,"use_cloud_storage":false,"resource_group_name":"default","version":1,"target_scope":""},"multi_schema_info":null,"priority":1,"seq_num":0,"charset":"utf8mb4","collate":"utf8mb4_0900_ai_ci","admin_operator":0,"trace_info":{"connection_id":2097156,"session_alias":""},"bdr_role":"","cdc_write_source":0,"local_mode":false,"sql_mode":1436549152}]')\G
*************************** 1. row ***************************
JSON_PRETTY('[{"id":10108,"type":7,"schema_id":2,"table_id":10104,"schema_name":"test","table_name":"t1","state":1,"warning":null,"err":null,"err_count":0,"row_count":0,"raw_args":[false,{"O":"c1_3","L":"c1_3"},[{"Column":{"Schema":{"O":"","L":""},"Table":: [
  {
    "admin_operator": 0,
    "bdr_role": "",
    "binlog": {
      "DBInfo": null,
      "FinishedTS": 0,
      "MultipleTableInfos": null,
      "SchemaVersion": 0,
      "TableInfo": null
    },
    "cdc_write_source": 0,
    "charset": "utf8mb4",
    "collate": "utf8mb4_0900_ai_ci",
    "dependency_id": 0,
    "err": null,
    "err_count": 0,
    "id": 10108,
    "local_mode": false,
    "multi_schema_info": null,
    "priority": 1,
    "query": "alter table t1 add index (c1(111))",
    "raw_args": [
      false,
      {
        "L": "c1_3",
        "O": "c1_3"
      },
      [
        {
          "Column": {
            "Name": {
              "L": "c1",
              "O": "c1"
            },
            "Schema": {
              "L": "",
              "O": ""
            },
            "Table": {
              "L": "",
              "O": ""
            }
          },
          "Desc": false,
          "Expr": null,
          "Length": 111
        }
      ],
      null,
      [],
      false
    ],
    "real_start_ts": 449347534330527746,
    "reorg_meta": {
      "is_dist_reorg": true,
      "is_fast_reorg": true,
      "location": {
        "name": "Europe/Amsterdam",
        "offset": 0
      },
      "reorg_tp": 3,
      "resource_group_name": "default",
      "sql_mode": 1436549152,
      "target_scope": "",
      "use_cloud_storage": false,
      "version": 1,
      "warnings": {},
      "warnings_count": {}
    },
    "row_count": 0,
    "schema_id": 2,
    "schema_name": "test",
    "schema_state": 3,
    "seq_num": 0,
    "snapshot_ver": 449347534336819200,
    "sql_mode": 1436549152,
    "start_ts": 449347534329217024,
    "state": 1,
    "table_id": 10104,
    "table_name": "t1",
    "trace_info": {
      "connection_id": 2097156,
      "session_alias": ""
    },
    "type": 7,
    "version": 1,
    "warning": null
  }
]
1 row in set (0.00 sec)

[
  {
    "admin_operator": 0,
    "bdr_role": "",
    "binlog": {
      "DBInfo": null,
      "FinishedTS": 0,
      "MultipleTableInfos": null,
      "SchemaVersion": 0,
      "TableInfo": null
    },
    "cdc_write_source": 0,
    "charset": "utf8mb4",
    "collate": "utf8mb4_0900_ai_ci",
    "dependency_id": 0,
    "err": null,
    "err_count": 0,
    "id": 10108,
    "local_mode": false,
    "multi_schema_info": null,
    "priority": 1,
    "query": "alter table t1 add index (c1(111))",
    "raw_args": [
      false,
      {
        "L": "c1_3",
        "O": "c1_3"
      },
      [
        {
          "Column": {
            "Name": {
              "L": "c1",
              "O": "c1"
            },
            "Schema": {
              "L": "",
              "O": ""
            },
            "Table": {
              "L": "",
              "O": ""
            }
          },
          "Desc": false,
          "Expr": null,
          "Length": 111
        }
      ],
      null,
      [],
      false
    ],
    "real_start_ts": 449347534330527746,
    "reorg_meta": {
      "is_dist_reorg": true,
      "is_fast_reorg": true,
      "location": {
        "name": "Europe/Amsterdam",
        "offset": 0
      },
      "reorg_tp": 3,
      "resource_group_name": "default",
      "sql_mode": 1436549152,
      "target_scope": "",
      "use_cloud_storage": false,
      "version": 1,
      "warnings": {},
      "warnings_count": {}
    },
    "row_count": 0,
    "schema_id": 2,
    "schema_name": "test",
    "schema_state": 3,
    "seq_num": 0,
    "snapshot_ver": 449347534336819200,
    "sql_mode": 1436549152,
    "start_ts": 449347534329217024,
    "state": 1,
    "table_id": 10104,
    "table_name": "t1",
    "trace_info": {
      "connection_id": 2097156,
      "session_alias": ""
    },
    "type": 7,
    "version": 1,
    "warning": null
  }
]

Copy link

ti-chi-bot bot commented Apr 26, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from dveeden, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 26, 2024
@dveeden dveeden requested a review from cfzjywxk April 26, 2024 09:57
Copy link

tiprow bot commented Apr 26, 2024

Hi @dveeden. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dveeden
Copy link
Contributor Author

dveeden commented Apr 26, 2024

Some questions:

  • Do we want to filter out any fields like raw_args and query? The query is already in another column. Currently (*Job).String() has a list of columns to include.
  • Should we change the column definition to a JSON column instead of a VARCHAR? If we keep the VARCHAR, what about the length?
  • Should multiple queries get separated by a ;?

Copy link

codecov bot commented Apr 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 52.6912%. Comparing base (10971ea) to head (1f79b59).
Report is 1 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #52921         +/-   ##
=================================================
- Coverage   74.3919%   52.6912%   -21.7008%     
=================================================
  Files          1482       1588        +106     
  Lines        355545     591218     +235673     
=================================================
+ Hits         264497     311520      +47023     
- Misses        71785     256763     +184978     
- Partials      19263      22935       +3672     
Flag Coverage Δ
integration 36.6220% <0.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.2971% <ø> (ø)
parser ∅ <ø> (∅)
br 45.9075% <ø> (+3.1598%) ⬆️

Copy link

ti-chi-bot bot commented Apr 26, 2024

@dveeden: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/check_dev_2 1f79b59 link true /test check-dev2
idc-jenkins-ci-tidb/unit-test 1f79b59 link true /test unit-test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

query += "\n"
}
}

ddlJobs, err := json.Marshal(e.ddlInfo.Jobs)
Copy link
Member

Choose a reason for hiding this comment

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

It would print many unnecessary fields.

@wjhuang2016
Copy link
Member

Some questions:

  • Do we want to filter out any fields like raw_args and query? The query is already in another column. Currently (*Job).String() has a list of columns to include.
  • Should we change the column definition to a JSON column instead of a VARCHAR? If we keep the VARCHAR, what about the length?
  • Should multiple queries get separated by a ;?
  1. Some fields are not necessary and should be skipped.
  2. Varchar is enough, the length can be 65536.
  3. I think it's ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ADMIN SHOW DDL has structured data in Go format
2 participants