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: trying to change column to JSON type with onlineddl results in error #14089

Closed
olyazavr opened this issue Sep 25, 2023 · 2 comments · Fixed by #14093
Closed

Bug Report: trying to change column to JSON type with onlineddl results in error #14089

olyazavr opened this issue Sep 25, 2023 · 2 comments · Fixed by #14093
Assignees
Labels
Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) Type: Bug

Comments

@olyazavr
Copy link
Contributor

olyazavr commented Sep 25, 2023

Overview of the Issue

When trying to change the type and name of a column to a JSON type, the onlineddl migration fails because it cannot find the new column name in the old table. This specifically only fails when converting to JSON, not any other type.

From the logs, I can see it trying to select the new column name from the old table, which is incorrect. Weirdly enough, the vreplication filter is printed out as using the correct (old) column name, but the query that is streamed is using the wrong (new) column name

Reproduction Steps

CREATE TABLE `example` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `id2` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB
vtctl ApplySchema -- --skip_preflight --ddl_strategy "vitess" --sql "alter table example change id2 id3 JSON;" MyKeyspace

See it fail with column id3 not found in table example

Binary Version

"almost v18" - commit https://github.com/vitessio/vitess/commit/e7c0bb07ac0b5c0ddd2dfa2da5a1bfb2a25bae4a

Operating System and Environment details

Centos8, Linux 5.4.141-hs22.el8.x86_64

Log Fragments

creating controller  .... filter:{rules:{match:"_21d02a9e_5ba9_11ee_a124_0e60febffd0b_20230925134048_vrepl" filter:"select `id` as `id`,  convert(`id2` using utf8mb4) as `id3` from `example`
vttablet I0925 13:40:53.431411       2 engine.go:280] Streaming rows for query select /*vt+ ukColumns="id" */ id, convert(id3 using utf8mb4) as id3 from example, lastpk: []
vttablet E0925 13:40:53.432177       2 planbuilder.go:434] column id3 not found in table example
vttablet E0925 13:40:53.432187       2 rowstreamer.go:185] column id3 not found in table example
@olyazavr
Copy link
Contributor Author

The code path goes through here and then here the new column gets used instead of the old column

@olyazavr
Copy link
Contributor Author

Then the actual error comes from here where it tries to find the new column in the table (the new column does not exist)

Both of these places use the alias as the column name, which isn't right in this case because the alias is the new column that doesn't exist in the table

@shlomi-noach shlomi-noach added Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) and removed Needs Triage This issue needs to be correctly labelled and triaged labels Sep 26, 2023
@shlomi-noach shlomi-noach self-assigned this Sep 26, 2023
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

Successfully merging a pull request may close this issue.

2 participants