Skip to content

Commit

Permalink
Fix race in combined iterator test (#183)
Browse files Browse the repository at this point in the history
The fetchers may not have started right after the iterator is created.
Interrupt after snapshotter has started.
  • Loading branch information
lyuboxa committed Jul 18, 2024
1 parent 3a618cd commit 46654b2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions source/logrepl/combined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,6 @@ func TestCombinedIterator_Next(t *testing.T) {

expectedRecords := testRecords()

// interrupt repl connection
var terminated bool
is.NoErr(pool.QueryRow(ctx, fmt.Sprintf(
`SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE
query ILIKE '%%CREATE_REPLICATION_SLOT %s%%' and pid <> pg_backend_pid()
`,
table,
)).Scan(&terminated))
is.True(terminated)

// compare snapshot
for id := 1; id < 5; id++ {
t.Run(fmt.Sprint("next_snapshot", id), func(t *testing.T) {
Expand All @@ -194,6 +184,16 @@ func TestCombinedIterator_Next(t *testing.T) {
})
}

// interrupt repl connection
var terminated bool
is.NoErr(pool.QueryRow(ctx, fmt.Sprintf(
`SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE
query ILIKE '%%CREATE_REPLICATION_SLOT %s%%' and pid <> pg_backend_pid()
`,
table,
)).Scan(&terminated))
is.True(terminated)

t.Run("next_cdc_5", func(t *testing.T) {
is := is.New(t)

Expand Down

0 comments on commit 46654b2

Please sign in to comment.