Skip to content

Commit

Permalink
Add reproduction steps
Browse files Browse the repository at this point in the history
Signed-off-by: Brendan Dougherty <[email protected]>
  • Loading branch information
brendar committed Nov 22, 2023
1 parent 9a6f526 commit 2b6fb4b
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/local/run_queries.go
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)
}
}
}
75 changes: 75 additions & 0 deletions examples/local/vtgate_unicode_vindex_memory_leak.md
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

0 comments on commit 2b6fb4b

Please sign in to comment.