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

[release-15.0] Fix: TabletServer ReserveBeginExecute to return transaction ID on error (#13193) #13196

Merged
merged 2 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
68 changes: 41 additions & 27 deletions go/test/endtoend/vtgate/partialfailure/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import (
"os"
"testing"

"vitess.io/vitess/go/test/endtoend/utils"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/utils"
)

var (
Expand Down Expand Up @@ -99,39 +98,54 @@ CREATE TABLE test_vdx (
`
)

var enableSettingsPool bool

func TestMain(m *testing.M) {
defer cluster.PanicHandler(nil)
flag.Parse()

exitCode := func() int {
clusterInstance = cluster.NewCluster(cell, hostname)
defer clusterInstance.Teardown()
code := runAllTests(m)
if code != 0 {
os.Exit(code)
}

// Start topo server
if err := clusterInstance.StartTopo(); err != nil {
return 1
}
println("running with settings pool enabled")
// run again with settings pool enabled.
enableSettingsPool = true
code = runAllTests(m)
os.Exit(code)
}

// Start keyspace
keyspace := &cluster.Keyspace{
Name: keyspaceName,
SchemaSQL: sqlSchema,
VSchema: vSchema,
}
if err := clusterInstance.StartKeyspace(*keyspace, []string{"-40", "40-80", "80-c0", "c0-"}, 0, false); err != nil {
func runAllTests(m *testing.M) int {
clusterInstance = cluster.NewCluster(cell, hostname)
defer clusterInstance.Teardown()

return 1
}
// Start topo server
if err := clusterInstance.StartTopo(); err != nil {
return 1
}

// Start vtgate
clusterInstance.VtGateExtraArgs = append(clusterInstance.VtGateExtraArgs, "--planner-version", "Gen4Fallback")
if err := clusterInstance.StartVtgate(); err != nil {
return 1
}
vtParams = clusterInstance.GetVTParams(keyspaceName)
return m.Run()
}()
os.Exit(exitCode)
// Start keyspace
keyspace := &cluster.Keyspace{
Name: keyspaceName,
SchemaSQL: sqlSchema,
VSchema: vSchema,
}
if enableSettingsPool {
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, "--queryserver-enable-settings-pool")
}
if err := clusterInstance.StartKeyspace(*keyspace, []string{"-40", "40-80", "80-c0", "c0-"}, 0, false); err != nil {

return 1
}

// Start vtgate
clusterInstance.VtGateExtraArgs = append(clusterInstance.VtGateExtraArgs, "--planner-version", "Gen4Fallback")
if err := clusterInstance.StartVtgate(); err != nil {
return 1
}
vtParams = clusterInstance.GetVTParams(keyspaceName)
return m.Run()
}

func testAllModes(t *testing.T, stmts func(conn *mysql.Conn)) {
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/grpcqueryservice/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ func (q *query) ReserveBeginExecute(ctx context.Context, request *querypb.Reserv
)
state, result, err := q.server.ReserveBeginExecute(ctx, request.Target, request.PreQueries, request.PostBeginQueries, request.Query.Sql, request.Query.BindVariables, request.Options)
if err != nil {
// if we have a valid reservedID, return the error in-band
if state.ReservedID != 0 {
// if we have a valid reservedID or transactionID, return the error in-band
if state.TransactionID != 0 || state.ReservedID != 0 {
return &querypb.ReserveBeginExecuteResponse{
Error: vterrors.ToVTRPC(err),
TransactionId: state.TransactionID,
Expand Down