From bf99a048a77b312e7cae16bc5e940f9255241dba Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 2 Mar 2022 13:00:51 +0300
Subject: [PATCH v2] Use synchronous_commit=on in test_setup.sql

Starting from cc50080a82 create_index test started to fail when there is a
synchronous_commit=off setting in postgresql.conf. As pointed out by Andres,
this is because synchronous_commit affects the time when the hint bits are
set. This in its turn affects the choice of the query plans.

This patch sets synchronous_commit to `on` in test_setup.sql. It's not very
satisfying but we don't immediately see what else can be done.

Authors: Andres Freund, Aleksander Alekseev
Discussion: https://www.postgresql.org/message-id/flat/CAJ7c6TPJNof1Q+vJsy3QebgbPgXdu2ErPvYkBdhD6_Ckv5EZRg@mail.gmail.com
---
 src/test/regress/expected/test_setup.out | 7 +++++++
 src/test/regress/sql/test_setup.sql      | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/src/test/regress/expected/test_setup.out b/src/test/regress/expected/test_setup.out
index 98e08cb6eb..e667412fd4 100644
--- a/src/test/regress/expected/test_setup.out
+++ b/src/test/regress/expected/test_setup.out
@@ -7,6 +7,13 @@
 \getenv dlsuffix PG_DLSUFFIX
 \set regresslib :libdir '/regress' :dlsuffix
 --
+-- synchronous_commit setting affects the time when hint bits are set which
+-- in its turn has an effect on the query plans. This means that in the
+-- general case we can't guarantee that all the tests will pass regardless of
+-- synchronous_commit value in postgresql.conf.
+--
+SET synchronous_commit = on;
+--
 -- Postgres formerly made the public schema read/write by default,
 -- and most of the core regression tests still expect that.
 --
diff --git a/src/test/regress/sql/test_setup.sql b/src/test/regress/sql/test_setup.sql
index d0a73c473d..ea2ac22b52 100644
--- a/src/test/regress/sql/test_setup.sql
+++ b/src/test/regress/sql/test_setup.sql
@@ -9,6 +9,14 @@
 
 \set regresslib :libdir '/regress' :dlsuffix
 
+--
+-- synchronous_commit setting affects the time when hint bits are set which
+-- in its turn has an effect on the query plans. This means that in the
+-- general case we can't guarantee that all the tests will pass regardless of
+-- synchronous_commit value in postgresql.conf.
+--
+SET synchronous_commit = on;
+
 --
 -- Postgres formerly made the public schema read/write by default,
 -- and most of the core regression tests still expect that.
-- 
2.35.1

