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

Rollback after error can clobber updates #6285

Closed
aquarapid opened this issue Jun 9, 2020 · 0 comments
Closed

Rollback after error can clobber updates #6285

aquarapid opened this issue Jun 9, 2020 · 0 comments
Assignees
Milestone

Comments

@aquarapid
Copy link
Contributor

aquarapid commented Jun 9, 2020

This seems to be just another form of #6264 , but happens with default settings.

This occurs in current master (b9bb5d0), but has been reported against 6.0 as well.

Scenario:

  • Setup by using examples/local/101_initial_cluster.sh
  • Connect to vtgate, and run through the following testcase.
  • Create table with unique key and insert a value:
$ mysql -A -u root -P 15306 -h 127.0.0.1 commerce
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.9-Vitess MySQL Community Server - GPL
.
.
mysql> create table t1 (c1 bigint primary key, c2 bigint, unique key (c2));
Query OK, 0 rows affected (0.12 sec)

mysql> insert into t1 (c1, c2) values (1, 1);
Query OK, 1 row affected (0.03 sec)

mysql> select * from t1;
+----+------+
| c1 | c2   |
+----+------+
|  1 |    1 |
+----+------+
1 row in set (0.01 sec)
  • Verify autocommit is on (by default):
mysql> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | ON    |
+---------------+-------+
1 row in set (0.01 sec)
  • Insert a value with duplicate unique key:
mysql> insert into t1 (c1, c2) values (2, 1);
ERROR 1062 (23000): vtgate: http://localhost:15001/: execInsertUnsharded: target: commerce.0.master, used tablet: zone1-100 (localhost): vttablet: rpc error: code = AlreadyExists desc = Duplicate entry '1' for key 't1.c2' (errno 1062) (sqlstate 23000) (CallerID: userData1): Sql: "insert into t1(c1, c2) values (:vtg1, :vtg2)", BindVars: {vtg1: "type:INT64 value:\"2\" "vtg2: "type:INT64 value:\"1\" "}
  • Verify table is unchanged:
mysql> select * from t1;
+----+------+
| c1 | c2   |
+----+------+
|  1 |    1 |
+----+------+
1 row in set (0.00 sec)
  • Update existing row, verifying it has changed:
mysql> update t1 set c2 = 2 where c1 = 1;
Query OK, 1 row affected (0.01 sec)

mysql> select * from t1;
+----+------+
| c1 | c2   |
+----+------+
|  1 |    2 |
+----+------+
1 row in set (0.00 sec)
  • Now, wait 30 seconds, and check table again:
mysql> select sleep(30);
+-----------+
| sleep(30) |
+-----------+
|         0 |
+-----------+
1 row in set (30.00 sec)
mysql> select * from t1;
ERROR 1317 (HY000): vtgate: http://localhost:15001/: target: commerce.0.master, used tablet: zone1-100 (localhost): vttablet: rpc error: code = Aborted desc = transaction 1591663223087763322: ended at 2020-06-08 17:47:59.896 PDT (exceeded timeout: 30s) (CallerID: userData1)
  • That didn't work, check again:
mysql> select * from t1;
+----+------+
| c1 | c2   |
+----+------+
|  1 |    1 |
+----+------+
1 row in set (0.01 sec)

Table has reverted to previous state.

@aquarapid aquarapid assigned aquarapid and systay and unassigned aquarapid Jun 9, 2020
gedgar pushed a commit to planetscale/vitess that referenced this issue Jun 10, 2020
Fixes vitessio#6264
Fixes vitessio#6285

Signed-off-by: Andres Taylor <andres@planetscale.com>
@deepthi deepthi added this to the v7.0 milestone Jun 15, 2020
deepthi pushed a commit to planetscale/vitess that referenced this issue Jun 16, 2020
Fixes vitessio#6264
Fixes vitessio#6285

Signed-off-by: Andres Taylor <andres@planetscale.com>

Signed-off-by: deepthi <deepthi@planetscale.com>
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

No branches or pull requests

3 participants