diff --git a/content/en/docs/17.0/reference/vreplication/vstream.md b/content/en/docs/17.0/reference/vreplication/vstream.md index 085c6b637..0e049b469 100644 --- a/content/en/docs/17.0/reference/vreplication/vstream.md +++ b/content/en/docs/17.0/reference/vreplication/vstream.md @@ -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)\ @@ -197,6 +200,56 @@ for { ... ``` +
+ +#### Copy All Tables From All Shards in the `ks` Keyspace + +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) +``` + +
+ +#### 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) +``` + +
+{{< warning >}} +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: