agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH] Fix calculation base of WAL recycling
12+ messages / 3 participants
[nested] [flat]

* [PATCH] Fix calculation base of WAL recycling
@ 2018-07-19 03:13 Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Kyotaro Horiguchi @ 2018-07-19 03:13 UTC (permalink / raw)

The commit 4b0d28de06 removed the prior checkpoint and related things
but that leaves WAL recycling based on the prior checkpoint. This
makes max_wal_size and min_wal_size work incorrectly. This patch makes
WAL recycling be based on the last checkpoint.
---
 src/backend/access/transam/xlog.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 4049deb968..d7a61af8f1 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2287,7 +2287,7 @@ assign_checkpoint_completion_target(double newval, void *extra)
  * XLOG segments? Returns the highest segment that should be preallocated.
  */
 static XLogSegNo
-XLOGfileslop(XLogRecPtr PriorRedoPtr)
+XLOGfileslop(XLogRecPtr RedoRecPtr)
 {
 	XLogSegNo	minSegNo;
 	XLogSegNo	maxSegNo;
@@ -2299,9 +2299,9 @@ XLOGfileslop(XLogRecPtr PriorRedoPtr)
 	 * correspond to. Always recycle enough segments to meet the minimum, and
 	 * remove enough segments to stay below the maximum.
 	 */
-	minSegNo = PriorRedoPtr / wal_segment_size +
+	minSegNo = RedoRecPtr / wal_segment_size +
 		ConvertToXSegs(min_wal_size_mb, wal_segment_size) - 1;
-	maxSegNo = PriorRedoPtr / wal_segment_size +
+	maxSegNo = RedoRecPtr / wal_segment_size +
 		ConvertToXSegs(max_wal_size_mb, wal_segment_size) - 1;
 
 	/*
@@ -2316,7 +2316,7 @@ XLOGfileslop(XLogRecPtr PriorRedoPtr)
 	/* add 10% for good measure. */
 	distance *= 1.10;
 
-	recycleSegNo = (XLogSegNo) ceil(((double) PriorRedoPtr + distance) /
+	recycleSegNo = (XLogSegNo) ceil(((double) RedoRecPtr + distance) /
 									wal_segment_size);
 
 	if (recycleSegNo < minSegNo)
@@ -3896,12 +3896,12 @@ RemoveTempXlogFiles(void)
 /*
  * Recycle or remove all log files older or equal to passed segno.
  *
- * endptr is current (or recent) end of xlog, and PriorRedoRecPtr is the
- * redo pointer of the previous checkpoint. These are used to determine
+ * endptr is current (or recent) end of xlog, and RedoRecPtr is the
+ * redo pointer of the last checkpoint. These are used to determine
  * whether we want to recycle rather than delete no-longer-wanted log files.
  */
 static void
-RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
+RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
 {
 	DIR		   *xldir;
 	struct dirent *xlde;
@@ -3944,7 +3944,7 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
 				/* Update the last removed location in shared memory first */
 				UpdateLastRemovedPtr(xlde->d_name);
 
-				RemoveXlogFile(xlde->d_name, PriorRedoPtr, endptr);
+				RemoveXlogFile(xlde->d_name, RedoRecPtr, endptr);
 			}
 		}
 	}
@@ -4006,9 +4006,11 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI)
 			 * remove it yet. It should be OK to remove it - files that are
 			 * not part of our timeline history are not required for recovery
 			 * - but seems safer to let them be archived and removed later.
+			 * Here, switchpoint is a good approximate of RedoRecPtr for
+			 * RemoveXlogFile since we have just done timeline switching.
 			 */
 			if (!XLogArchiveIsReady(xlde->d_name))
-				RemoveXlogFile(xlde->d_name, InvalidXLogRecPtr, switchpoint);
+				RemoveXlogFile(xlde->d_name, switchpoint, switchpoint);
 		}
 	}
 
@@ -4018,14 +4020,12 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI)
 /*
  * Recycle or remove a log file that's no longer needed.
  *
- * endptr is current (or recent) end of xlog, and PriorRedoRecPtr is the
- * redo pointer of the previous checkpoint. These are used to determine
+ * endptr is current (or recent) end of xlog, and RedoRecPtr is the
+ * redo pointer of the last checkpoint. These are used to determine
  * whether we want to recycle rather than delete no-longer-wanted log files.
- * If PriorRedoRecPtr is not known, pass invalid, and the function will
- * recycle, somewhat arbitrarily, 10 future segments.
  */
 static void
-RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
+RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
 {
 	char		path[MAXPGPATH];
 #ifdef WIN32
@@ -4039,10 +4039,7 @@ RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
 	 * Initialize info about where to try to recycle to.
 	 */
 	XLByteToSeg(endptr, endlogSegNo, wal_segment_size);
-	if (PriorRedoPtr == InvalidXLogRecPtr)
-		recycleSegNo = endlogSegNo + 10;
-	else
-		recycleSegNo = XLOGfileslop(PriorRedoPtr);
+	recycleSegNo = XLOGfileslop(RedoRecPtr);
 
 	snprintf(path, MAXPGPATH, XLOGDIR "/%s", segname);
 
@@ -9057,7 +9054,7 @@ CreateCheckPoint(int flags)
 		XLByteToSeg(RedoRecPtr, _logSegNo, wal_segment_size);
 		KeepLogSeg(recptr, &_logSegNo);
 		_logSegNo--;
-		RemoveOldXlogFiles(_logSegNo, PriorRedoPtr, recptr);
+		RemoveOldXlogFiles(_logSegNo, RedoRecPtr, recptr);
 	}
 
 	/*
@@ -9410,7 +9407,7 @@ CreateRestartPoint(int flags)
 		if (RecoveryInProgress())
 			ThisTimeLineID = replayTLI;
 
-		RemoveOldXlogFiles(_logSegNo, PriorRedoPtr, endptr);
+		RemoveOldXlogFiles(_logSegNo, RedoRecPtr, endptr);
 
 		/*
 		 * Make more log segments if needed.  (Do this after recycling old log
-- 
2.16.3


----Next_Part(Mon_Jul_23_13_57_48_2018_127)----





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 8/8] vcregress: run alltaptests in parallel
@ 2022-01-18 23:48 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-01-18 23:48 UTC (permalink / raw)

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl

Should pass the srcdir to all taptests, or go back to writing the results to
tmp_check ?

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pgbench/t/002_pgbench_no_server.pl       |  4 ++--
 .../libpq_pipeline/t/001_libpq_pipeline.pl       |  5 ++++-
 src/test/recovery/t/027_stream_regress.pl        |  4 ++--
 src/tools/msvc/vcregress.pl                      | 16 +++++-----------
 4 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index acad19edd0c..84e36dcd3fe 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
index 0c164dcaba5..facfec5cad4 100644
--- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
+++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
@@ -49,7 +49,10 @@ for my $testname (@tests)
 		my $expected;
 		my $result;
 
-		$expected = slurp_file_eval("traces/$testname.trace");
+		# Hack to allow TESTDIR=. during parallel tap tests
+		my $inputdir = "$ENV{'TESTDIR'}/src/test/modules/libpq_pipeline";
+		$inputdir = "$ENV{'TESTDIR'}" if ! -e $inputdir;
+		$expected = slurp_file_eval("$inputdir/traces/$testname.trace");
 		next unless $expected ne "";
 		$result = slurp_file_eval($traceout);
 		next unless $result ne "";
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index c0aae707ea1..4b84e3e78f5 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -58,9 +58,9 @@ system_or_bail($ENV{PG_REGRESS} . " $extra_opts " .
 			   "--bindir= " .
 			   "--host=" . $node_primary->host . " " .
 			   "--port=" . $node_primary->port . " " .
-			   "--schedule=../regress/parallel_schedule " .
+			   "--schedule=\"$dlpath/parallel_schedule\" " .
 			   "--max-concurrent-tests=20 " .
-			   "--inputdir=../regress " .
+			   "--inputdir=\"$dlpath\" " .
 			   "--outputdir=\"$outputdir\"");
 
 # Clobber all sequences with their next value, so that we don't have
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 4572db8eca4..b178713b911 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -299,8 +299,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -314,15 +312,11 @@ sub alltaptests
 		},
 		@top_dir);
 
-	$ENV{REGRESS_OUTPUTDIR} = "$topdir/src/test/recovery/tmp_check";
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for good performance
+	$ENV{REGRESS_OUTPUTDIR} = "$topdir/src/test/recovery/tmp_check"; # For recovery check
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--4e5ZDkbgLEOfWmLx--





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 14/23] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

XX-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pgbench/t/002_pgbench_no_server.pl |  4 ++--
 src/tools/msvc/vcregress.pl                | 14 ++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index 50bde7dd0fc..bbbb49bb23d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 5dcc3419ad7..49168e298ac 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -328,8 +328,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -343,14 +341,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for better performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--tKkaNMvYmhQvRCRK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0015-another-way-to-install-uri_regress-testclient.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 10/19] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

ci-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pg_upgrade/t/002_pg_upgrade.pl             |  2 +-
 src/bin/pgbench/t/002_pgbench_no_server.pl         |  4 ++--
 .../modules/libpq_pipeline/t/001_libpq_pipeline.pl |  3 ++-
 src/test/modules/test_misc/t/003_check_guc.pl      |  2 +-
 src/test/recovery/t/027_stream_regress.pl          |  5 +++--
 src/tools/msvc/vcregress.pl                        | 14 ++++----------
 6 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 75ac768a96e..3f8fc986e72 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -60,7 +60,7 @@ $oldnode->init(extra => [ '--wal-segsize', '1', '--allow-group-access' ]);
 $oldnode->start;
 
 # The default location of the source code is the root of this directory.
-my $srcdir = abs_path("../../..");
+my $srcdir = abs_path("$ENV{TESTDIR}/../../..");
 
 # Set up the data of the old instance with a dump or pg_regress.
 if (defined($ENV{olddump}))
diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index 50bde7dd0fc..bbbb49bb23d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
index 4cb1170438a..e79980469b4 100644
--- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
+++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
@@ -49,7 +49,8 @@ for my $testname (@tests)
 		my $expected;
 		my $result;
 
-		$expected = slurp_file_eval("traces/$testname.trace");
+		my $inputdir = "$ENV{'TESTDIR'}/test";
+		$expected = slurp_file_eval("$inputdir/$testname.trace");
 		next unless $expected ne "";
 		$result = slurp_file_eval($traceout);
 		next unless $result ne "";
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 60459ef759e..167b6ea44b7 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -35,7 +35,7 @@ my @not_in_sample_array = split("\n", lc($not_in_sample));
 
 # TAP tests are executed in the directory of the test, in the source tree,
 # even for VPATH builds, so rely on that to find postgresql.conf.sample.
-my $rootdir     = "../../../..";
+my $rootdir     = "$ENV{TESTDIR}/../../../..";
 my $sample_file = "$rootdir/src/backend/utils/misc/postgresql.conf.sample";
 
 # List of all the GUCs found in the sample file.
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index fdb4ea0bf50..c1ec234d607 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -70,10 +70,11 @@ my $rc =
 	  . $node_primary->host . " "
 	  . "--port="
 	  . $node_primary->port . " "
-	  . "--schedule=../regress/parallel_schedule "
+	  . "--schedule=\"$dlpath/parallel_schedule\" "
 	  . "--max-concurrent-tests=20 "
-	  . "--inputdir=../regress "
+	  . "--inputdir=\"$dlpath\" "
 	  . "--outputdir=\"$outputdir\"");
+
 if ($rc != 0)
 {
 	# Dump out the regression diffs file, if there is one
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 1b1387acac0..870b848919c 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -328,8 +328,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -343,14 +341,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for better performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--Sw7tCqrGA+HQ0/zt
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0011-cirrus-make-DebugInformationFormat-OldStyle-for-CI-b.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 10/21] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

ci-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pg_upgrade/t/002_pg_upgrade.pl             |  2 +-
 src/bin/pgbench/t/002_pgbench_no_server.pl         |  4 ++--
 .../modules/libpq_pipeline/t/001_libpq_pipeline.pl |  3 ++-
 src/test/modules/test_misc/t/003_check_guc.pl      |  2 +-
 src/test/recovery/t/027_stream_regress.pl          |  5 +++--
 src/tools/msvc/vcregress.pl                        | 14 ++++----------
 6 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 2f9b13bf0ae..757f4c76f7d 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -64,7 +64,7 @@ $oldnode->init(extra => [ '--wal-segsize', '1', '--allow-group-access' ]);
 $oldnode->start;
 
 # The default location of the source code is the root of this directory.
-my $srcdir = abs_path("../../..");
+my $srcdir = abs_path("$ENV{TESTDIR}/../../..");
 
 # Set up the data of the old instance with a dump or pg_regress.
 if (defined($ENV{olddump}))
diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index 50bde7dd0fc..bbbb49bb23d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
index 0821329c8d3..7e6752562fd 100644
--- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
+++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
@@ -50,7 +50,8 @@ for my $testname (@tests)
 		my $expected;
 		my $result;
 
-		$expected = slurp_file_eval("traces/$testname.trace");
+		my $inputdir = "$ENV{'TESTDIR'}";
+		$expected = slurp_file_eval("$inputdir/traces/$testname.trace");
 		next unless $expected ne "";
 		$result = slurp_file_eval($traceout);
 		next unless $result ne "";
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 60459ef759e..167b6ea44b7 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -35,7 +35,7 @@ my @not_in_sample_array = split("\n", lc($not_in_sample));
 
 # TAP tests are executed in the directory of the test, in the source tree,
 # even for VPATH builds, so rely on that to find postgresql.conf.sample.
-my $rootdir     = "../../../..";
+my $rootdir     = "$ENV{TESTDIR}/../../../..";
 my $sample_file = "$rootdir/src/backend/utils/misc/postgresql.conf.sample";
 
 # List of all the GUCs found in the sample file.
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index 7982ac08d0a..c062877bec6 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -70,10 +70,11 @@ my $rc =
 	  . $node_primary->host . " "
 	  . "--port="
 	  . $node_primary->port . " "
-	  . "--schedule=../regress/parallel_schedule "
+	  . "--schedule=\"$dlpath/parallel_schedule\" "
 	  . "--max-concurrent-tests=20 "
-	  . "--inputdir=../regress "
+	  . "--inputdir=\"$dlpath\" "
 	  . "--outputdir=\"$outputdir\"");
+
 if ($rc != 0)
 {
 	# Dump out the regression diffs file, if there is one
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 5dcc3419ad7..49168e298ac 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -328,8 +328,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -343,14 +341,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for better performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--mln0rGgUGuXEqmuI
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0011-cirrus-make-DebugInformationFormat-OldStyle-for-CI-b.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 6/7] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

ci-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:
Should pass the srcdir to all taptests, or go back to writing the results to
tmp_check ?

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pgbench/t/002_pgbench_no_server.pl         |  4 ++--
 .../modules/libpq_pipeline/t/001_libpq_pipeline.pl |  3 ++-
 src/test/modules/test_misc/t/003_check_guc.pl      |  2 +-
 src/test/recovery/t/027_stream_regress.pl          |  4 ++--
 src/tools/msvc/vcregress.pl                        | 14 ++++----------
 5 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index acad19edd0..84e36dcd3f 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
index 0c164dcaba..2a0eca7744 100644
--- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
+++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
@@ -49,7 +49,8 @@ for my $testname (@tests)
 		my $expected;
 		my $result;
 
-		$expected = slurp_file_eval("traces/$testname.trace");
+		my $inputdir = "$ENV{'TESTDIR'}/tmp_check";
+		$expected = slurp_file_eval("$inputdir/traces/$testname.trace");
 		next unless $expected ne "";
 		$result = slurp_file_eval($traceout);
 		next unless $result ne "";
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 60459ef759..167b6ea44b 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -35,7 +35,7 @@ my @not_in_sample_array = split("\n", lc($not_in_sample));
 
 # TAP tests are executed in the directory of the test, in the source tree,
 # even for VPATH builds, so rely on that to find postgresql.conf.sample.
-my $rootdir     = "../../../..";
+my $rootdir     = "$ENV{TESTDIR}/../../../..";
 my $sample_file = "$rootdir/src/backend/utils/misc/postgresql.conf.sample";
 
 # List of all the GUCs found in the sample file.
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index c40951b7ba..f7679306f5 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -58,9 +58,9 @@ system_or_bail($ENV{PG_REGRESS} . " $extra_opts " .
 			   "--bindir= " .
 			   "--host=" . $node_primary->host . " " .
 			   "--port=" . $node_primary->port . " " .
-			   "--schedule=../regress/parallel_schedule " .
+			   "--schedule=\"$dlpath/parallel_schedule\" " .
 			   "--max-concurrent-tests=20 " .
-			   "--inputdir=../regress " .
+			   "--inputdir=\"$dlpath\" " .
 			   "--outputdir=\"$outputdir\"");
 
 # Clobber all sequences with their next value, so that we don't have
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index e27c1d15e5..cc8d690c29 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -295,8 +295,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -310,14 +308,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for good performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--ibvzjYYg+QDzMCy1
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0007-tmp-run-tap-tests-first.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 10/19] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

ci-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pg_upgrade/t/002_pg_upgrade.pl             |  2 +-
 src/bin/pgbench/t/002_pgbench_no_server.pl         |  4 ++--
 .../modules/libpq_pipeline/t/001_libpq_pipeline.pl |  3 ++-
 src/test/modules/test_misc/t/003_check_guc.pl      |  2 +-
 src/test/recovery/t/027_stream_regress.pl          |  5 +++--
 src/tools/msvc/vcregress.pl                        | 14 ++++----------
 6 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 75ac768a96e..3f8fc986e72 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -60,7 +60,7 @@ $oldnode->init(extra => [ '--wal-segsize', '1', '--allow-group-access' ]);
 $oldnode->start;
 
 # The default location of the source code is the root of this directory.
-my $srcdir = abs_path("../../..");
+my $srcdir = abs_path("$ENV{TESTDIR}/../../..");
 
 # Set up the data of the old instance with a dump or pg_regress.
 if (defined($ENV{olddump}))
diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index 50bde7dd0fc..bbbb49bb23d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
index 4cb1170438a..e79980469b4 100644
--- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
+++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
@@ -49,7 +49,8 @@ for my $testname (@tests)
 		my $expected;
 		my $result;
 
-		$expected = slurp_file_eval("traces/$testname.trace");
+		my $inputdir = "$ENV{'TESTDIR'}/test";
+		$expected = slurp_file_eval("$inputdir/$testname.trace");
 		next unless $expected ne "";
 		$result = slurp_file_eval($traceout);
 		next unless $result ne "";
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 60459ef759e..167b6ea44b7 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -35,7 +35,7 @@ my @not_in_sample_array = split("\n", lc($not_in_sample));
 
 # TAP tests are executed in the directory of the test, in the source tree,
 # even for VPATH builds, so rely on that to find postgresql.conf.sample.
-my $rootdir     = "../../../..";
+my $rootdir     = "$ENV{TESTDIR}/../../../..";
 my $sample_file = "$rootdir/src/backend/utils/misc/postgresql.conf.sample";
 
 # List of all the GUCs found in the sample file.
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index fdb4ea0bf50..c1ec234d607 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -70,10 +70,11 @@ my $rc =
 	  . $node_primary->host . " "
 	  . "--port="
 	  . $node_primary->port . " "
-	  . "--schedule=../regress/parallel_schedule "
+	  . "--schedule=\"$dlpath/parallel_schedule\" "
 	  . "--max-concurrent-tests=20 "
-	  . "--inputdir=../regress "
+	  . "--inputdir=\"$dlpath\" "
 	  . "--outputdir=\"$outputdir\"");
+
 if ($rc != 0)
 {
 	# Dump out the regression diffs file, if there is one
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 1b1387acac0..870b848919c 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -328,8 +328,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -343,14 +341,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for better performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--Sw7tCqrGA+HQ0/zt
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0011-cirrus-make-DebugInformationFormat-OldStyle-for-CI-b.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 10/19] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

ci-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pg_upgrade/t/002_pg_upgrade.pl             |  2 +-
 src/bin/pgbench/t/002_pgbench_no_server.pl         |  4 ++--
 .../modules/libpq_pipeline/t/001_libpq_pipeline.pl |  3 ++-
 src/test/modules/test_misc/t/003_check_guc.pl      |  2 +-
 src/test/recovery/t/027_stream_regress.pl          |  5 +++--
 src/tools/msvc/vcregress.pl                        | 14 ++++----------
 6 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 75ac768a96e..3f8fc986e72 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -60,7 +60,7 @@ $oldnode->init(extra => [ '--wal-segsize', '1', '--allow-group-access' ]);
 $oldnode->start;
 
 # The default location of the source code is the root of this directory.
-my $srcdir = abs_path("../../..");
+my $srcdir = abs_path("$ENV{TESTDIR}/../../..");
 
 # Set up the data of the old instance with a dump or pg_regress.
 if (defined($ENV{olddump}))
diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index 50bde7dd0fc..bbbb49bb23d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
index 4cb1170438a..e79980469b4 100644
--- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
+++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
@@ -49,7 +49,8 @@ for my $testname (@tests)
 		my $expected;
 		my $result;
 
-		$expected = slurp_file_eval("traces/$testname.trace");
+		my $inputdir = "$ENV{'TESTDIR'}/test";
+		$expected = slurp_file_eval("$inputdir/$testname.trace");
 		next unless $expected ne "";
 		$result = slurp_file_eval($traceout);
 		next unless $result ne "";
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 60459ef759e..167b6ea44b7 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -35,7 +35,7 @@ my @not_in_sample_array = split("\n", lc($not_in_sample));
 
 # TAP tests are executed in the directory of the test, in the source tree,
 # even for VPATH builds, so rely on that to find postgresql.conf.sample.
-my $rootdir     = "../../../..";
+my $rootdir     = "$ENV{TESTDIR}/../../../..";
 my $sample_file = "$rootdir/src/backend/utils/misc/postgresql.conf.sample";
 
 # List of all the GUCs found in the sample file.
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index fdb4ea0bf50..c1ec234d607 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -70,10 +70,11 @@ my $rc =
 	  . $node_primary->host . " "
 	  . "--port="
 	  . $node_primary->port . " "
-	  . "--schedule=../regress/parallel_schedule "
+	  . "--schedule=\"$dlpath/parallel_schedule\" "
 	  . "--max-concurrent-tests=20 "
-	  . "--inputdir=../regress "
+	  . "--inputdir=\"$dlpath\" "
 	  . "--outputdir=\"$outputdir\"");
+
 if ($rc != 0)
 {
 	# Dump out the regression diffs file, if there is one
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 1b1387acac0..870b848919c 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -328,8 +328,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -343,14 +341,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for better performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--Sw7tCqrGA+HQ0/zt
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0011-cirrus-make-DebugInformationFormat-OldStyle-for-CI-b.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 16/25] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

XX-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pgbench/t/002_pgbench_no_server.pl |  4 ++--
 src/tools/msvc/vcregress.pl                | 14 ++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index 50bde7dd0fc..bbbb49bb23d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 5dcc3419ad7..49168e298ac 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -328,8 +328,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -343,14 +341,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for better performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--IS0zKkzwUGydFO0o
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0017-another-way-to-install-uri_regress-testclient.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 10/21] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

ci-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pg_upgrade/t/002_pg_upgrade.pl             |  2 +-
 src/bin/pgbench/t/002_pgbench_no_server.pl         |  4 ++--
 .../modules/libpq_pipeline/t/001_libpq_pipeline.pl |  3 ++-
 src/test/modules/test_misc/t/003_check_guc.pl      |  2 +-
 src/test/recovery/t/027_stream_regress.pl          |  5 +++--
 src/tools/msvc/vcregress.pl                        | 14 ++++----------
 6 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 3f11540e189..90bfcfed026 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -64,7 +64,7 @@ $oldnode->init(extra => [ '--wal-segsize', '1', '--allow-group-access' ]);
 $oldnode->start;
 
 # The default location of the source code is the root of this directory.
-my $srcdir = abs_path("../../..");
+my $srcdir = abs_path("$ENV{TESTDIR}/../../..");
 
 # Set up the data of the old instance with a dump or pg_regress.
 if (defined($ENV{olddump}))
diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index 50bde7dd0fc..bbbb49bb23d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
index 4cb1170438a..e5c1c0bfa89 100644
--- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
+++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
@@ -49,7 +49,8 @@ for my $testname (@tests)
 		my $expected;
 		my $result;
 
-		$expected = slurp_file_eval("traces/$testname.trace");
+		my $inputdir = "$ENV{'TESTDIR'}";
+		$expected = slurp_file_eval("$inputdir/traces/$testname.trace");
 		next unless $expected ne "";
 		$result = slurp_file_eval($traceout);
 		next unless $result ne "";
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 60459ef759e..167b6ea44b7 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -35,7 +35,7 @@ my @not_in_sample_array = split("\n", lc($not_in_sample));
 
 # TAP tests are executed in the directory of the test, in the source tree,
 # even for VPATH builds, so rely on that to find postgresql.conf.sample.
-my $rootdir     = "../../../..";
+my $rootdir     = "$ENV{TESTDIR}/../../../..";
 my $sample_file = "$rootdir/src/backend/utils/misc/postgresql.conf.sample";
 
 # List of all the GUCs found in the sample file.
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index fdb4ea0bf50..c1ec234d607 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -70,10 +70,11 @@ my $rc =
 	  . $node_primary->host . " "
 	  . "--port="
 	  . $node_primary->port . " "
-	  . "--schedule=../regress/parallel_schedule "
+	  . "--schedule=\"$dlpath/parallel_schedule\" "
 	  . "--max-concurrent-tests=20 "
-	  . "--inputdir=../regress "
+	  . "--inputdir=\"$dlpath\" "
 	  . "--outputdir=\"$outputdir\"");
+
 if ($rc != 0)
 {
 	# Dump out the regression diffs file, if there is one
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 5dcc3419ad7..49168e298ac 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -328,8 +328,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -343,14 +341,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for better performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--STPqjqpCrtky8aYs
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0011-cirrus-make-DebugInformationFormat-OldStyle-for-CI-b.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* [PATCH 14/23] vcregress: run alltaptests in parallel
@ 2022-02-19 19:41 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Justin Pryzby @ 2022-02-19 19:41 UTC (permalink / raw)

XX-os-only: windows

The test changes are needed to avoid these failures:

https://github.com/justinpryzby/postgres/runs/5174636590
[15:59:59.408] Bailout called.  Further testing stopped:  could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument
[15:59:59.408] FAILED--Further testing stopped: could not create test directory "c:/cirrus/tmp_check/t_C:\cirrus\src\bin\pgbench\t\002_pgbench_no_server_stuff": Invalid argument

https://github.com/justinpryzby/postgres/runs/5174788205
[16:37:09.891] #   Failed test 'reading traces/disallowed_in_pipeline.trace: could not open "traces/disallowed_in_pipeline.trace": The system cannot find the path specified at C:\cirrus\src\test\modules\libpq_pipeline\t\001_libpq_pipeline.pl line 70.

https://github.com/justinpryzby/postgres/runs/5174877506
pg_regress: could not open file "../regress/parallel_schedule" for reading: No such file or directory

XXX: avoid breaking src/bin/psql/t/010_tab_completion.pl:

See also:
f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b
795862c280c5949bafcd8c44543d887fd32b590a
db973ffb3ca43e65a0bf15175a35184a53bf977d
---
 src/bin/pgbench/t/002_pgbench_no_server.pl |  4 ++--
 src/tools/msvc/vcregress.pl                | 14 ++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl
index 50bde7dd0fc..bbbb49bb23d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -8,12 +8,12 @@
 use strict;
 use warnings;
 
+use File::Basename;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
 # create a directory for scripts
-my $testname = $0;
-$testname =~ s,.*/,,;
+my $testname = basename($0);
 $testname =~ s/\.pl$//;
 
 my $testdir = "$PostgreSQL::Test::Utils::tmp_check/t_${testname}_stuff";
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 5dcc3419ad7..49168e298ac 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -328,8 +328,6 @@ sub alltaptests
 {
 	InstallTemp();
 
-	my $mstat = 0;
-
 	# Find out all the existing TAP tests by looking for t/ directories
 	# in the tree.
 	my @tap_dirs = ();
@@ -343,14 +341,10 @@ sub alltaptests
 		},
 		@top_dir);
 
-	# Process each test
-	foreach my $test_path (@tap_dirs)
-	{
-		my $dir = dirname($test_path);
-		my $status = tap_check($dir);
-		$mstat ||= $status;
-	}
-	exit $mstat if $mstat;
+	# Run all the tap tests in a single prove instance for better performance
+	$ENV{PROVE_TESTS} = "@tap_dirs";
+	my $status = tap_check('PROVE_FLAGS=--ext=.pl', "$topdir");
+	exit $status if $status;
 	return;
 }
 
-- 
2.17.1


--tKkaNMvYmhQvRCRK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0015-another-way-to-install-uri_regress-testclient.patch"



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Not able to compile PG16 with custom flags in freebsd 14.1 - Please Help
@ 2024-09-05 16:36 Moksh Chadha <[email protected]>
  0 siblings, 0 replies; 12+ messages in thread

From: Moksh Chadha @ 2024-09-05 16:36 UTC (permalink / raw)
  To: [email protected]

Hi I am trying to install Postgresql 16 on my freebsd 14.1 by compiling it
hosted in an ec2 machine on AWS.

I am using GCC13 to compile the binaries and I keep on running into


*gcc13: fatal error: cannot read spec file './specs': Is a directory *Please
Help

here is the code of my bash script I have also uploaded the same code in
github gist :-

https://gist.github.com/mokshchadha/6c5590e339959a91dc6985b96dee25cb

Code in the above mentioned gist

 #!/bin/sh


# Configuration variables
POSTGRES_VERSION="16.3"
POSTGRES_PREFIX="/usr/local/pgsql"
DATA_DIR="$POSTGRES_PREFIX/data"
LOGFILE="$POSTGRES_PREFIX/logfile"
BUILD_DIR="/tmp/postgresql-build"
PYTHON3_PATH=$(which python3)

# Helper functions
error_exit() {
    echo "Error: $1" >&2
    cleanup
    exit 1
}

warning_message() {
    echo "Warning: $1" >&2
}

cleanup() {
    echo "Cleaning up..."
    [ -d "$BUILD_DIR" ] && rm -rf "$BUILD_DIR" || warning_message
"Failed to remove build directory."
}

check_prerequisites() {
    # Check for GCC 13
    if ! command -v gcc13 >/dev/null 2>&1; then
        echo "GCC 13 is not installed. Installing GCC 13..."
        pkg install -y gcc13 || error_exit "Failed to install GCC 13.
Please install it manually using 'pkg install gcc13'."
    else
        echo "GCC 13 is installed. Checking version and configuration..."
        gcc13 --version
        gcc13 -v 2>&1 | grep "Configured with"

        # Check for specs file issue
        GCC_LIBDIR="/usr/local/lib/gcc13"
        SPECS_FILE="$GCC_LIBDIR/specs"

        if [ ! -f "$SPECS_FILE" ]; then
            echo "specs file not found. Attempting to create..."
            if ! gcc13 -dumpspecs > "$SPECS_FILE" 2>/dev/null; then
                error_exit "Failed to create specs file. Please check
GCC 13 installation."
            fi
        fi

        # Verify GCC functionality
        if ! gcc13 -v >/dev/null 2>&1; then
            error_exit "GCC 13 is not functioning correctly. Please
check your GCC installation."
        fi
    fi

    # Check for GNU Make
    if ! command -v gmake >/dev/null 2>&1; then
        echo "GNU Make is not installed. Installing GNU Make..."
        pkg install -y gmake || error_exit "Failed to install GNU
Make. Please install it manually using 'pkg install gmake'."
    fi

    command -v fetch >/dev/null 2>&1 || error_exit "fetch is required
but not installed. Please install it using 'pkg install fetch'."
    command -v python3 >/dev/null 2>&1 || error_exit "Python3 is
required but not installed. Please install it using 'pkg install
python3'."
    command -v openssl >/dev/null 2>&1 || error_exit "OpenSSL is
required but not installed. Please install it using 'pkg install
openssl'."

    # Check for pkg-config
    if ! command -v pkg-config >/dev/null 2>&1; then
        echo "pkg-config is not installed. Installing pkg-config..."
        pkg install -y pkgconf || error_exit "Failed to install
pkg-config. Please install it manually using 'pkg install pkgconf'."
    fi

    # Check for LZ4
    if ! pkg info -e liblz4 >/dev/null 2>&1; then
        echo "LZ4 is not installed. Installing LZ4..."
        pkg install -y liblz4 || error_exit "Failed to install LZ4.
Please install it manually using 'pkg install liblz4'."
    fi

    # Verify LZ4 installation
    if ! pkg-config --exists liblz4; then
        error_exit "LZ4 library not found by pkg-config. Please check
your LZ4 installation."
    fi

    # Check for ICU
    if ! pkg info -e icu >/dev/null 2>&1; then
        echo "ICU is not installed. Installing ICU..."
        pkg install -y icu || error_exit "Failed to install ICU.
Please install it manually using 'pkg install icu'."
    fi

    # Verify ICU installation
    if [ -f /usr/local/lib/libicuuc.so ]; then
        echo "ICU library found at /usr/local/lib/libicuuc.so"
    else
        error_exit "ICU library not found at expected location. Please
check your ICU installation."
    fi

    # Print ICU version
    echo "ICU version:"
    pkg info icu | grep Version

    # Print LZ4 version
    echo "LZ4 version:"
    pkg info liblz4 | grep Version
}

ensure_install_directory() {
    if [ ! -d "$POSTGRES_PREFIX" ]; then
        mkdir -p "$POSTGRES_PREFIX" || error_exit "Failed to create
installation directory."
    elif [ ! -w "$POSTGRES_PREFIX" ]; then
        chmod u+w "$POSTGRES_PREFIX" || error_exit "Failed to set
permissions on installation directory."
    fi
}

create_postgres_user() {
    if ! pw groupshow postgres >/dev/null 2>&1; then
        echo "Creating 'postgres' group..."
        pw groupadd postgres || error_exit "Failed to create 'postgres' group."
    fi

    if ! pw usershow postgres >/dev/null 2>&1; then
        echo "Creating 'postgres' user..."
        pw useradd postgres -g postgres -m -s /usr/local/bin/bash ||
error_exit "Failed to create 'postgres' user."
    else
        echo "'postgres' user already exists."
    fi
}

download_postgresql() {
    echo "Downloading PostgreSQL $POSTGRES_VERSION..."
    mkdir -p "$BUILD_DIR" || error_exit "Failed to create build directory."
    cd "$BUILD_DIR" || error_exit "Failed to enter build directory."

    if [ ! -f "postgresql-$POSTGRES_VERSION.tar.bz2" ]; then
        fetch "https://ftp.postgresql.org/pub/source/v$POSTGRES_VERSION/postgresql-$POSTGRES_VERSION.tar.bz2";
|| error_exit "Failed to download PostgreSQL source."
    else
        echo "Source tarball already exists, skipping download."
    fi

    if [ ! -d "postgresql-$POSTGRES_VERSION" ]; then
        tar -xvf "postgresql-$POSTGRES_VERSION.tar.bz2" || error_exit
"Failed to extract PostgreSQL source."
    else
        echo "Source directory already exists, skipping extraction."
    fi

    cd "postgresql-$POSTGRES_VERSION" || error_exit "Failed to enter
PostgreSQL source directory."
}

configure_postgresql() {
    echo "Configuring PostgreSQL with custom options..."
    PYTHON_INCLUDE_DIR=$($PYTHON3_PATH -c "from distutils.sysconfig
import get_python_inc; print(get_python_inc())")
    PYTHON_LIB_DIR=$($PYTHON3_PATH -c "from distutils.sysconfig import
get_config_var; print(get_config_var('LIBDIR'))")

    # Add ICU library and include paths
    ICU_LIBS="-L/usr/local/lib -licui18n -licuuc -licudata"
    ICU_CFLAGS="-I/usr/local/include"

    # Add LZ4 library and include paths
    LZ4_LIBS=$(pkg-config --libs liblz4)
    LZ4_CFLAGS=$(pkg-config --cflags liblz4)

    export CC=gcc13
    export LDFLAGS="-L/usr/local/lib -L$PYTHON_LIB_DIR $ICU_LIBS $LZ4_LIBS"
    export CPPFLAGS="-I/usr/local/include -I$PYTHON_INCLUDE_DIR
$ICU_CFLAGS $LZ4_CFLAGS"
    export ICU_LIBS
    export ICU_CFLAGS
    export LZ4_LIBS
    export LZ4_CFLAGS
    export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
    export LIBRARY_PATH="/usr/local/lib:$LIBRARY_PATH"
    export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

    config_command="./configure \
        CC=gcc13 \
        --prefix=\"$POSTGRES_PREFIX\" \
        --with-blocksize=32 \
        --with-segsize=8 \
        --with-openssl \
        --with-ssl=openssl \
        --with-lz4 \
        --with-python \
        --with-icu \
        --with-includes=\"/usr/local/include $PYTHON_INCLUDE_DIR\" \
        --with-libraries=\"/usr/local/lib $PYTHON_LIB_DIR\""
    echo "Configuration command: $config_command"
    echo "LDFLAGS: $LDFLAGS"
    echo "CPPFLAGS: $CPPFLAGS"
    echo "ICU_LIBS: $ICU_LIBS"
    echo "ICU_CFLAGS: $ICU_CFLAGS"
    echo "LZ4_LIBS: $LZ4_LIBS"
    echo "LZ4_CFLAGS: $LZ4_CFLAGS"
    echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
    echo "LIBRARY_PATH: $LIBRARY_PATH"
    echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"

    # Run configure and capture output
    if ! eval $config_command > configure_output.log 2>&1; then
        echo "Configuration failed. Last 50 lines of output:"
        tail -n 50 configure_output.log
        error_exit "Configuration failed. See configure_output.log for details."
    fi
}

verify_compilation_options() {
    echo "Verifying compilation options..."
    grep -E "BLCKSZ|RELSEG_SIZE" src/include/pg_config.h
}

compile_postgresql() {
    echo "Compiling PostgreSQL..."
    gmake || error_exit "Compilation failed."

    echo "Compiling contrib modules (including pg_trgm)..."
    cd contrib || error_exit "Failed to enter contrib directory."
    gmake || error_exit "Compilation of contrib modules failed."

    cd .. || error_exit "Failed to return to main PostgreSQL directory."
    verify_compilation_options
}

install_postgresql() {
    echo "Installing PostgreSQL..."
    gmake install || error_exit "Installation failed."

    echo "Installing contrib modules (including pg_trgm)..."
    cd contrib || error_exit "Failed to enter contrib directory."
    gmake install || error_exit "Installation of contrib modules failed."

    cd .. || error_exit "Failed to return to main PostgreSQL directory."
}

setup_environment() {
    echo "Setting up environment variables..."
    if ! grep -q "$POSTGRES_PREFIX/bin" /etc/profile; then
        echo "export PATH=\"$POSTGRES_PREFIX/bin:\$PATH\"" >>
/etc/profile || warning_message "Failed to update /etc/profile."
        . /etc/profile || warning_message "Failed to source /etc/profile."
    else
        echo "PATH already includes $POSTGRES_PREFIX/bin."
    fi
}

initialize_database() {
    echo "Initializing the PostgreSQL database..."
    mkdir -p "$DATA_DIR" || error_exit "Failed to create data directory."
    chown postgres:postgres "$DATA_DIR"
    su -m postgres -c "$POSTGRES_PREFIX/bin/initdb -D $DATA_DIR" ||
error_exit "Database initialization failed."
}

create_extension_pg_trgm() {
    echo "Creating pg_trgm extension..."
    su -m postgres -c "$POSTGRES_PREFIX/bin/psql -d postgres -c
'CREATE EXTENSION IF NOT EXISTS pg_trgm;'" || warning_message "Failed
to create pg_trgm extension. You may need to create it manually in
your databases."
}

start_postgresql() {
    echo "Starting PostgreSQL..."
    su -m postgres -c "$POSTGRES_PREFIX/bin/pg_ctl -D $DATA_DIR -l
$LOGFILE -w start"
    sleep 5  # Give the server a moment to start up
    if ! su -m postgres -c "$POSTGRES_PREFIX/bin/pg_isready -q"; then
        check_log_file
        error_exit "Failed to start PostgreSQL."
    fi
    echo "PostgreSQL started successfully."
}

check_log_file() {
    echo "Checking PostgreSQL log file for errors..."
    if [ -f "$LOGFILE" ]; then
        tail -n 50 "$LOGFILE"
    else
        echo "Log file not found at $LOGFILE"
    fi
}

verify_custom_options() {
    echo "Verifying custom build options..."
    su -m postgres -c "$POSTGRES_PREFIX/bin/psql -d postgres -c \"SHOW
block_size;\"" || warning_message "Failed to verify block size."
    su -m postgres -c "$POSTGRES_PREFIX/bin/psql -d postgres -c \"SHOW
segment_size;\"" || warning_message "Failed to verify segment size."
    echo "Checking PostgreSQL version and compile-time options:"
    su -m postgres -c "$POSTGRES_PREFIX/bin/postgres -V"
    su -m postgres -c "$POSTGRES_PREFIX/bin/pg_config --configure"

    echo "Verifying pg_trgm extension installation:"
    su -m postgres -c "$POSTGRES_PREFIX/bin/psql -d postgres -c
\"SELECT * FROM pg_extension WHERE extname = 'pg_trgm';\"" ||
warning_message "Failed to verify pg_trgm extension."
}

stop_postgresql() {
    echo "Stopping PostgreSQL..."
    if command -v "$POSTGRES_PREFIX/bin/pg_ctl" > /dev/null 2>&1; then
        su -m postgres -c "$POSTGRES_PREFIX/bin/pg_ctl -D $DATA_DIR
stop -m fast" || warning_message "Failed to stop PostgreSQL."
    else
        echo "pg_ctl command not found; assuming PostgreSQL is not running."
    fi
}

uninstall_postgresql() {
    echo "Uninstalling PostgreSQL..."
    stop_postgresql
    if [ -d "$POSTGRES_PREFIX" ]; then
        rm -rf "$POSTGRES_PREFIX" || warning_message "Failed to remove
PostgreSQL directories."
        echo "PostgreSQL uninstalled successfully."
    else
        echo "No PostgreSQL installation detected."
    fi
}

perform_installation() {
    check_prerequisites
    create_postgres_user
    ensure_install_directory
    download_postgresql
    configure_postgresql
    compile_postgresql
    install_postgresql
    setup_environment
    initialize_database
    start_postgresql
    create_extension_pg_trgm
    check_log_file
    verify_custom_options
    echo "PostgreSQL installed and configured successfully with
pg_trgm extension!"
}

# Ensure cleanup happens on script exit
trap cleanup EXIT

# Main function
case "$1" in
    stop)
        stop_postgresql
        ;;
    uninstall)
        uninstall_postgresql
        ;;
    install)
        perform_installation
        ;;
    *)
        echo "Usage: $0 {install|stop|uninstall}"
        exit 1
        ;;
esac


^ permalink  raw  reply  [nested|flat] 12+ messages in thread


end of thread, other threads:[~2024-09-05 16:36 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19 03:13 [PATCH] Fix calculation base of WAL recycling Kyotaro Horiguchi <[email protected]>
2022-01-18 23:48 [PATCH 8/8] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 14/23] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 10/19] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 10/21] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 6/7] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 10/19] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 10/19] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 16/25] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 10/21] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2022-02-19 19:41 [PATCH 14/23] vcregress: run alltaptests in parallel Justin Pryzby <[email protected]>
2024-09-05 16:36 Not able to compile PG16 with custom flags in freebsd 14.1 - Please Help Moksh Chadha <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox