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

[Vitess11] [VReplication] VReplication doesn't copy timestamp column with default current_timestamp #8759

Closed
tokikanno opened this issue Sep 2, 2021 · 1 comment

Comments

@tokikanno
Copy link
Contributor

tokikanno commented Sep 2, 2021

Overview of the Issue

VReplication doesn't copy timestamp column with default current_timestamp

Reproduction Steps

  • Create a table which has a timestamp column with DEFAULT CURRENT_TIMESTAMP setting
create table toki_test3 (
	id varchar(3) NOT NULL,
	created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
	PRIMARY KEY(`id`)
);
  • Insert several rows into it
insert into src.toki_test3 values ('AAA', NULL);
insert into src.toki_test3 values ('BBB', NULL);
select * from src.toki_test3;
+-----+---------------------+
| id  | created             |
+-----+---------------------+
| AAA | 2021-09-02 11:41:53 |
| BBB | 2021-09-02 11:41:54 |
+-----+---------------------+
  • Start MoveTables workflow on created table
vtctlclient MoveTables -source src -tables toki_test3 Create dest.test
  • Verify copied table
select * from dest.toki_test3;
+-----+---------------------+
| id  | created             |
+-----+---------------------+
| AAA | 2021-09-02 11:45:13 |
| BBB | 2021-09-02 11:45:13 |
+-----+---------------------+

The created value is not the same as origin table, seems VReplication didn't copy the values of created column from origin table.

Binary version

Vitess V11 release

Related slack threads

Possible reason

This issue may caused by PR #8129

The copied table schema has an extra info DEFAULT_GENERATED (the origin table didn’t)

desc toki_test3;
+---------+------------+------+-----+-------------------+-------------------+
| Field   | Type       | Null | Key | Default           | Extra             |
+---------+------------+------+-----+-------------------+-------------------+
| id      | varchar(3) | NO   | PRI | NULL              |                   |
| created | timestamp  | NO   |     | CURRENT_TIMESTAMP | DEFAULT_GENERATED |
+---------+------------+------+-----+-------------------+-------------------+

Via these codes (merged from #8129 )

if strings.Contains(extra, "generated") || strings.Contains(extra, "virtual") {

The created timestamp column seems will be ignored during replication because Vitess think it is a generated column

@mattlord
Copy link
Contributor

This was resolved via #8763 and #8796.

Thank you so much for the great issue and PR, @tokikanno !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants