From 46654b2e077e35955f4bfbf86fab98a8dc813c79 Mon Sep 17 00:00:00 2001 From: Lyubo Kamenov Date: Thu, 18 Jul 2024 18:08:28 -0400 Subject: [PATCH] Fix race in combined iterator test (#183) The fetchers may not have started right after the iterator is created. Interrupt after snapshotter has started. --- source/logrepl/combined_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/logrepl/combined_test.go b/source/logrepl/combined_test.go index 4abca0d..6e1b5ec 100644 --- a/source/logrepl/combined_test.go +++ b/source/logrepl/combined_test.go @@ -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) { @@ -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)