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

duplicated views with the same name been created #58769

Open
tiancaiamao opened this issue Jan 7, 2025 · 1 comment · May be fixed by #58770
Open

duplicated views with the same name been created #58769

tiancaiamao opened this issue Jan 7, 2025 · 1 comment · May be fixed by #58770
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. report/customer Customers have encountered this bug. severity/moderate type/bug The issue is confirmed as a bug.

Comments

@tiancaiamao
Copy link
Contributor

tiancaiamao commented Jan 7, 2025

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

This is found in one of our customer's environment.

files contain sensitive information removed

They found that the result of select INFORMATION_SCHEMA.TABLES and select the specific table mismatch.
Then they drop that view, but later found a view can not be dropped (select by table id can see that view, but select drop always fail)

After investigate their ddi history, the root cause is that we don't prevent create views twice with same name

...
    },
      "offset": 1,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 3,
      "name": {
       "O": "dct_cd",
       "L": "dct_cd"
      },
      "offset": 2,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 4,
      "name": {
       "O": "dct_nm",
       "L": "dct_nm"
      },
      "offset": 3,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 5,
      "name": {
       "O": "doc_fct",
       "L": "doc_fct"
      },
      "offset": 4,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 6,
      "name": {
       "O": "id_crd_no",
       "L": "id_crd_no"
      },
      "offset": 5,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 7,
      "name": {
       "O": "slf_tel_no",
       "L": "slf_tel_no"
      },
      "offset": 6,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 8,
      "name": {
       "O": "is_enable",
       "L": "is_enable"
      },
      "offset": 7,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 9,
      "name": {
       "O": "sgn_dct",
       "L": "sgn_dct"
      },
      "offset": 8,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 10,
      "name": {
       "O": "crt_tm",
       "L": "crt_tm"
      },
      "offset": 9,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 11,
      "name": {
       "O": "mdcr_act",
       "L": "mdcr_act"
      },
      "offset": 10,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 12,
      "name": {
       "O": "ascrn_dses_rgt",
       "L": "ascrn_dses_rgt"
      },
      "offset": 11,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 13,
      "name": {
       "O": "upt_tm",
       "L": "upt_tm"
      },
      "offset": 12,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 14,
      "name": {
       "O": "invld_flg",
       "L": "invld_flg"
      },
      "offset": 13,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     }
    ],
    "index_info": null,
    "constraint_info": null,
    "fk_info": null,
    "state": 5,
    "pk_is_handle": false,
    "is_common_handle": false,
    "common_handle_version": 0,
    "comment": "",
    "auto_inc_id": 0,
    "auto_id_cache": 0,
    "auto_rand_id": 0,
    "max_col_id": 14,
    "max_idx_id": 0,
    "max_fk_id": 0,
    "max_cst_id": 0,
    "update_timestamp": 454345962731077663,
    "ShardRowIDBits": 0,
    "max_shard_row_id_bits": 0,
    "auto_random_bits": 0,
    "auto_random_range_bits": 0,
    "pre_split_regions": 0,
    "partition": null,
    "compression": "",
    "view": {
     "view_algorithm": 0,
     "view_definer": {
      "Username": "root",
      "Hostname": "100.127.232.6",
      "CurrentUser": false,
      "AuthUsername": "root",
      "AuthHostname": "%",
      "AuthPlugin": "mysql_native_password"
     },
     "view_security": 0,
     "view_select": "SELECT `a`.`MDC_ORG_CD` AS `org_id`,`a`.`MDC_ORG_NM` AS `org_nm`,`a`.`DCT_CD` AS `dct_cd`,`a`.`DCT_NM` AS `dct_nm`,NULL AS `doc_fct`,`a`.`DCT_ID_CRD_NO` AS `id_crd_no`,`a`.`DCT_TEL_NO` AS `slf_tel_no`,`a`.`STRT_USE_STTS` AS `is_enable`,1 AS `sgn_dct`,`a`.`CRT_TM` AS `crt_tm`,NULL AS `mdcr_act`,NULL AS `ascrn_dses_rgt`,`a`.`UPD_DT` AS `upt_tm`,0 AS `invld_flg` FROM `cdr_5721`.`PBLC_FML_DCT_BSC_INFMT` AS `a` WHERE LENGTH(`a`.`DCT_CD`) IN (7,8,9) AND LENGTH(`a`.`DCT_ID_CRD_NO`)=_UTF8MB4'18' AND `a`.`DCT_ID_CRD_NO` NOT LIKE _UTF8MB4'0000%' AND `a`.`DCT_ID_CRD_NO` NOT LIKE _UTF8MB4'%0000' AND SUBSTR(`a`.`DCT_ID_CRD_NO`, 7, 8) REGEXP _UTF8MB4'(((19|20)([0-9]{2}))(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229)'",
     "view_checkoption": 1,
     "view_cols": null
    },
    "sequence": null,
    "Lock": null,
    "version": 5,
    "tiflash_replica": null,
    "is_columnar": false,
    "temp_table_type": 0,
    "cache_table_status": 0,
    "policy_ref_info": null,
    "stats_options": null,
    "exchange_partition_info": null,
    "ttl_info": null,
    "revision": 0
   },
   "FinishedTS": 454345962835673108,
   "MultipleTableInfos": null
  },
  "version": 1,
  "reorg_meta": null,
  "multi_schema_info": null,
  "priority": 0,
  "seq_num": 10299,
  "charset": "",
  "collate": "",
  "admin_operator": 0,
  "trace_info": {
   "connection_id": 954654668,
   "session_alias": ""
  }
 },
 {
  "id": 17020,
  "type": 21,
  "schema_id": 921,
  "table_id": 17019,
  "schema_name": "prot_resident",
  "table_name": "ads_dct",
  "state": 6,
  "warning": null,
  "err": null,
  "err_count": 0,
  "row_count": 0,
  "raw_args": null,
  "schema_state": 5,
  "snapshot_ver": 0,
  "real_start_ts": 454345957449400350,
  "start_ts": 454345957331173396,
  "dependency_id": 0,
  "query": "/* Query from DMS-WEBSQL-0-Eid_51878564335209209h by user 288837422613802050 */ CREATE \nVIEW `prot_resident`.`ads_dct` AS\nSELECT `a`.`MDC_ORG_CD` AS `org_id`,`a`.`MDC_ORG_NM` AS `org_nm`,`a`.`DCT_CD` AS `dct_cd`,`a`.`DCT_NM` AS `dct_nm`,NULL AS `doc_fct`,`a`.`DCT_ID_CRD_NO` AS `id_crd_no`,`a`.`DCT_TEL_NO` AS `slf_tel_no`,`a`.`STRT_USE_STTS` AS `is_enable`,1 AS `sgn_dct`,`a`.`CRT_TM` AS `crt_tm`,NULL AS `mdcr_act`,NULL AS `ascrn_dses_rgt`,`a`.`UPD_DT` AS `upt_tm`,0 AS `invld_flg` FROM `cdr_5721`.`PBLC_FML_DCT_BSC_INFMT` AS `a` WHERE LENGTH(`a`.`DCT_CD`) IN (7,8,9) and  LENGTH(`a`.`DCT_ID_CRD_NO`)='18' and `a`.`DCT_ID_CRD_NO` not like '0000%'\r\n\tand `a`.`DCT_ID_CRD_NO` not like '%0000' and SUBSTR(`a`.`DCT_ID_CRD_NO`, 7, 8) RLIKE '(((19|20)([0-9]{2}))(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229)'",
  "binlog": {
   "SchemaVersion": 13352,
   "DBInfo": null,
   "TableInfo": {
    "id": 17019,
    "name": {
     "O": "ads_dct",
     "L": "ads_dct"
    },
    "charset": "utf8mb4",
    "collate": "utf8mb4_bin",
    "cols": [
     {
      "id": 1,
      "name": {
       "O": "org_id",
       "L": "org_id"
      },
      "offset": 0,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 2,
      "name": {
       "O": "org_nm",
       "L": "org_nm"
      },
      "offset": 1,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 3,
      "name": {
       "O": "dct_cd",
       "L": "dct_cd"
      },
      "offset": 2,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 4,
      "name": {
       "O": "dct_nm",
       "L": "dct_nm"
      },
      "offset": 3,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 5,
      "name": {
       "O": "doc_fct",
       "L": "doc_fct"
      },
      "offset": 4,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 6,
      "name": {
       "O": "id_crd_no",
       "L": "id_crd_no"
      },
      "offset": 5,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 7,
      "name": {
       "O": "slf_tel_no",
       "L": "slf_tel_no"
      },
      "offset": 6,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 8,
      "name": {
       "O": "is_enable",
       "L": "is_enable"
      },
      "offset": 7,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 9,
      "name": {
       "O": "sgn_dct",
       "L": "sgn_dct"
      },
      "offset": 8,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 10,
      "name": {
       "O": "crt_tm",
       "L": "crt_tm"
      },
      "offset": 9,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 11,
      "name": {
       "O": "mdcr_act",
       "L": "mdcr_act"
      },
      "offset": 10,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 12,
      "name": {
       "O": "ascrn_dses_rgt",
       "L": "ascrn_dses_rgt"
      },
      "offset": 11,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 13,
      "name": {
       "O": "upt_tm",
       "L": "upt_tm"
      },
      "offset": 12,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     },
     {
      "id": 14,
      "name": {
       "O": "invld_flg",
       "L": "invld_flg"
      },
      "offset": 13,
      "origin_default": null,
      "origin_default_bit": null,
      "default": null,
      "default_bit": null,
      "default_is_expr": false,
      "generated_expr_string": "",
      "generated_stored": false,
      "dependences": null,
      "type": {
       "Tp": 0,
       "Flag": 0,
       "Flen": 0,
       "Decimal": 0,
       "Charset": "",
       "Collate": "",
       "Elems": null,
       "ElemsIsBinaryLit": null,
       "Array": false
      },
      "state": 5,
      "comment": "",
      "hidden": false,
      "change_state_info": null,
      "version": 0
     }
    ],
    "index_info": null,
    "constraint_info": null,
    "fk_info": null,
    "state": 5,
    "pk_is_handle": false,
    "is_common_handle": false,
    "common_handle_version": 0,
    "comment": "",
    "auto_inc_id": 0,
    "auto_id_cache": 0,
    "auto_rand_id": 0,
    "max_col_id": 14,
    "max_idx_id": 0,
    "max_fk_id": 0,
    "max_cst_id": 0,
    "update_timestamp": 454345957449400350,
    "ShardRowIDBits": 0,
    "max_shard_row_id_bits": 0,
    "auto_random_bits": 0,
    "auto_random_range_bits": 0,
    "pre_split_regions": 0,
    "partition": null,
    "compression": "",
    "view": {
     "view_algorithm": 0,
     "view_definer": {
      "Username": "root",
      "Hostname": "100.127.232.15",
      "CurrentUser": false,
      "AuthUsername": "root",
      "AuthHostname": "%",
      "AuthPlugin": "mysql_native_password"
     },
     "view_security": 0,
     "view_select": "SELECT `a`.`MDC_ORG_CD` AS `org_id`,`a`.`MDC_ORG_NM` AS `org_nm`,`a`.`DCT_CD` AS `dct_cd`,`a`.`DCT_NM` AS `dct_nm`,NULL AS `doc_fct`,`a`.`DCT_ID_CRD_NO` AS `id_crd_no`,`a`.`DCT_TEL_NO` AS `slf_tel_no`,`a`.`STRT_USE_STTS` AS `is_enable`,1 AS `sgn_dct`,`a`.`CRT_TM` AS `crt_tm`,NULL AS `mdcr_act`,NULL AS `ascrn_dses_rgt`,`a`.`UPD_DT` AS `upt_tm`,0 AS `invld_flg` FROM `cdr_5721`.`PBLC_FML_DCT_BSC_INFMT` AS `a` WHERE LENGTH(`a`.`DCT_CD`) IN (7,8,9) AND LENGTH(`a`.`DCT_ID_CRD_NO`)=_UTF8MB4'18' AND `a`.`DCT_ID_CRD_NO` NOT LIKE _UTF8MB4'0000%' AND `a`.`DCT_ID_CRD_NO` NOT LIKE _UTF8MB4'%0000' AND SUBSTR(`a`.`DCT_ID_CRD_NO`, 7, 8) REGEXP _UTF8MB4'(((19|20)([0-9]{2}))(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229)'",
     "view_checkoption": 1,
     "view_cols": null
    },
    "sequence": null,
    "Lock": null,
    "version": 5,
    "tiflash_replica": null,
    "is_columnar": false,
    "temp_table_type": 0,
    "cache_table_status": 0,
    "policy_ref_info": null,
    "stats_options": null,
    "exchange_partition_info": null,
    "ttl_info": null,
    "revision": 0
   },
   "FinishedTS": 454345961393881115,
   "MultipleTableInfos": null
  },
  "version": 1,
  "reorg_meta": null,
  "multi_schema_info": null,
  "priority": 0,
  "seq_num": 10298,
  "charset": "",
  "collate": "",
  "admin_operator": 0,
  "trace_info": {
   "connection_id": 1996817658,
   "session_alias": ""
  }
 },
