diff --git a/contrib/test_decoding/expected/invalidation_distribution.out b/contrib/test_decoding/expected/invalidation_distribution.out
index 9fe87e2cda9..ae53b1e61de 100644
--- a/contrib/test_decoding/expected/invalidation_distribution.out
+++ b/contrib/test_decoding/expected/invalidation_distribution.out
@@ -1,4 +1,4 @@
-Parsed test spec with 5 sessions
+Parsed test spec with 3 sessions
 
 starting permutation: s1_insert_tbl1 s1_begin s1_insert_tbl1 s2_alter_pub_add_tbl s1_commit s1_insert_tbl1 s2_get_binary_changes
 step s1_insert_tbl1: INSERT INTO tbl1 (val1, val2) VALUES (1, 1);
@@ -19,22 +19,19 @@ stop
 (1 row)
 
 
-starting permutation: s3i1 s4b s4i1 s5b s5i1 s3a s4i2 s4c s5c s4i3 s3i2 s3_get_binary_changes
-step s3i1: INSERT INTO tbl1 (val1, val2) VALUES (1, 1);
-step s4b: BEGIN;
-step s4i1: INSERT INTO tbl1 (val1, val2) VALUES (2, 2);
-step s5b: BEGIN;
-step s5i1: INSERT INTO tbl1 (val1, val2) VALUES (3, 3);
-step s3a: ALTER PUBLICATION pub ADD TABLE tbl1;
-step s4i2: INSERT INTO tbl1 (val1, val2) VALUES (4, 4);
-step s4c: COMMIT;
-step s5c: COMMIT;
-step s4i3: INSERT INTO tbl1 (val1, val2) VALUES (5, 5);
-step s3i2: INSERT INTO tbl1 (val1, val2) VALUES (6, 6);
-step s3_get_binary_changes: SELECT count(data) FROM pg_logical_slot_get_binary_changes('isolation_slot', NULL, NULL, 'proto_version', '4', 'publication_names', 'pub') WHERE get_byte(data, 0) = 73;
+starting permutation: s1_begin s1_insert_tbl1 s3_begin s3_insert_tbl1 s2_alter_pub_add_tbl s1_insert_tbl1 s1_commit s3_commit s2_get_binary_changes
+step s1_begin: BEGIN;
+step s1_insert_tbl1: INSERT INTO tbl1 (val1, val2) VALUES (1, 1);
+step s3_begin: BEGIN;
+step s3_insert_tbl1: INSERT INTO tbl1 (val1, val2) VALUES (2, 2);
+step s2_alter_pub_add_tbl: ALTER PUBLICATION pub ADD TABLE tbl1;
+step s1_insert_tbl1: INSERT INTO tbl1 (val1, val2) VALUES (1, 1);
+step s1_commit: COMMIT;
+step s3_commit: COMMIT;
+step s2_get_binary_changes: SELECT count(data) FROM pg_logical_slot_get_binary_changes('isolation_slot', NULL, NULL, 'proto_version', '4', 'publication_names', 'pub') WHERE get_byte(data, 0) = 73;
 count
 -----
-    3
+    1
 (1 row)
 
 ?column?
diff --git a/contrib/test_decoding/specs/invalidation_distribution.spec b/contrib/test_decoding/specs/invalidation_distribution.spec
index 1a90453f1ea..f73cf6e482a 100644
--- a/contrib/test_decoding/specs/invalidation_distribution.spec
+++ b/contrib/test_decoding/specs/invalidation_distribution.spec
@@ -29,25 +29,15 @@ step "s2_alter_pub_add_tbl" { ALTER PUBLICATION pub ADD TABLE tbl1; }
 step "s2_get_binary_changes" { SELECT count(data) FROM pg_logical_slot_get_binary_changes('isolation_slot', NULL, NULL, 'proto_version', '4', 'publication_names', 'pub') WHERE get_byte(data, 0) = 73; }
 
 session "s3"
-step "s3i1" { INSERT INTO tbl1 (val1, val2) VALUES (1, 1);}
-step "s3a" { ALTER PUBLICATION pub ADD TABLE tbl1; }
-step "s3i2" { INSERT INTO tbl1 (val1, val2) VALUES (6, 6); }
-step "s3_get_binary_changes" { SELECT count(data) FROM pg_logical_slot_get_binary_changes('isolation_slot', NULL, NULL, 'proto_version', '4', 'publication_names', 'pub') WHERE get_byte(data, 0) = 73; }
-
-session "s4"
-step "s4b" { BEGIN; }
-step "s4i1" { INSERT INTO tbl1 (val1, val2) VALUES (2, 2);}
-step "s4i2" { INSERT INTO tbl1 (val1, val2) VALUES (4, 4); }
-step "s4c" { COMMIT; }
-step "s4i3" { INSERT INTO tbl1 (val1, val2) VALUES (5, 5); }
-
-session "s5"
-step "s5b" { BEGIN; }
-step "s5i1" { INSERT INTO tbl1 (val1, val2) VALUES (3, 3); }
-step "s5c" { COMMIT; }
+setup { SET synchronous_commit=on; }
+step "s3_begin" { BEGIN; }
+step "s3_insert_tbl1" { INSERT INTO tbl1 (val1, val2) VALUES (2, 2); }
+step "s3_commit" { COMMIT; }
 
 # Expect to get one insert change. LOGICAL_REP_MSG_INSERT = 'I'
 permutation "s1_insert_tbl1" "s1_begin" "s1_insert_tbl1" "s2_alter_pub_add_tbl" "s1_commit" "s1_insert_tbl1" "s2_get_binary_changes"
 
-# Expect to get three insert changes with LOGICAL_REP_MSG_INSERT = 'I' that happened after the table tbl1 is added to the publication.
-permutation "s3i1" "s4b" "s4i1" "s5b" "s5i1" "s3a" "s4i2" "s4c" "s5c" "s4i3" "s3i2" "s3_get_binary_changes"
+# Expect to get one insert change with LOGICAL_REP_MSG_INSERT = 'I' from
+# the second "s1_insert_tbl1" executed after adding the table tbl1 the
+# publication in "s2_alter_pub_add_tbl".
+permutation "s1_begin" "s1_insert_tbl1" "s3_begin" "s3_insert_tbl1" "s2_alter_pub_add_tbl" "s1_insert_tbl1" "s1_commit" "s3_commit" "s2_get_binary_changes"
