Bug 13241 - postgresql owns /var/run/postgresql but does not create it, server startup fails
Summary: postgresql owns /var/run/postgresql but does not create it, server startup fails
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 4
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Florian Hubold
QA Contact:
URL:
Whiteboard:
Keywords:
: 12782 (view as bug list)
Depends on: 12841
Blocks:
  Show dependency treegraph
 
Reported: 2014-04-20 15:12 CEST by Florian Hubold
Modified: 2014-05-09 00:02 CEST (History)
7 users (show)

See Also:
Source RPM:
CVE:
Status comment:


Attachments

Description Florian Hubold 2014-04-20 15:12:38 CEST
Description of problem:

After a fresh installation of postgresql9.3-server on Mageia 4:


[doktor5000@Mageia4 ~]$ systemctl status postgresql.service
postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled)
   Active: inactive (dead)

[doktor5000@Mageia4 ~]$ sudo systemctl start postgresql.service
Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details.

[doktor5000@Mageia4 ~]$ systemctl status postgresql.service
postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled)
   Active: failed (Result: exit-code) since So 2014-04-20 14:20:01 CEST; 8s ago
  Process: 23375 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=1/FAILURE)
  Process: 23337 ExecStartPre=/usr/libexec/postgresql_initdb.sh ${PGDATA} (code=exited, status=0/SUCCESS)

Apr 20 14:19:56 Mageia4 pg_ctl[23375]: FATAL:  could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory
Apr 20 14:20:01 Mageia4 pg_ctl[23375]: pg_ctl: could not start server
Apr 20 14:20:01 Mageia4 pg_ctl[23375]: Examine the log output.
Apr 20 14:20:01 Mageia4 systemd[1]: postgresql.service: control process exited, code=exited status=1
Apr 20 14:20:01 Mageia4 systemd[1]: Failed to start PostgreSQL database server.
Apr 20 14:20:01 Mageia4 systemd[1]: Unit postgresql.service entered failed state.

[doktor5000@Mageia4 ~]$ df /var/run/postgresql
df: â/var/run/postgresqlâ: file or directory not found



After creating the folder and adjusting ownership postgresql starts fine:

[doktor5000@Mageia4 ~]$ sudo mkdir /var/run/postgresql
[doktor5000@Mageia4 ~]$ sudo chown postgres:postgres /var/run/postgresql
[doktor5000@Mageia4 ~]$ ls -ald /var/run/postgresql
drwxr-xr-x 2 postgres postgres 40 Apr 20 14:20 /var/run/postgresql/

[doktor5000@Mageia4 ~]$ systemctl status postgresql.service
postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled)
   Active: active (running) since So 2014-04-20 14:22:22 CEST; 4s ago
  Process: 23538 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=0/SUCCESS)
  Process: 23536 ExecStartPre=/usr/libexec/postgresql_initdb.sh ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 23541 (postgres)
   CGroup: /system.slice/postgresql.service
           ââ23541 /usr/bin/postgres -D /var/lib/pgsql/data -p 5432
           ââ23544 postgres: checkpointer process   
           ââ23545 postgres: writer process   
           ââ23546 postgres: wal writer process   
           ââ23547 postgres: autovacuum launcher process   
           ââ23548 postgres: stats collector process   

Apr 20 14:22:21 Mageia4 systemd[1]: Starting PostgreSQL database server...
Apr 20 14:22:21 Mageia4 pg_ctl[23538]: LOG:  database system was shut down at 2014-04-20 14:19:56 CEST
Apr 20 14:22:21 Mageia4 pg_ctl[23538]: LOG:  database system is ready to accept connections
Apr 20 14:22:21 Mageia4 pg_ctl[23538]: LOG:  autovacuum launcher started
Apr 20 14:22:22 Mageia4 systemd[1]: Started PostgreSQL database server.







Reproducible: 

Steps to Reproduce:
Comment 1 Florian Hubold 2014-04-20 15:17:51 CEST
Some more information:

[doktor5000@Mageia4 ~]$ rpm -qf /var/run/postgresql/
postgresql9.3-server-9.3.2-2.mga4


Seems the issue is how the directory is listed in %files list in the SPEC. It gets created during %install:


338	# Create the directory for sockets.
339	install -d -m 755 %{buildroot}/var/run/postgresql

but in %files list it is listed as %ghost and only %dir?

576	%attr(755,postgres,postgres) %ghost %dir /var/run/postgresql

If this is marked as %ghost, it would have to be created on target system during one of the %post phases, right?

CC: (none) => doktor5000

Comment 2 Florian Hubold 2014-04-20 15:28:57 CEST
Submitted a fix to updates/4/postgresql9.3 and an updates candidate to updates_testing after testing if this work. Will write advisory soon.
Comment 4 Florian Hubold 2014-04-20 22:23:36 CEST
*** Bug 12782 has been marked as a duplicate of this bug. ***

CC: (none) => stormi

Florian Hubold 2014-04-20 22:24:05 CEST

Depends on: (none) => 12841

Comment 5 Florian Hubold 2014-04-20 22:42:04 CEST
(In reply to Barry Jackson from comment #3)
> https://wiki.mageia.org/en/System_Service_policy#Transient_folders_.28.2Frun.
> 2C_.2Fvar.2Frun.2C_.2Fvar.2Flock.29

Yeah, yeah, just saw it when I came back home. Was rejected by buildsystem http://pkgsubmit.mageia.org/uploads/rejected/4/core/updates_testing/20140420132809.doktor5000.valstar.4551.youri

Submission errors, aborting:
- postgresql9.3-server-9.3.2-2.1.mga4:
 - non-ghost-in-var-run /var/run/postgresql
 - non-ghost-in-var-run /var/run/postgresql


But that instructions from the wiki alone won't work, I had to use the full path to the config file in %post:

%_tmpfilescreate %{_tmpfilesdir}/%{bname}

Already commited new fix for updates/4/postgresql9.3


@Luigi: Doesn't seem like Funda will do the security updates, shall I help with those, at least for mga4?
Florian Hubold 2014-04-20 22:42:26 CEST

CC: (none) => luigiwalser, nanardon

Comment 6 David Walser 2014-04-21 00:12:05 CEST
(In reply to Florian Hubold from comment #5)
> @Luigi: Doesn't seem like Funda will do the security updates, shall I help
> with those, at least for mga4?

Yes, please.  BTW does this tmpfiles issue affect only 9.3, or also the others?
Comment 7 Florian Hubold 2014-04-21 16:42:10 CEST
(In reply to David Walser from comment #6)
> does this tmpfiles issue affect only 9.3, or also the others?

No clue at all, didn't even look yet. Will take a look once I find some time.
Also, do you want to combine this bugfix and the security fix into one update candidate?

Assignee: fundawang => doktor5000

Comment 8 David Walser 2014-04-21 18:28:00 CEST
(In reply to Florian Hubold from comment #7)
> Also, do you want to combine this bugfix and the security fix into one
> update candidate?

Yes, we can save the QA team some work that way.
Comment 9 Florian Hubold 2014-05-05 21:07:38 CEST
To reproduce and simulate installation on freshly installed system
(WARNING: this will wipe your postgres databases!)

urpme $(rpm -qa | grep ^postgresql9.3) 1>/dev/null; rm -rf /var/lib/pgsql ; rm -rf /var/run/postgresql


#verify socket directory does not exist:
ls -ald /var/run/postgresql

#install and start postgres server, then check status
urpmi postgresql9.3-server --auto && systemctl start postgresql && sleep 3; systemctl status postgresql

#see the failure
Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details.

#verify socket directory has not been created:
ls -ald /var/run/postgresql


======================================================================

#rinse and repeat with update candidate, socket directory should exist

# ls -ald /var/run/postgresql
drwxr-xr-x 2 postgres postgres 40 Mai  5 21:05 /var/run/postgresql/



list of packages:

x86_64
postgresql9.3-pltcl-9.3.4-1.mga4.x86_64.rpm
lib64pq9.3_5-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-debuginfo-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-server-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-pl-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-plpython-9.3.4-1.mga4.x86_64.rpm
lib64ecpg9.3_6-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-plpgsql-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-plperl-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-contrib-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-devel-9.3.4-1.mga4.x86_64.rpm
postgresql9.3-docs-9.3.4-1.mga4.noarch.rpm


i586
postgresql9.3-pltcl-9.3.4-1.mga4.i586.rpm
lib64pq9.3_5-9.3.4-1.mga4.i586.rpm
postgresql9.3-debuginfo-9.3.4-1.mga4.i586.rpm
postgresql9.3-server-9.3.4-1.mga4.i586.rpm
postgresql9.3-pl-9.3.4-1.mga4.i586.rpm
postgresql9.3-plpython-9.3.4-1.mga4.i586.rpm
lib64ecpg9.3_6-9.3.4-1.mga4.i586.rpm
postgresql9.3-plpgsql-9.3.4-1.mga4.i586.rpm
postgresql9.3-plperl-9.3.4-1.mga4.i586.rpm
postgresql9.3-9.3.4-1.mga4.i586.rpm
postgresql9.3-contrib-9.3.4-1.mga4.i586.rpm
postgresql9.3-devel-9.3.4-1.mga4.i586.rpm
postgresql9.3-docs-9.3.4-1.mga4.noarch.rpm


SRPMs
postgresql9.3-9.3.4-1.mga4.src.rpm

Status: NEW => ASSIGNED
Assignee: doktor5000 => qa-bugs

Comment 10 claire robinson 2014-05-06 10:06:32 CEST
Please don't assign multiple bugs to QA for the same update Florian. 
I've added these details in bug 12841.

CC: (none) => qa-bugs
Assignee: qa-bugs => doktor5000

David Walser 2014-05-07 20:16:00 CEST

Depends on: (none) => 13336

David Walser 2014-05-07 20:16:40 CEST

Depends on: 13336 => (none)

Comment 11 Thomas Backlund 2014-05-09 00:02:05 CEST
Update pushed:
http://advisories.mageia.org/MGASA-2014-0205.html

Status: ASSIGNED => RESOLVED
CC: (none) => tmb
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.