Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added go/cmd/vtgateproxy/vtgateproxy
Binary file not shown.
1 change: 1 addition & 0 deletions go/flags/endtoend/vtbench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ Flags:
--vtgate-grpc-ca string the server ca to use to validate servers when connecting
--vtgate-grpc-cert string the cert to use to connect
--vtgate-grpc-crl string the server crl to use to validate server certificates when connecting
--vtgate-grpc-fail-fast whether to enable grpc fail fast when communicating with vtgate
--vtgate-grpc-key string the key to use to connect
--vtgate-grpc-server-name string the server name to use to validate server certificate
1 change: 1 addition & 0 deletions go/flags/endtoend/vtclient.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Flags:
--vtgate-grpc-ca string the server ca to use to validate servers when connecting
--vtgate-grpc-cert string the cert to use to connect
--vtgate-grpc-crl string the server crl to use to validate server certificates when connecting
--vtgate-grpc-fail-fast whether to enable grpc fail fast when communicating with vtgate
--vtgate-grpc-key string the key to use to connect
--vtgate-grpc-server-name string the server name to use to validate server certificate
--vtgate_protocol string how to talk to vtgate (default "grpc")
1 change: 1 addition & 0 deletions go/flags/endtoend/vtcombo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ Flags:
--vtgate-grpc-ca string the server ca to use to validate servers when connecting
--vtgate-grpc-cert string the cert to use to connect
--vtgate-grpc-crl string the server crl to use to validate server certificates when connecting
--vtgate-grpc-fail-fast whether to enable grpc fail fast when communicating with vtgate
--vtgate-grpc-key string the key to use to connect
--vtgate-grpc-server-name string the server name to use to validate server certificate
--vttablet-skip-buildinfo-tags string comma-separated list of buildinfo tags to skip from merging with --init-tags. each tag is either an exact match or a regular expression of the form '/regexp/'. (default "/.*/")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vttestserver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Flags:
--vtgate-grpc-ca string the server ca to use to validate servers when connecting
--vtgate-grpc-cert string the cert to use to connect
--vtgate-grpc-crl string the server crl to use to validate server certificates when connecting
--vtgate-grpc-fail-fast whether to enable grpc fail fast when communicating with vtgate
--vtgate-grpc-key string the key to use to connect
--vtgate-grpc-server-name string the server name to use to validate server certificate
--xbstream-restore-flags string Flags to pass to xbstream command during restore. These should be space separated and will be added to the end of the command. These need to match the ones used for backup e.g. --compress / --decompress, --encrypt / --decrypt
Expand Down
18 changes: 10 additions & 8 deletions go/vt/vtgate/grpcvtgateconn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ import (
)

var (
cert string
key string
ca string
crl string
name string
cert string
key string
ca string
crl string
name string
failFast bool
)

func init() {
Expand All @@ -56,16 +57,17 @@ func init() {
"vtctl",
"vttestserver",
} {
servenv.OnParseFor(cmd, registerFlags)
servenv.OnParseFor(cmd, RegisterFlags)
}
}

func registerFlags(fs *pflag.FlagSet) {
func RegisterFlags(fs *pflag.FlagSet) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for making this public? It doesn't seem necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is -- As I mentioned in the related issue description, the main reason for these changes is our "vtgateproxy" binary which in essence is a mash-up of a mysql server module to accept connections from our app, and the vtgate grpc interface which we use to route those queries.

To make that work, we want to be able to call this function to be able to register flags as part of the app initialization since we can't put "vtgateproxy" in the list of explicitly opted-in binaries above.

utils.SetFlagStringVar(fs, &cert, "vtgate-grpc-cert", "", "the cert to use to connect")
utils.SetFlagStringVar(fs, &key, "vtgate-grpc-key", "", "the key to use to connect")
utils.SetFlagStringVar(fs, &ca, "vtgate-grpc-ca", "", "the server ca to use to validate servers when connecting")
utils.SetFlagStringVar(fs, &crl, "vtgate-grpc-crl", "", "the server crl to use to validate server certificates when connecting")
utils.SetFlagStringVar(fs, &name, "vtgate-grpc-server-name", "", "the server name to use to validate server certificate")
utils.SetFlagBoolVar(fs, &failFast, "vtgate-grpc-fail-fast", false, "whether to enable grpc fail fast when communicating with vtgate")
}

type vtgateConn struct {
Expand All @@ -87,7 +89,7 @@ func Dial(opts ...grpc.DialOption) vtgateconn.DialerFunc {

opts = append(opts, opt)

cc, err := grpcclient.DialContext(ctx, address, grpcclient.FailFast(false), opts...)
cc, err := grpcclient.DialContext(ctx, address, grpcclient.FailFast(failFast), opts...)
if err != nil {
return nil, err
}
Expand Down
7 changes: 6 additions & 1 deletion go/vt/vtgate/vtgateconn/vtgateconn.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Vitess Authors.
Copyright 2024 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -171,6 +171,11 @@ func (sn *VTGateSession) Prepare(ctx context.Context, query string) ([]*querypb.
return fields, paramsCount, err
}

// CloseSession closes the session provided by rolling back any active transaction.
func (sn *VTGateSession) CloseSession(ctx context.Context) error {
return sn.impl.CloseSession(ctx, sn.session)
}

Copy link
Member

Choose a reason for hiding this comment

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

We should have tests for this to describe why this is needed. We do run stuff like https://go.dev/blog/deadcode on the codebase to clean up unused parts and it would identify this and we're remove it again.

Making sure it's at least tested and described in the tests why it's needed would be required to at least try to avoid it being removed again in the future.

Copy link
Member Author

@demmer demmer Sep 3, 2025

Choose a reason for hiding this comment

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

OK. I added a test for this to the framework.

Took a bit of wrangling for the existing tests and the fake server to track "active txns" to make this work, but it is now tested.

//
// The rest of this file is for the protocol implementations.
//
Expand Down
Loading