Skip to content

VReplication: Improve error handling in VTGate VStreams #17558

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

Merged
merged 8 commits into from
Feb 11, 2025
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
19 changes: 11 additions & 8 deletions go/test/endtoend/vreplication/vstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"strings"
"sync"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -76,11 +77,13 @@ func testVStreamWithFailover(t *testing.T, failover bool) {
}},
}
flags := &vtgatepb.VStreamFlags{HeartbeatInterval: 3600}
done := false
done := atomic.Bool{}
done.Store(false)

// don't insert while PRS is going on
var insertMu sync.Mutex
stopInserting := false
stopInserting := atomic.Bool{}
stopInserting.Store(false)
id := 0

vtgateConn := vc.GetVTGateConn(t)
Expand All @@ -89,7 +92,7 @@ func testVStreamWithFailover(t *testing.T, failover bool) {
// first goroutine that keeps inserting rows into table being streamed until some time elapses after second PRS
go func() {
for {
if stopInserting {
if stopInserting.Load() {
return
}
insertMu.Lock()
Expand Down Expand Up @@ -121,7 +124,7 @@ func testVStreamWithFailover(t *testing.T, failover bool) {
log.Infof("%s:: remote error: %v", time.Now(), err)
}

if done {
if done.Load() {
return
}
}
Expand Down Expand Up @@ -153,12 +156,12 @@ func testVStreamWithFailover(t *testing.T, failover bool) {
require.NoError(t, err)
}
time.Sleep(100 * time.Millisecond)
stopInserting = true
time.Sleep(2 * time.Second)
done = true
stopInserting.Store(true)
time.Sleep(10 * time.Second) // Give the vstream plenty of time to catchup
done.Store(true)
}

if done {
if done.Load() {
break
}
}
Expand Down
Loading
Loading