Skip Menu |

This queue is for tickets about the Test-postgresql CPAN distribution.

Report information
The Basics
Id: 96472
Status: resolved
Priority: 0/
Queue: Test-postgresql

People
Owner: KAZUHO [...] cpan.org
Requestors: mlarue [...] usermode.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.09
Fixed in:
  • 1.10_01
  • 1.20_01
  • 1.20_02



Subject: Postmaster startup indication fail
_try_start() opens postgres.log and waits for "is ready to accept connections" to indicate that postgresql is up and ready. This mechanism does not work with current postgresql versions: 1) Postgresql switches logfile to s/th inside data/pg_log/postgresql-{Weekday}.log 2) Postgresql installation is localized and so are the log messages (at least with fedora) Proposal: Instead of logfile tailing/scanning, try to connect. See attached patch. Btw.: Test::Postgresql, which is newer, has the same problem: https://metacpan.org/source/TJC/Test-PostgreSQL-0.10/lib/Test/PostgreSQL.pm#L163 Greets, Markus
Subject: patch-Test-postgresl-localized-log.diff
--- orig/postgresql.pm +++ postgresql.pm 2014-06-16 09:39:17.990283317 +0200 @@ -160,16 +160,12 @@ close $logfh; # wait until server becomes ready (or dies) for (my $i = 0; $i < 100; $i++) { - open $logfh, '<', $self->base_dir . '/postgres.log' - or die 'failed to open log file:' . $self->base_dir - . "/postgres.log:$!"; - my $lines = do { join '', <$logfh> }; - close $logfh; - last - if $lines =~ /is ready to accept connections/; + if ( DBI->connect($self->dsn(dbname => 'template1',port=>$port), '', '', {}) ) { + last; + } if (waitpid($pid, WNOHANG) > 0) { # failed - return $lines; + return 1; } sleep 1; }
On Mon Jun 16 04:06:04 2014, MLARUE wrote: Show quoted text
> _try_start() opens postgres.log and waits for "is ready to accept > connections" to indicate that postgresql is up and ready. > > This mechanism does not work with current postgresql versions: > > 1) Postgresql switches logfile to s/th inside data/pg_log/postgresql- > {Weekday}.log > > 2) Postgresql installation is localized and so are the log messages > (at least with fedora) > > Proposal: Instead of logfile tailing/scanning, try to connect. > > See attached patch. > > Btw.: Test::Postgresql, which is newer, has the same problem: > https://metacpan.org/source/TJC/Test-PostgreSQL- > 0.10/lib/Test/PostgreSQL.pm#L163
I'm the author of the Test::PostgreSQL fork. If you'd like to submit a pull request at https://github.com/TJC/Test-postgresql I'll be happy to merge it in.
This has been resolved in version 1.10 onwards, for versions of postgres 9.0 and later.