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

Flaky test debugging #14746

Closed
Closed
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
2 changes: 1 addition & 1 deletion go/mysql/flavor_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (mysqlFlavor) waitUntilPositionCommand(ctx context.Context, pos Position) (
}
}

return fmt.Sprintf("SELECT WAIT_FOR_EXECUTED_GTID_SET('%s', %v)", pos, timeoutSeconds), nil
return fmt.Sprintf("SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('%s', %v)", pos, timeoutSeconds), nil
}

// readBinlogEvent is part of the Flavor interface.
Expand Down
39 changes: 39 additions & 0 deletions go/test/endtoend/cluster/mysqlctld_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import (
"os/exec"
"path"
"strings"
"testing"
"time"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/vt/log"
)
Expand Down Expand Up @@ -150,6 +153,42 @@ func (mysqlctld *MysqlctldProcess) CleanupFiles(tabletUID int) {
os.RemoveAll(path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tabletUID)))
}

func PrintFiles(t *testing.T, tabletUID int, files ...string) {
dir := path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tabletUID))
var directories []string
directories = append(directories, dir)

for len(directories) > 0 {
dir = directories[0]
directories = directories[1:]
entries, err := os.ReadDir(dir)
require.NoError(t, err)
for _, entry := range entries {
name := path.Join(dir, entry.Name())
if entry.IsDir() {
directories = append(directories, name)
continue
}
if len(files) != 0 {
fileFound := false
for _, file := range files {
if strings.EqualFold(entry.Name(), file) {
fileFound = true
break
}
}
if !fileFound {
continue
}
}
res, err := os.ReadFile(name)
require.NoError(t, err)
log.Errorf("READING FILE - %v", name)
log.Errorf("%v", string(res))
}
}
}

// MysqlCtldProcessInstance returns a Mysqlctld handle for mysqlctld process
// configured with the given Config.
func MysqlCtldProcessInstance(tabletUID int, mySQLPort int, tmpDirectory string) *MysqlctldProcess {
Expand Down
1 change: 1 addition & 0 deletions go/test/endtoend/mysqlctld/mysqlctld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func TestRestart(t *testing.T) {
defer cluster.PanicHandler(t)
err := primaryTablet.MysqlctldProcess.Stop()
require.Nil(t, err)
cluster.PrintFiles(t, primaryTablet.TabletUID, "error.log")
primaryTablet.MysqlctldProcess.CleanupFiles(primaryTablet.TabletUID)
err = primaryTablet.MysqlctldProcess.Start()
require.Nil(t, err)
Expand Down
Loading