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

pgerror: add "initial connection heartbeat failed" to SQL retryable #106547

Closed
wants to merge 1 commit into from
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
1 change: 1 addition & 0 deletions pkg/ccl/serverccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ go_test(
"//pkg/util/log",
"//pkg/util/protoutil",
"//pkg/util/randutil",
"//pkg/util/stop",
"//pkg/util/timeutil",
"@com_github_cockroachdb_datadriven//:datadriven",
"@com_github_cockroachdb_errors//:errors",
Expand Down
45 changes: 45 additions & 0 deletions pkg/ccl/serverccl/server_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"errors"
"fmt"
"io"
"net"
"net/http"
"strings"
"testing"
Expand All @@ -34,6 +35,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/lib/pq"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -432,3 +434,46 @@ func TestSystemConfigWatcherCache(t *testing.T) {
defer leaktest.AfterTest(t)()
systemconfigwatchertest.TestSystemConfigWatcher(t, false /* skipSecondary */)
}

func TestStartTenantWithStaleInstance(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

ctx := context.Background()
tc := serverutils.StartNewTestCluster(t, 1, base.TestClusterArgs{ServerArgs: base.TestServerArgs{
// We need to disable the default test tenant because we're going to
// create our own.
DefaultTestTenant: base.TestTenantDisabled,
}})
defer tc.Stopper().Stop(ctx)

rpcAddr := func() string {
tenantStopper := stop.NewStopper()
defer tenantStopper.Stop(ctx)
server, db := serverutils.StartTenant(t, tc.Server(0), base.TestTenantArgs{
Stopper: tenantStopper,
TenantID: serverutils.TestTenantID(),
},
)
defer db.Close()
return server.RPCAddr()
}()

listener, err := net.Listen("tcp", rpcAddr)
require.NoError(t, err)
defer func() {
_ = listener.Close()
}()

_, db := serverutils.StartTenant(t, tc.Server(0), base.TestTenantArgs{
TenantID: serverutils.TestTenantID(),
})
defer func() {
_ = db.Close()
}()

// Query a table to make sure the tenant is healthy, doesn't really matter
// which table.
_, err = db.Exec("SELECT count(*) FROM system.sqlliveness")
require.NoError(t, err)
}
2 changes: 1 addition & 1 deletion pkg/sql/pgwire/pgerror/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func IsSQLRetryableError(err error) bool {
// here.
errString := FullError(err)
matched, merr := regexp.MatchString(
"(no inbound stream connection|connection reset by peer|connection refused|failed to send RPC|rpc error: code = Unavailable|(^|\\s)EOF|result is ambiguous)",
"(no inbound stream connection|initial connection heartbeat failed|connection reset by peer|connection refused|failed to send RPC|rpc error: code = Unavailable|(^|\\s)EOF|result is ambiguous)",
errString)
if merr != nil {
return false
Expand Down