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

Bug Report: Unable to execute a DDL twice in a same client connection #14049

Closed
earayu opened this issue Sep 20, 2023 · 4 comments
Closed

Bug Report: Unable to execute a DDL twice in a same client connection #14049

earayu opened this issue Sep 20, 2023 · 4 comments
Assignees
Labels
Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) Type: Bug

Comments

@earayu
Copy link

earayu commented Sep 20, 2023

Overview of the Issue

I've observed that the introduced session_uuid from this issue (#7263) is being used as a migration_context for OnlineDDL. Nevertheless, a consequence of this is that it prevents the execution of a DDL statement more than once for a single client connection.

Reproduction Steps

create table t3 (c1 int primary);

drop table t3;

-- won't be executed as the migration_context is unchanged
create table t3 (c1 int primary); 

Binary Version

main

Operating System and Environment details

main

Log Fragments

No response

@earayu earayu added Needs Triage This issue needs to be correctly labelled and triaged Type: Bug labels Sep 20, 2023
@earayu
Copy link
Author

earayu commented Sep 20, 2023

Maybe this problem can be fixed like this:
image

@shlomi-noach shlomi-noach self-assigned this Sep 21, 2023
@shlomi-noach shlomi-noach added the Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) label Sep 21, 2023
@shlomi-noach
Copy link
Contributor

The behavior is actually intentional, with multi-sharded environments in mind, and where some shards may succeed a migration and some may fail. See details in https://vitess.io/docs/18.0/user-guides/schema-changes/advanced-usage/#duplicate-migration-detection. As per the docs (and a recent addition), you may explicitly set @@migration_context to override @@session_uuid:

mysql> set @@migration_context = uuid();
Query OK, 0 rows affected (0.00 sec)

mysql> select @@migration_context;
+--------------------------------------+
| @@migration_context                  |
+--------------------------------------+
| 53374dec-58a9-11ee-9d5b-0a43f95f28a3 |
+--------------------------------------+
1 row in set (0.00 sec)

This value is then used in your next submitted migrations. So, the following will work:

> create table t3 (c1 int primary);

> drop table t3;

> set @@migration_context = uuid();
> create table t3 (c1 int primary); 

@shlomi-noach shlomi-noach removed the Needs Triage This issue needs to be correctly labelled and triaged label Sep 21, 2023
@shlomi-noach
Copy link
Contributor

If there's no more comments I will go ahead and close this issue.

@earayu
Copy link
Author

earayu commented Sep 26, 2023

If there's no more comments I will go ahead and close this issue.

Thank you for your reply, there's no more comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants