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

Update the vstream doc in v17.0 #1410

Merged
merged 8 commits into from
Mar 16, 2023
51 changes: 51 additions & 0 deletions content/en/docs/17.0/reference/vreplication/vstream.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ The keyspace, shard, and GTID position list to start streaming from. If no `Shar
then a [table copy phase](https://github.com/vitessio/vitess/issues/6277) will be initiated for the tables matched
by the provided [filter](#filter) on the given shard.

If the `ShardGtid.Shard` value is omitted, this means that all shards in the keyspace specified in the `ShardGtid.Keyspace` value are included.
Additionally, if the `ShardGtid.Keyspace` value has a `/` prefix, you can use regular expressions such as `/.*` to include all keyspaces.

#### Filter

**Type** [Filter](https://pkg.go.dev/vitess.io/vitess/go/vt/proto/binlogdata#Filter)\
Expand Down Expand Up @@ -197,6 +200,54 @@ for {
...
```

</br>
#### Copy All Tables From All Shards in the `ks` Keyspace
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Netlify wants an empty line between these two. Sorry, I didn't realize that.


Below is a snippet in Go that demonstrates how to copy from all shards by omitting `ShardGtid.Shard`:

```go
vgtid := &binlogdatapb.VGtid{
ShardGtids: []*binlogdatapb.ShardGtid{{
Keyspace: "ks",
Gtid: "",
}},
}
filter := &binlogdatapb.Filter{
Rules: []*binlogdatapb.Rule{{
Match: "/.*",
}},
}
flags := &vtgatepb.VStreamFlags{}
reader, err := gconn.VStream(ctx, topodatapb.TabletType_PRIMARY, vgtid, filter, flags)
```

</br>
#### Copy All Tables From All Shards in All Keyspaces

Below is a snippet in Go that demonstrates how to copy from all keyspaces by specifying `/.*` as the value for `ShardGtid.Keyspace`:

```go
vgtid := &binlogdatapb.VGtid{
ShardGtids: []*binlogdatapb.ShardGtid{{
Keyspace: "/.*",
Gtid: "",
}},
}
filter := &binlogdatapb.Filter{
Rules: []*binlogdatapb.Rule{{
Match: "/.*",
}},
}
flags := &vtgatepb.VStreamFlags{}
reader, err := gconn.VStream(ctx, topodatapb.TabletType_PRIMARY, vgtid, filter, flags)
```

</br>
{{< warning >}}
yoheimuta marked this conversation as resolved.
Show resolved Hide resolved
Copying from all keyspaces can generate a significant amount of load and potentially impact production traffic.
Therefore, please exercise caution when using regular expressions in production.
{{< /warning >}}

## Debugging

There is also an SQL interface that can be used for testing and debugging from a `vtgate`. Here's an example:
Expand Down