Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions doc/design-docs/AtomicDistributedTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,11 @@ The redo_state table needs to support the following use cases:
```
create table redo_state(
dtid varbinary(512),
db_name varbinary(256) not null default '',
state bigint, // state can be 0: Failed, 1: Prepared.
time_created bigint,
message text, // record any error message.
primary key(dtid)
primary key(dtid, db_name)
)
```

Expand All @@ -376,9 +377,10 @@ It needs the ability to read the statements of a dtid in the correct order (by i
```
create table redo_statement(
dtid varbinary(512),
db_name varbinary(256) not null default '',
id bigint,
statement mediumblob,
primary key(dtid, id)
primary key(dtid, db_name, id)
)
```

Expand Down Expand Up @@ -733,4 +735,4 @@ MySQL XA was considered as an alternative to having RMs manage the transaction r
There are currently over 20 open bugs on XA. On MySQL 8.0.33, reproduction steps were followed for all these bugs, and 8 still persist. Out of these 8 bugs, 4 have patches attached that resolve the issues when applied.
For the remaining 4 issues, changes will need to be made either in the code or the workflow to ensure they are resolved.

MySQL’s XA seems a probable candidate if we encounter issues with our implementation of handling distributed transactions that XA can resolve. XA's chatty API and no known big production deployment have kept us away from using it.
MySQL’s XA seems a probable candidate if we encounter issues with our implementation of handling distributed transactions that XA can resolve. XA's chatty API and no known big production deployment have kept us away from using it.
6 changes: 3 additions & 3 deletions go/test/endtoend/transaction/twopc/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ var tables = map[string]extractInterestingValues{
},
"ks.redo_state": func(dtidMap map[string]string, vals []sqltypes.Value) (out []sqltypes.Value) {
dtid := getDTID(dtidMap, vals[0].ToString())
dtState := getDTState(vals[1])
dtState := getDTState(vals[2])
out = append(out, sqltypes.NewVarChar(dtid), sqltypes.NewVarChar(dtState.String()))
return
},
"ks.redo_statement": func(dtidMap map[string]string, vals []sqltypes.Value) (out []sqltypes.Value) {
dtid := getDTID(dtidMap, vals[0].ToString())
stmt := getStatement(vals[2].ToString())
out = append([]sqltypes.Value{sqltypes.NewVarChar(dtid)}, vals[1], sqltypes.TestValue(sqltypes.Blob, stmt))
stmt := getStatement(vals[3].ToString())
out = append([]sqltypes.Value{sqltypes.NewVarChar(dtid)}, vals[2], sqltypes.TestValue(sqltypes.Blob, stmt))
return
},
"ks.twopc_user": func(_ map[string]string, vals []sqltypes.Value) []sqltypes.Value { return vals },
Expand Down
3 changes: 2 additions & 1 deletion go/vt/sidecardb/schema/twopc/redo_state.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ limitations under the License.

CREATE TABLE IF NOT EXISTS redo_state(
dtid varbinary(512) NOT NULL,
db_name varbinary(256) NOT NULL DEFAULT '',
state bigint NOT NULL,
time_created bigint NOT NULL,
message text,
primary key(dtid)
primary key(dtid, db_name)
) ENGINE = InnoDB CHARSET = utf8mb4
3 changes: 2 additions & 1 deletion go/vt/sidecardb/schema/twopc/redo_statement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ limitations under the License.

CREATE TABLE IF NOT EXISTS redo_statement(
dtid varbinary(512) NOT NULL,
db_name varbinary(256) NOT NULL DEFAULT '',
id bigint NOT NULL,
statement mediumblob NOT NULL,
primary key(dtid, id)
primary key(dtid, db_name, id)
) ENGINE = InnoDB CHARSET = utf8mb4
24 changes: 12 additions & 12 deletions go/vt/vtexplain/testdata/twopc-output/deletesharded-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ delete from user where id=1
4 ks_sharded/-40: insert into `_vt`.dt_participant(dtid, id, keyspace, shard) values ('ks_sharded:-40:1515392388787015722', 1, 'ks_sharded', '80-c0')
4 ks_sharded/-40: commit
5 ks_sharded/80-c0: begin
5 ks_sharded/80-c0: insert into `_vt`.redo_state(dtid, state, time_created) values ('ks_sharded:-40:1515392388787015722', 1, 1515392388909259045)
5 ks_sharded/80-c0: insert into `_vt`.redo_statement(dtid, id, statement) values ('ks_sharded:-40:1515392388787015722', 1, 'delete from name_user_map where (name = \'name_val_1\' and user_id = 1) /* vtgate:: keyspace_id:a6e89b54b129c33051b76db219595660 */')
5 ks_sharded/80-c0: insert into `_vt`.redo_state(dtid, db_name, state, time_created) values ('ks_sharded:-40:1515392388787015722', '', 1, 1515392388909259045)
5 ks_sharded/80-c0: insert into `_vt`.redo_statement(dtid, db_name, id, statement) values ('ks_sharded:-40:1515392388787015722', '', 1, 'delete from name_user_map where (name = \'name_val_1\' and user_id = 1) /* vtgate:: keyspace_id:a6e89b54b129c33051b76db219595660 */')
5 ks_sharded/80-c0: commit
6 ks_sharded/-40: update `_vt`.dt_state set state = 2 where dtid = 'ks_sharded:-40:1515392388787015722' and state = 1
6 ks_sharded/-40: commit
7 ks_sharded/80-c0: delete from `_vt`.redo_state where dtid = 'ks_sharded:-40:1515392388787015722'
7 ks_sharded/80-c0: delete from `_vt`.redo_statement where dtid = 'ks_sharded:-40:1515392388787015722'
7 ks_sharded/80-c0: delete from `_vt`.redo_state where dtid = 'ks_sharded:-40:1515392388787015722' and db_name = ''
7 ks_sharded/80-c0: delete from `_vt`.redo_statement where dtid = 'ks_sharded:-40:1515392388787015722' and db_name = ''
7 ks_sharded/80-c0: commit
8 ks_sharded/-40: begin
8 ks_sharded/-40: delete from `_vt`.dt_state where dtid = 'ks_sharded:-40:1515392388787015722'
Expand All @@ -54,20 +54,20 @@ delete from user where name='billy'
5 ks_sharded/c0-: insert into `_vt`.dt_participant(dtid, id, keyspace, shard) values ('ks_sharded:c0-:1515392388798209886', 1, 'ks_sharded', '-40'), ('ks_sharded:c0-:1515392388798209886', 2, 'ks_sharded', '80-c0')
5 ks_sharded/c0-: commit
6 ks_sharded/-40: begin
6 ks_sharded/-40: insert into `_vt`.redo_state(dtid, state, time_created) values ('ks_sharded:c0-:1515392388798209886', 1, 1515392389021902468)
6 ks_sharded/-40: insert into `_vt`.redo_statement(dtid, id, statement) values ('ks_sharded:c0-:1515392388798209886', 1, 'delete from user where id in (1) /* vtgate:: keyspace_id:166b40b44aba4bd6 */')
6 ks_sharded/-40: insert into `_vt`.redo_state(dtid, db_name, state, time_created) values ('ks_sharded:c0-:1515392388798209886', '', 1, 1515392389021902468)
6 ks_sharded/-40: insert into `_vt`.redo_statement(dtid, db_name, id, statement) values ('ks_sharded:c0-:1515392388798209886', '', 1, 'delete from user where id in (1) /* vtgate:: keyspace_id:166b40b44aba4bd6 */')
6 ks_sharded/-40: commit
6 ks_sharded/80-c0: begin
6 ks_sharded/80-c0: insert into `_vt`.redo_state(dtid, state, time_created) values ('ks_sharded:c0-:1515392388798209886', 1, 1515392389021902697)
6 ks_sharded/80-c0: insert into `_vt`.redo_statement(dtid, id, statement) values ('ks_sharded:c0-:1515392388798209886', 1, 'delete from name_user_map where (name = \'name_val_1\' and user_id = 1) /* vtgate:: keyspace_id:a6e89b54b129c33051b76db219595660 */')
6 ks_sharded/80-c0: insert into `_vt`.redo_state(dtid, db_name, state, time_created) values ('ks_sharded:c0-:1515392388798209886', '', 1, 1515392389021902697)
6 ks_sharded/80-c0: insert into `_vt`.redo_statement(dtid, db_name, id, statement) values ('ks_sharded:c0-:1515392388798209886', '', 1, 'delete from name_user_map where (name = \'name_val_1\' and user_id = 1) /* vtgate:: keyspace_id:a6e89b54b129c33051b76db219595660 */')
6 ks_sharded/80-c0: commit
7 ks_sharded/c0-: update `_vt`.dt_state set state = 2 where dtid = 'ks_sharded:c0-:1515392388798209886' and state = 1
7 ks_sharded/c0-: commit
8 ks_sharded/-40: delete from `_vt`.redo_state where dtid = 'ks_sharded:c0-:1515392388798209886'
8 ks_sharded/-40: delete from `_vt`.redo_statement where dtid = 'ks_sharded:c0-:1515392388798209886'
8 ks_sharded/-40: delete from `_vt`.redo_state where dtid = 'ks_sharded:c0-:1515392388798209886' and db_name = ''
8 ks_sharded/-40: delete from `_vt`.redo_statement where dtid = 'ks_sharded:c0-:1515392388798209886' and db_name = ''
8 ks_sharded/-40: commit
8 ks_sharded/80-c0: delete from `_vt`.redo_state where dtid = 'ks_sharded:c0-:1515392388798209886'
8 ks_sharded/80-c0: delete from `_vt`.redo_statement where dtid = 'ks_sharded:c0-:1515392388798209886'
8 ks_sharded/80-c0: delete from `_vt`.redo_state where dtid = 'ks_sharded:c0-:1515392388798209886' and db_name = ''
8 ks_sharded/80-c0: delete from `_vt`.redo_statement where dtid = 'ks_sharded:c0-:1515392388798209886' and db_name = ''
8 ks_sharded/80-c0: commit
9 ks_sharded/c0-: begin
9 ks_sharded/c0-: delete from `_vt`.dt_state where dtid = 'ks_sharded:c0-:1515392388798209886'
Expand Down
Loading
Loading