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

Adding @@session_uuid to vtgate; used as 'context' by Online DDL #7263

Merged

Conversation

shlomi-noach
Copy link
Contributor

@shlomi-noach shlomi-noach commented Jan 7, 2021

Description

We introduce new session variable:

$ mysql

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@session_uuid;
+--------------------------------------+
| @@session_uuid                       |
+--------------------------------------+
| 29191773-50c1-11eb-8798-f875a4d24e90 |
+--------------------------------------+
1 row in set (0.00 sec)

mysql> select @@session_uuid;
+--------------------------------------+
| @@session_uuid                       |
+--------------------------------------+
| 29191773-50c1-11eb-8798-f875a4d24e90 |
+--------------------------------------+
1 row in set (0.01 sec)

mysql> ^DBye


$ mysql -e "select @@session_uuid"
+--------------------------------------+
| @@session_uuid                       |
+--------------------------------------+
| 3202f39e-50c1-11eb-8798-f875a4d24e90 |
+--------------------------------------+

$ mysql -e "select @@session_uuid"
+--------------------------------------+
| @@session_uuid                       |
+--------------------------------------+
| 32bc2102-50c1-11eb-8798-f875a4d24e90 |
+--------------------------------------+

As can be seen, each session now has a unique session_uuid, accessible to the user. The uuid is generated on session creation, and is unchanged throughout the sessions' life.

The new variable is used by Online DDL functionality. In #7082 we introduced the idea of a migration "context", which is basically some textual identifier. For example, if you run vtctlclient ApplySchema ... with multiple DDLs, they all share the same context, since all run by the same vtctlient invocation.

Now this is the same for vtgate, too. The context includes the session UUID. For example:

mysql> select id, migration_uuid, migration_context from _vt.schema_migrations ;
+----+--------------------------------------+---------------------------------------------+
| id | migration_uuid                       | migration_context                           |
+----+--------------------------------------+---------------------------------------------+
|  1 | 5f2b056d_50c0_11eb_9b88_f875a4d24e90 | vtgate:53137624-50c0-11eb-9b88-f875a4d24e90 |
|  2 | 95bf8bb8_50c0_11eb_9b88_f875a4d24e90 | vtgate:804fd443-50c0-11eb-9b88-f875a4d24e90 |
|  3 | df41df8e_50c1_11eb_8798_f875a4d24e90 | vtgate:dbb6b0f5-50c1-11eb-8798-f875a4d24e90 |
|  4 | df9c28b5_50c1_11eb_8798_f875a4d24e90 | vtgate:dbb6b0f5-50c1-11eb-8798-f875a4d24e90 |
+----+--------------------------------------+---------------------------------------------+

In the above, migrations (3) and (4) were both created by the same vtgate session.

Related Issue(s)

tracking issue #6926

Checklist

  • Should this PR be backported? ideally this gets through to v0.9
  • Tests were added or are not required
  • Documentation was added or is not required

Impacted Areas in Vitess

Components that this PR will affect:

  • Query Serving
  • VReplication
  • Cluster Management
  • Build

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Copy link
Collaborator

@systay systay left a comment

Choose a reason for hiding this comment

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

LGTM

@shlomi-noach
Copy link
Contributor Author

fastest review ever!

@shlomi-noach shlomi-noach merged commit ccd52da into vitessio:master Jan 7, 2021
@shlomi-noach shlomi-noach deleted the online-ddl-vtgate-session-uuid branch January 7, 2021 08:56
@askdba askdba added this to the v9.0 milestone Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants