Subject: bug#22619: postgresql-service error checking wtf

From: Danny Milosavljevic <[email-masked]>
Date: Fri, 12 Feb 2016 20:48:58 +0100

Hi,

I've found out some more details. The message 
 
> > initdb: directory "/var/lib/postgresql/data" exists but is not empty
> > If you want to create a new database system, either remove or empty
> > the directory "/var/lib/postgresql/data" or run initdb
> > with an argument other than "/var/lib/postgresql/data".

is not an error for the entire service. It's initdb refusing to clobber the existing database (which has been created by the postgresql-service instance with no #:config-file argument) and helpful in preventing data loss.

The actual problem only arises because guix reconfigure doesn't deem a change in service arguments as reason to restart (or reconfigure) a service.

I.e. before, my config was:

(postgresql-service )

Then I did guix reconfigure ...

Afterwards, I changed the config to:

(postgresql-service #:config-file ...)

Then I did giux reconfigure   # this erroneously doesn't reload the postgres service!!

> > and the error message still references the default config file.  
> 
> I don’t see any references to a config file in what you pasted.

In the postgres-service definition in guix/gnu/services/databases.scm , there's a %default-postgres-config . That's what I meant.
At all times, the default config file was printed in the log - which was because the postgres service never actually was reconfigured.

>I’ve tested ‘postgresql-service’ in a pristine system with ‘guix system vm’ and it starts without any such message.  So I guess there’s stale data in /var/lib/postgresql/data on your system?

It was left over from the first unsuccessful launch because bug# 22618 hadn't been fixed at the time.

Thanks,
   Danny