forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Brendan Dougherty <[email protected]>
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
_ "vitess.io/vitess/go/vt/vtctl/grpcvtctlclient" | ||
_ "vitess.io/vitess/go/vt/vtgate/grpcvtgateconn" | ||
"vitess.io/vitess/go/vt/vtgate/vtgateconn" | ||
) | ||
|
||
func main() { | ||
ctx := context.Background() | ||
conn, err := vtgateconn.Dial(ctx, "localhost:15991") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer conn.Close() | ||
session := conn.Session("things", nil) | ||
for { | ||
_, err := session.Execute(ctx, "SELECT * FROM things WHERE id = 'fooBARfooBARfooBARfooBARfooBAR'", nil) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Setup | ||
====== | ||
* Edit `go/vt/vtgate/vindexes/unicode.go` to not use a pool (just a single shared `pooledCollator` protected by a mutex) | ||
This ensures that reproduction isn't impacted by the nondeterministic nature of sync.Pool, i.e. https://pkg.go.dev/sync#Pool | ||
> Any item stored in the Pool may be removed automatically at any time without notification. If the Pool holds the only reference when this happens, the item might be deallocated. | ||
* `SKIP_VTADMIN=true ./101_initial_cluster.sh` | ||
* Create a new sharded "things" keyspace: | ||
```bash | ||
source ../common/env.sh | ||
|
||
for i in 300 301 302; do | ||
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh | ||
SHARD=-80 CELL=zone1 KEYSPACE=things TABLET_UID=$i ../common/scripts/vttablet-up.sh | ||
done | ||
|
||
for i in 400 401 402; do | ||
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh | ||
SHARD=80- CELL=zone1 KEYSPACE=things TABLET_UID=$i ../common/scripts/vttablet-up.sh | ||
done | ||
|
||
# set the correct durability policy for the keyspace | ||
vtctldclient --server localhost:15999 SetKeyspaceDurabilityPolicy --durability-policy=semi_sync things || fail "Failed to set keyspace durability policy on the things keyspace" | ||
|
||
for shard in "-80" "80-"; do | ||
# Wait for all the tablets to be up and registered in the topology server | ||
# and for a primary tablet to be elected in the shard and become healthy/serving. | ||
wait_for_healthy_shard things "${shard}" || exit 1 | ||
done | ||
``` | ||
* Create the VSchema: | ||
```bash | ||
vtctldclient ApplyVSchema --vschema ' | ||
{ | ||
"sharded": true, | ||
"vindexes": { | ||
"unicode_loose_md5": { | ||
"type": "unicode_loose_md5" | ||
} | ||
}, | ||
"tables": { | ||
"things": { | ||
"column_vindexes": [ | ||
{ | ||
"column": "id", | ||
"name": "unicode_loose_md5" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
' things || fail "Failed to create vschema in sharded things keyspace" | ||
``` | ||
|
||
* Create the SQL schema: | ||
```bash | ||
vtctldclient ApplySchema --sql ' | ||
create table if not exists things( | ||
id varchar(255) not null, | ||
primary key(id) | ||
) ENGINE=InnoDB; | ||
' things || fail "Failed to create tables in the things keyspace" | ||
``` | ||
|
||
* Check vtgate memory use | ||
``` | ||
cat /proc/$(cat /tmp/vtdataroot/tmp/vtgate.pid)/status | grep RSS | ||
``` | ||
|
||
* Run lots of queries | ||
```bash | ||
go run run_queries.go | ||
``` | ||
|
||
* Keep checking memory use |