Skip to content

Commit

Permalink
Documentation updates from vitessio/vitess#12239
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Feb 6, 2023
1 parent ac905c3 commit 67e730f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions content/en/docs/16.0/get-started/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ You are now ready to start your first cluster! Open a new terminal window to ens
Start by copying the local examples included with Vitess to your preferred location. For our first example we will deploy a [single unsharded keyspace](../../concepts/keyspace). The file `101_initial_cluster.sh` is for example `1` phase `01`. Lets execute it now:

```sh
mkdir -p ~/my-vitess-example/examples/local
cp -r /usr/local/vitess/examples/local ~/my-vitess-example/examples
cp -r /usr/local/vitess/web ~/my-vitess-example
mkdir -p ~/my-vitess-example/examples
cp -r <vitess source path>/examples ~/my-vitess-example/examples
cp -r <vitess source path>/web ~/my-vitess-example
cd ~/my-vitess-example/examples/local
./101_initial_cluster.sh
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ Start by copying the [`region_sharding` examples](https://github.com/vitessio/vi
included with Vitess to your preferred location and running the `101_initial_cluster.sh` script:

```bash
cp -r <vitess source path>/examples/region_sharding ~/my-vitess-region_sharding-example
cd ~/my-vitess-region_sharding-example
cp -r <vitess source path>/examples ~/my-vitess-example/examples
cp -r <vitess source path>/web ~/my-vitess-example
cd ~/my-vitess-example/examples/region_sharding
./101_initial_cluster.sh
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ As a result we might not even be able to tell the application with some certaint

It is not possible to make this the default behavior in Vitess; i.e. you will have to change your application code to take advantage of this option.

In the [local examples](https://github.com/vitessio/vitess/tree/main/examples/local), we have a script, [`method1.sh`](https://github.com/vitessio/vitess/blob/main/examples/local/vtexplain/atomicity_method1.sh); which tries to use a sample vschema from `vschema.json` and SQL schema in `vschema.sql` to illustrate this method. Let's run this and inspect the output:
In the [examples](https://github.com/vitessio/vitess/tree/main/examples/vtexplain), we have a script, [`atomicity_method1.sh`](https://github.com/vitessio/vitess/tree/main/examples/vtexplain/atomicity_method1.sh); which tries to use a sample vschema from `atomicity_vschema.json` and SQL schema in `atomicity_schema.sql` to illustrate this method. Let's run this and inspect the output:

```sh
$ ./method1.sh
+ vtexplain --vschema-file vschema.json --schema-file schema.sql --shards 4 --sql 'INSERT /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ INTO t1 (c1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);'
+ vtexplain --vschema-file atomicity_vschema.json --schema-file atomicity_schema.sql --shards 4 --sql 'INSERT /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ INTO t1 (c1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);'
----------------------------------------------------------------------
INSERT /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ INTO t1 (c1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20)

Expand All @@ -81,11 +81,11 @@ As can be seen from this output, we just issue all the inserts with the subset o

In certain situations, a schema may be constructed in a fashion where cross-shard writes are very rare (or should not happen). In a situation like this Vitess provides for a transaction mode (set via the MySQL set statement `set transaction_mode = 'single'`) called **SINGLE**. In this transaction mode, any write that needs to span multiple shards will fail with an error. Similarly, any **transactional read** (i.e. using `BEGIN` & `COMMIT`) that spans multiple shards will also get an error.

Here is our example for this case using `vtexplain` and [`method2.sh`](https://github.com/vitessio/vitess/blob/main/examples/local/vtexplain/atomicity_method2.sh):
Here is our example for this case using `vtexplain` and [`atomicity_method2.sh`](https://github.com/vitessio/vitess/tree/main/examples/vtexplain/atomicity_method2.sh):

```sh
$ ./method2.sh
+ vtexplain --vschema-file vschema.json --schema-file schema.sql --shards 4 --sql 'SET transaction_mode="single"; INSERT INTO t1 (c1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);'
+ vtexplain --vschema-file atomicity_vschema.json --schema-file atomicity_schema.sql --shards 4 --sql 'SET transaction_mode="single"; INSERT INTO t1 (c1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);'
E0803 16:54:09.738322 89168 tabletserver.go:1368] unknown error: unsupported query rollback (errno 1105) (sqlstate HY000): Sql: "rollback", BindVars: {}
E0803 16:54:09.738352 89168 tabletserver.go:1368] unknown error: unsupported query rollback (errno 1105) (sqlstate HY000): Sql: "rollback", BindVars: {}
E0803 16:54:09.738431 89168 tabletserver.go:1368] unknown error: unsupported query rollback (errno 1105) (sqlstate HY000): Sql: "rollback", BindVars: {}
Expand All @@ -101,7 +101,7 @@ If we limited ourselves to writes that only target a single one of the multiple

```sh
$ ./method2_working.sh
+ vtexplain --vschema-file vschema.json --schema-file schema.sql --shards 4 --sql 'SET transaction_mode="single"; INSERT INTO t1 (c1) values (10),(14),(15),(16);'
+ vtexplain --vschema-file atomicity_vschema.json --schema-file atomicity_schema.sql --shards 4 --sql 'SET transaction_mode="single"; INSERT INTO t1 (c1) values (10),(14),(15),(16);'
----------------------------------------------------------------------
SET transaction_mode="single"

Expand All @@ -118,7 +118,7 @@ Here is the result if we attempted a transactional read across shards while in `

```sh
$ ./method2_reads.sh
+ vtexplain --vschema-file vschema.json --schema-file schema.sql --shards 4 --sql 'SET transaction_mode="single"; BEGIN; SELECT * from t1; COMMIT;'
+ vtexplain --vschema-file atomicity_vschema.json --schema-file atomicity_schema.sql --shards 4 --sql 'SET transaction_mode="single"; BEGIN; SELECT * from t1; COMMIT;'
E0803 17:00:49.524545 89777 tabletserver.go:1368] unknown error: unsupported query rollback (errno 1105) (sqlstate HY000): Sql: "rollback", BindVars: {}
E0803 17:00:49.524549 89777 tabletserver.go:1368] unknown error: unsupported query rollback (errno 1105) (sqlstate HY000): Sql: "rollback", BindVars: {}
E0803 17:00:49.524581 89777 tabletserver.go:1368] unknown error: unsupported query rollback (errno 1105) (sqlstate HY000): Sql: "rollback", BindVars: {}
Expand All @@ -142,11 +142,11 @@ By default, Vitess employs a default setting for `transaction_mode` of **MULTI**
* As an optimization Phase 1+2 are performed at the same time, see below.
* Because parts of this proceeds serially, the latency of the overall insert is typically proportional to the number of shards that the insert is scattered across.

Let's run our example for this case [`method3.sh`](https://github.com/vitessio/vitess/blob/main/examples/local/vtexplain/atomicity_method3.sh) and inspect the output:
Let's run our example for this case [`atomicity_method3.sh`](https://github.com/vitessio/vitess/tree/main/examples/vtexplain/atomicity_method3.sh) and inspect the output:

```sh
$ ./method3.sh
+ vtexplain --vschema-file vschema.json --schema-file schema.sql --shards 4 --sql 'INSERT INTO t1 (c1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);'
+ vtexplain --vschema-file atomicity_vschema.json --schema-file atomicity_schema.sql --shards 4 --sql 'INSERT INTO t1 (c1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);'
----------------------------------------------------------------------
INSERT INTO t1 (c1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20)

Expand Down

0 comments on commit 67e730f

Please sign in to comment.