Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/cockroachdb/apd/v3 v3.2.3
github.com/cockroachdb/errors v1.7.5
github.com/dolthub/dolt/go v0.40.5-0.20260715222552-6bea62fec1d6
github.com/dolthub/dolt/go v0.40.5-0.20260717023913-8de32a8c8d8e
github.com/dolthub/eventsapi_schema v0.0.0-20260715220557-d9b4a1c6b4d4
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.20.1-0.20260715210958-36c4fed9afa6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:I
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo=
github.com/dolthub/dolt-mcp v0.3.4 h1:AyG5cw+fNWXDHXujtQnqUPZrpWtPg6FN6yYtjv1pP44=
github.com/dolthub/dolt-mcp v0.3.4/go.mod h1:bCZ7KHvDYs+M0e+ySgmGiNvLhcwsN7bbf5YCyillLrk=
github.com/dolthub/dolt/go v0.40.5-0.20260715222552-6bea62fec1d6 h1:abnk5UJQMJue6ZHFl4VIOUWSMV3/mjq/a3tAyLhVrFI=
github.com/dolthub/dolt/go v0.40.5-0.20260715222552-6bea62fec1d6/go.mod h1:NeIUHB089JzLdjA37lExTUW0oOj9ck5LPTpRMquVpb4=
github.com/dolthub/dolt/go v0.40.5-0.20260717023913-8de32a8c8d8e h1:Z9v7eg3MNs1OGSngDL/MI2cyC8M6GxUFeXqWYjfCU2k=
github.com/dolthub/dolt/go v0.40.5-0.20260717023913-8de32a8c8d8e/go.mod h1:3y+3STq+7aushqr4sLOW3fzRC+TT1xD0LeaYDbmvaEY=
github.com/dolthub/eventsapi_schema v0.0.0-20260715220557-d9b4a1c6b4d4 h1:0mg9QEFdkkBwJMxvz1tCjHYmfG2iIC6aShj1InDq9/M=
github.com/dolthub/eventsapi_schema v0.0.0-20260715220557-d9b4a1c6b4d4/go.mod h1:SSLraQS/jGLYFgff3vuZ+JbVUct6vyEeMzjLBqWqoyM=
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=
Expand Down
7 changes: 6 additions & 1 deletion integration-tests/go-sql-server-driver/driver/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ var DelvePath string
const TestUserName = "Bats Tests"
const TestEmailAddress = "bats@email.fake"

const ConnectAttempts = 50
// ConnectAttempts and RetrySleepDuration are used by the test driver to retry connections to a doltgres server
// that is starting up. Besides server startup, the retries must also absorb cluster replication being
// eventually consistent: connections default to the "postgres" database, and on a freshly-booted standby
// that database only exists once its first push from the primary lands (which on a slow CI host can take
// many seconds of first-contact setup). ~30 seconds, matching statusEventualConsistencyAttempts.
const ConnectAttempts = 600
const RetrySleepDuration = 50 * time.Millisecond

// EnvDoltgresBinPath is the environment variable used to locate the doltgres
Expand Down
30 changes: 28 additions & 2 deletions integration-tests/go-sql-server-driver/testdef.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"os"
"path/filepath"
"strings"
"sync"
"testing"
"text/template"
Expand Down Expand Up @@ -59,7 +60,11 @@ type Test struct {
// Set this environment variable to effectively disable timeouts for debugging.
const debugEnvKey = "DOLTGRES_SQL_SERVER_TEST_DEBUG"

var timeout = 20 * time.Second
// timeout bounds each individual query in a test. It must comfortably exceed the
// dolt_cluster_ack_writes_timeout_secs values used in the cluster replication tests (60s): a write on the
// primary legitimately blocks for up to that long waiting for standbys to acknowledge replication, e.g.
// when a standby is slow to complete first contact (jwks setup plus create-on-push) on a loaded CI host.
var timeout = 90 * time.Second

func init() {
_, ok := os.LookupEnv(debugEnvKey)
Expand Down Expand Up @@ -629,12 +634,33 @@ func RetryTestRun(t *testing.T, attempts int, test func(TestingT)) {
rtt.try(attempts, test)
}

// statusEventualConsistencyAttempts bounds how long RunQuery waits for a cluster
// replication status query to converge to its expected result.
// Retries are quite forgiving in these tests because the default `postgres` database in most of these tests is never
// written to, which means it get replicated async by a background thread, rather than by a user write.
// At driver.RetrySleepDuration (50ms) per attempt this is roughly 30 seconds, which also makes status
// queries usable as explicit quiesce barriers before graceful role transitions (which have a fixed
// 10-second internal budget for standbys to catch up).
const statusEventualConsistencyAttempts = 600

func RunQuery(t *testing.T, conn *sql.Conn, q driver.Query, ports *DynamicResources) {
RetryTestRun(t, q.RetryAttempts, func(t TestingT) {
attempts := q.RetryAttempts
// Replication status is eventually consistent, so status queries always get at
// least the generous eventual-consistency budget, even if the test set a smaller
// (or no) retry_attempts.
if observesReplicationStatus(q) && attempts < statusEventualConsistencyAttempts {
attempts = statusEventualConsistencyAttempts
}
RetryTestRun(t, attempts, func(t TestingT) {
RunQueryAttempt(t, conn, q, ports)
})
}

// observesReplicationStatus reports whether the query reads the dolt_cluster_status system table
func observesReplicationStatus(q driver.Query) bool {
return q.Query != "" && strings.Contains(strings.ToLower(q.Query), "dolt_cluster_status")
}

func RunQueryAttempt(t TestingT, conn *sql.Conn, q driver.Query, ports *DynamicResources) {
args := make([]any, len(q.Args))
for i := range q.Args {
Expand Down
Loading
Loading