...

2. What did you expect to see? (Required)

Try to reproduce it with unit test:

func TestCreateViewTwice(t *testing.T) {
	store := testkit.CreateMockStore(t)
	tk := testkit.NewTestKit(t, store)
	tk2 := testkit.NewTestKit(t, store)
	tk.MustExec("use test")
	tk.MustExec("create table t_raw (id int)")
	tk2.MustExec("use test")
	
	var wg sync.WaitGroup
	wg.Add(1)
	first := true
	testfailpoint.EnableCall(t, "github.com/pingcap/tidb/pkg/ddl/beforeDeliveryJob", func(job *model.Job) {
		if first {
			first = false
			go func() {
				defer wg.Done()
				tk2.MustExecToErr("create view v as select * from t_raw where id > 666")
			}()
		}
	})
	tk.MustExec("create view v as select * from t_raw")
	wg.Wait()
}

The test should pass

3. What did you see instead (Required)

Test failed.

4. What is your TiDB version? (Required)

v7.5.3

@tiancaiamao tiancaiamao added report/customer Customers have encountered this bug. severity/moderate type/bug The issue is confirmed as a bug. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. labels Jan 7, 2025
@tiancaiamao tiancaiamao linked a pull request Jan 7, 2025 that will close this issue
13 tasks
@ti-chi-bot ti-chi-bot bot added affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. labels Jan 8, 2025
@D3Hunter
Copy link
Contributor

D3Hunter commented Jan 9, 2025

maybe do some redaction to the SQL to avoid leak user info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. report/customer Customers have encountered this bug. severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants