You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "shaoyu-li (via GitHub)" <gi...@apache.org> on 2026/08/04 20:48:37 UTC

[PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

shaoyu-li opened a new pull request, #12364:
URL: https://github.com/apache/gravitino/pull/12364

   ### What changes were proposed in this pull request?
   
   Two changes to the MySQL DDL under `scripts/mysql/`:
   
   1. Six index names that were reused across 15 tables (`idx_mid`,
      `idx_cid`, `idx_sid`, `idx_rid`, `uk_sid_tn_del`, `uk_sid_fn_del`) are
      each prefixed with their table name, e.g. `table_meta_idx_mid`.
      32 index declarations are renamed in total.
   
   2. `table_version_info`: `version` and `deleted_at` become `NOT NULL`,
      and `uk_table_id_version_deleted_at` is promoted to
      `PRIMARY KEY (table_id, version, deleted_at)`. No surrogate `id`
      column is added.
   
   16 files are touched: 10 `schema-*.sql` and 6 `upgrade-*.sql`. The
   `table_version_info` change affects 5 of them.
   
   This PR deliberately does not add a migration script. Only the
   `CREATE TABLE` definitions change, so the new index names and the new
   primary key apply to freshly created databases; an existing deployment
   keeps its current index names and its primary-key-less
   `table_version_info`. Renaming an index on a live table is metadata-only
   from MySQL 5.7 onward, but turning the unique key of `table_version_info`
   into a primary key is a table rebuild, so migrating existing deployments
   deserves its own change with a proper lock and duration analysis rather
   than being folded in here.
   
   ### Why are the changes needed?
   
   MySQL scopes index names per table, so the reused names were valid, but
   they are ambiguous: `idx_mid` indexes `metalake_id` on most tables yet
   `metadata_object_id` on `tag_relation_meta` and `policy_relation_meta`.
   An `EXPLAIN` or slow query log that mentions `idx_mid` therefore does not
   identify the indexed column on its own. Unique names also let these
   scripts be consumed by tooling that requires index names to be unique
   across the whole schema.
   
   `table_version_info` having no primary key means InnoDB clusters it on an
   invisible generated key, so every lookup through the unique key costs a
   secondary index traversal plus a lookup into the clustered index.
   Promoting the existing unique key removes that without widening the row.
   
   Fix: #(issue)
   
   ### Does this PR introduce _any_ user-facing change?
   
   No API or configuration changes.
   
   The DDL for new installations changes: index names differ, and
   `table_version_info` gains a primary key with two columns becoming
   `NOT NULL`. Existing databases are left untouched by this PR.
   
   ### How was this patch tested?
   
   No new tests; this is a DDL-only change.
   
   - Verified that no index or unique-key name is declared more than once
     across any of the 16 modified files.
   - Confirmed no code selects an index by name: there is no `FORCE INDEX`
     or `USE INDEX` in the tree, and no mapper references an index name.
   - Confirmed `TableVersionBaseSQLProvider` always supplies `version` and
     `deleted_at` on insert, so marking them `NOT NULL` cannot break
     existing writes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "shaoyu-li (via GitHub)" <gi...@apache.org>.
shaoyu-li commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5211025874

   Thank you for your response. You're right that upgrade-1.3.0-to-2.0.0 needs the same change.
   We're running 1.3.0 internally, so a 1.3.0 user needs a way to pick this up without waiting for 2.0.0. I'd like to add a 1.3.1 schema for that. I'll write all these scripts:
     upgrade-1.3.0-to-1.3.1  the index renames and the table_version_info primary key
     upgrade-1.3.0-to-2.0.0  the same two changes, added to what is already there, so the direct 1.3.0 -> 2.0.0 path stays equivalent to a fresh 2.0.0 install
     upgrade-1.3.1-to-2.0.0  the current 1.3.0 -> 2.0.0 content without the renames, since 1.3.1 already has them
     schema-1.3.1-mysql.sql
   
   Only MySQL is affected, so for h2 and postgresql the 1.3.1 schema is a copy of 1.3.0 and only the 1.3.1 -> 2.0.0 script is added.
   I'll push these to this PR shortly, and open a cherry-pick PR against branch-1.3 once this one lands. Let me know if you'd rather structure the version chain differently. Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "zhangjiashen (via GitHub)" <gi...@apache.org>.
zhangjiashen commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5209205561

   > We may need to modify the 2.0.0 schema scripts only and leave the files with the old version.
   
   @yuqi1129 Thanks for looking into this! We're currently using version 1.3.0 with the 1.3.0 schema internally. If this fix is only included in 2.0.0, curious what's the recommended way to apply it to existing 1.3.0 schema?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "shaoyu-li (via GitHub)" <gi...@apache.org>.
shaoyu-li commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5211183305

   I have committed the new change. Please review this. Thank you very much!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5215344748

   <!-- coverage-report -->
   ### Code Coverage Report
   |Overall Project|68.29% **`+0.28%`**|:green_circle:|
   |:-|:-|:-:|
   |Files changed|88.43%|:green_circle:|
   <br>
   
   |Module|Coverage||
   |:-|:-|:-:|
   |aliyun|1.72%|:red_circle:|
   |api|49.37%|:green_circle:|
   |authorization-common|85.96%|:green_circle:|
   |aws|42.04%|:green_circle:|
   |azure|2.47%|:red_circle:|
   |catalog-common|9.92%|:red_circle:|
   |catalog-fileset|79.74%|:green_circle:|
   |catalog-glue|68.95%|:green_circle:|
   |catalog-hive|79.4%|:green_circle:|
   |catalog-jdbc-common|45.7%|:green_circle:|
   |catalog-jdbc-doris|81.8%|:green_circle:|
   |catalog-jdbc-mysql|79.33%|:green_circle:|
   |catalog-jdbc-postgresql|83.39%|:green_circle:|
   |catalog-jdbc-starrocks|79.16%|:green_circle:|
   |catalog-kafka|77.01%|:green_circle:|
   |catalog-lakehouse-generic|59.18%|:green_circle:|
   |catalog-lakehouse-hudi|79.1%|:green_circle:|
   |catalog-lakehouse-iceberg|85.86%|:green_circle:|
   |catalog-lakehouse-paimon|84.23%|:green_circle:|
   |catalog-model|77.72%|:green_circle:|
   |cli|44.48%|:green_circle:|
   |client-java|78.27%|:green_circle:|
   |common|52.57%|:green_circle:|
   |core|83.2% **`+0.24%`**|:green_circle:|
   |filesystem-hadoop3|77.28%|:green_circle:|
   |flink|0.0%|:red_circle:|
   |flink-common|48.68%|:green_circle:|
   |flink-runtime|0.0%|:red_circle:|
   |gcp|14.12%|:red_circle:|
   |hadoop-auth|68.0%|:green_circle:|
   |hadoop-common|12.7%|:red_circle:|
   |hive-metastore-common|53.4%|:green_circle:|
   |iceberg-common|64.75%|:green_circle:|
   |iceberg-rest-server|75.03%|:green_circle:|
   |idp-basic|86.02%|:green_circle:|
   |integration-test-common|0.0%|:red_circle:|
   |jobs|62.92%|:green_circle:|
   |lance-common|31.75%|:red_circle:|
   |lance-rest-server|63.47%|:green_circle:|
   |lineage|53.02%|:green_circle:|
   |optimizer|83.17%|:green_circle:|
   |optimizer-api|21.95%|:red_circle:|
   |server|85.76%|:green_circle:|
   |server-common|76.45%|:green_circle:|
   |spark|28.57%|:red_circle:|
   |spark-common|45.89%|:green_circle:|
   |tencent|69.84%|:green_circle:|
   |trino-connector|40.29%|:green_circle:|
   
   <details>
   <summary>Files</summary>
   
   |Module|File|Coverage||
   |:-|:-|:-|:-:|
   |common|[ConfigConstants.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/common/src/main/java/org/apache/gravitino/config/ConfigConstants.java)|0.0%|:red_circle:|
   |core|[AccessControlManager.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/authorization/AccessControlManager.java)|100.0%|:green_circle:|
   ||[OperationType.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java)|100.0%|:green_circle:|
   ||[GroupMetaBaseSQLProvider.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/GroupMetaBaseSQLProvider.java)|100.0%|:green_circle:|
   ||[UserMetaBaseSQLProvider.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/UserMetaBaseSQLProvider.java)|100.0%|:green_circle:|
   ||[GroupMetaH2Provider.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/GroupMetaH2Provider.java)|100.0%|:green_circle:|
   ||[UserMetaH2Provider.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/UserMetaH2Provider.java)|100.0%|:green_circle:|
   ||[GroupMetaPostgreSQLProvider.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/GroupMetaPostgreSQLProvider.java)|100.0%|:green_circle:|
   ||[UserMetaPostgreSQLProvider.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/UserMetaPostgreSQLProvider.java)|100.0%|:green_circle:|
   ||[CompatibilityUtils.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java)|99.39%|:green_circle:|
   ||[UserMetaSQLProviderFactory.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaSQLProviderFactory.java)|96.3%|:green_circle:|
   ||[GroupMetaSQLProviderFactory.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaSQLProviderFactory.java)|96.15%|:green_circle:|
   ||[GroupMetaService.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.java)|92.78%|:green_circle:|
   ||[UserMetaService.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/service/UserMetaService.java)|92.78%|:green_circle:|
   ||[AccessControlEventDispatcher.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/listener/AccessControlEventDispatcher.java)|89.08%|:green_circle:|
   ||[UserGroupManager.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/authorization/UserGroupManager.java)|68.42%|:green_circle:|
   ||[AccessControlHookDispatcher.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/hook/AccessControlHookDispatcher.java)|33.33%|:red_circle:|
   ||[AccessControlDispatcher.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/authorization/AccessControlDispatcher.java)|0.0%|:red_circle:|
   ||[GroupMetaMapper.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaMapper.java)|0.0%|:red_circle:|
   ||[UserMetaMapper.java](https://github.com/shaoyu-li/gravitino/blob/263f30e26275650eb702c35bce08485f8fffccd4/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaMapper.java)|0.0%|:red_circle:|
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "shaoyu-li (via GitHub)" <gi...@apache.org>.
shaoyu-li commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5244663676

   Hi, thanks for your response. May I ask when the 2.0.0 version will be released, and what changes/updates are coming to Lance part?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "shaoyu-li (via GitHub)" <gi...@apache.org>.
shaoyu-li commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5319706083

   @yuqi1129  That makes sense, thanks for taking another look. I agree this is an improvement rather than a bug fix, and I take the point about not changing database scripts in patch releases.
   
   I have narrowed the PR to 2.0.0 only — the 1.3.1 schema and the two related upgrade scripts are gone. What is left is two files:
   
   - `schema-2.0.0-mysql.sql` — the index renames and the `table_version_info` primary key
   - `upgrade-1.3.0-to-2.0.0-mysql.sql` — the same two changes appended to the existing content, which is unchanged
   
   The upgrade script needs to stay in sync, otherwise a database upgraded from 1.3.0 would keep the old index names and a `table_version_info` without a primary key. I verified that applying it to `schema-1.3.0-mysql.sql` yields exactly the index names and primary keys declared in `schema-2.0.0-mysql.sql`.
   
   For our 1.3.0 deployment we will maintain the migration internally, as you suggested. Thanks also for the 2.0.0 timeline and the Lance roadmap.
   
   This should be ready for another look.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5186676403

   We may need to modify the 2.0.0 schema scripts only and leave the files with the old version. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5210859369

   OK, according to the previous discussion, it seems that this is a bug fix, so we also need to cherry-pick this fix to branch-1.3. Do you have time to change the upgrade-1.3.0-2.0.0 scripts? I can help if you have other things to do.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 merged PR #12364:
URL: https://github.com/apache/gravitino/pull/12364


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5249696141

   > Hi, thanks for your response. May I ask when the 2.0.0 version will be released, and what changes/updates are coming to Lance part?
   
   We expect to release it in the middle of September. As for Lance, we will
   - Support authn and authz
   - Make it consistent with IRC
   - Several bug fixes and improvements will be launched.
   
   If you have any suggestions, do not hesitate to share your advice, and welcome to jointly develop.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5237450530

   @shaoyu-li 
   
   After a more thorough analysis, I would like to revise my earlier assessment. I believe this change should be classified as an improvement rather than a bug fix. Although the current index names may be debatable, they are valid in MySQL and do not cause functional issues.
   
   Traditionally, unless there is a critical bug, we avoid changing database scripts in patch releases. Otherwise, we need to introduce and maintain additional upgrade paths between patch and major versions. As of 1.3.0, we have not made schema changes between patch releases.
    
   Therefore, I have some concerns about introducing these changes in 1.3.1. Would it be possible to limit this PR to 2.0.0? For your existing 1.3.0 deployment, I suggest treating this as an internal improvement and maintaining the corresponding migration internally.
   
   Looking forward to hearing more about this. Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12363] improvement(storage): Make MySQL index names unique and give table_version_info a primary key [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #12364:
URL: https://github.com/apache/gravitino/pull/12364#issuecomment-5322222002

   > @yuqi1129 That makes sense, thanks for taking another look. I agree this is an improvement rather than a bug fix, and I take the point about not changing database scripts in patch releases.
   > 
   > I have narrowed the PR to 2.0.0 only — the 1.3.1 schema and the two related upgrade scripts are gone. What is left is two files:
   > 
   > * `schema-2.0.0-mysql.sql` — the index renames and the `table_version_info` primary key
   > * `upgrade-1.3.0-to-2.0.0-mysql.sql` — the same two changes appended to the existing content, which is unchanged
   > 
   > The upgrade script needs to stay in sync, otherwise a database upgraded from 1.3.0 would keep the old index names and a `table_version_info` without a primary key. I verified that applying it to `schema-1.3.0-mysql.sql` yields exactly the index names and primary keys declared in `schema-2.0.0-mysql.sql`.
   > 
   > For our 1.3.0 deployment we will maintain the migration internally, as you suggested. Thanks also for the 2.0.0 timeline and the Lance roadmap.
   > 
   > This should be ready for another look.
   
   Great, I will review and merge it ASAP.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org