[Bug 906900] New: PostgreSQL improper shutdown
http://bugzilla.opensuse.org/show_bug.cgi?id=906900 Bug ID: 906900 Summary: PostgreSQL improper shutdown Classification: openSUSE Product: openSUSE Distribution Version: 13.2 Hardware: x86-64 OS: openSUSE 13.2 Status: NEW Severity: Normal Priority: P5 - None Component: Other Assignee: bnc-team-screening@forge.provo.novell.com Reporter: opensuse@schillerstrasse42.de QA Contact: qa-bugs@suse.de Found By: --- Blocker: --- Created attachment 614780 --> http://bugzilla.opensuse.org/attachment.cgi?id=614780&action=edit Postgres Log-File I have a fresh and clean installation of openSUSE 13.2 (KDE). I installed postgresql-server from the standard repository. I'm able to start and access the database server without any problem. I have enabled the service "systemctl enable postgresql.service". The service is started automatically at boot time. However, if I shut down the system, the postgreSQL server is not closed properly. The next time the server starts, it complains about an improper shutdown and a database recovery is started. I found out, that the postgres process is killed even before the postgres init script is called for shutdown. I've no idea, who is killing the process (any why) -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Bernhard Wiedemann
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Reinhard Max
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Stefan Fent
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #11 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #12 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #13 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #14 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #15 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Reinhard Max
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #25 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Michael Schlueter
Finally, I've found that the stop command in the init script was not even executed because: if pg_ctl status -s -D $DATADIR >/dev/null
fails with:
pg_ctl: no server running
Michael, I need to check wheter it is the same on your machine. Can you please add the command: Yes, same thing here (see also comment #5). I will attach the requested logs. I also added a "ps -ef | grep postgres" to the stop section. It shows, that at
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #31 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #32 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #33 from Michael Schlueter
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Michael Schlueter
Therefore, I've created a combined setup that executes the init script to setup the environment and afterwards starts the database from within a service file. Please copy the attached file postgresql-init to /etc/init.d/ and postgresql.service to /etc/systemd/system/.
I tested the new service files. However it doesn't work very well for me. Whenever I shutdown the service (manually or via shutdown) the complete postgres data directory is deleted. I guess that's because of this statement in the service file: ExecStopPost=/usr/bin/rm -r ${DATADIR} During the service start a new database is created with ExecStartPre=/usr/bin/initdb --locale=${LANG} --auth=${AUTH} ${DATADIR} I tried to remove these two statements from the service file; afterwards the service start fails. linux-rzhz:~ # systemctl status postgresql.service postgresql.service - PostgreSQL database server Loaded: loaded (/etc/systemd/system/postgresql.service; enabled) Active: failed (Result: exit-code) since Tue 2014-12-02 21:38:54 CET; 4min 25s ago Process: 2362 ExecStart=/usr/bin/pg_ctl start -s -w -D $DATADIR -l $LOGFILE $OPTIONS (code=exited, status=1/FAILURE) Process: 2350 ExecStartPre=/etc/init.d/postgresql-init start (code=exited, status=0/SUCCESS) Dec 02 21:38:49 linux-rzhz postgresql-init[2350]: Starting PostgreSQL 9.3.5 ..done Dec 02 21:38:49 linux-rzhz pg_ctl[2362]: postgres cannot access the server configuration file "/-l/postgresql.conf": No suc...rectory Dec 02 21:38:54 linux-rzhz pg_ctl[2362]: pg_ctl: could not start server Dec 02 21:38:54 linux-rzhz pg_ctl[2362]: Examine the log output. The postgresql.conf file resides in /var/lib/pgsql/data -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Michael Schlueter
(In reply to Michael Schlueter from comment #37)
(In reply to Thomas Blume from comment #34)
I tested the new service files. However it doesn't work very well for me.
Ok, I have attached updated files, please test them.
Great! The database shutdown works perfectly well now. The only thing that is a bit odd, is that initdb is still called at each and every system start. This does not harm, but results in some warning: ----- linux-rzhz:/etc/systemd/system # systemctl status postgresql.service postgresql.service - PostgreSQL database server Loaded: loaded (/etc/systemd/system/postgresql.service; enabled) Active: active (running) since Wed 2014-12-03 18:30:31 CET; 11min ago Main PID: 1636 (postgres) CGroup: /system.slice/postgresql.service ├─1636 /usr/lib/postgresql93/bin/postgres -D /var/lib/pgsql/data ├─1673 postgres: logger process ├─1685 postgres: checkpointer process ├─1686 postgres: writer process ├─1687 postgres: wal writer process ├─1688 postgres: autovacuum launcher process └─1689 postgres: stats collector process Dec 03 18:30:30 linux-rzhz initdb[1623]: The files belonging to this database system will be owned by user "postgres". Dec 03 18:30:30 linux-rzhz initdb[1623]: This user must also own the server process. Dec 03 18:30:30 linux-rzhz initdb[1623]: The database cluster will be initialized with locale "C". Dec 03 18:30:30 linux-rzhz initdb[1623]: The default database encoding has accordingly been set to "SQL_ASCII". Dec 03 18:30:30 linux-rzhz initdb[1623]: The default text search configuration will be set to "english". Dec 03 18:30:30 linux-rzhz initdb[1623]: Data page checksums are disabled. Dec 03 18:30:30 linux-rzhz initdb[1623]: initdb: directory "/var/lib/pgsql/data" exists but is not empty Dec 03 18:30:30 linux-rzhz initdb[1623]: If you want to create a new database system, either remove or empty Dec 03 18:30:30 linux-rzhz initdb[1623]: the directory "/var/lib/pgsql/data" or run initdb Dec 03 18:30:30 linux-rzhz initdb[1623]: with an argument other than "/var/lib/pgsql/data". ----- Anyway, for me that's fully ok. Will this fix be included in the official repo at some point in time? Thanks for your great support and the effort for sorting this out. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Reinhard Max
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #42 from Reinhard Max
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #43 from Bernhard Wiedemann
is there a scriptable (I know it can be done in C) way to acchieve the side effects of "su -" without creating a new login session?
If plain "su" and sudo do not do what you want, it can probably be done with env (1) -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #52 from Michael Schlueter
Ok, attached the files modificed according to comment #45. Michael, for testing please copy the manager script to:
/usr/lib/postgresql/
and postgresql.service to /etc/systemd/system.
Reinhard, can you take a look wheter it's ok now?
I have tested the new version of the postgres.service. Everything looks great now. The startup and shutdown is clean; the status shows the expected result: ---------------- linux-rzhz:/var/lib/pgsql/data/pg_log # systemctl status postgresql.service postgresql.service - PostgreSQL database server Loaded: loaded (/etc/systemd/system/postgresql.service; enabled) Active: active (running) since Thu 2014-12-04 20:23:16 CET; 6min ago Process: 1583 ExecStart=/usr/lib/postgresql/manager start (code=exited, status=0/SUCCESS) Main PID: 1654 (postgres) CGroup: /system.slice/postgresql.service ├─1654 /usr/lib/postgresql93/bin/postgres -D /var/lib/pgsql/data ├─1692 postgres: logger process ├─1708 postgres: checkpointer process ├─1709 postgres: writer process ├─1710 postgres: wal writer process ├─1711 postgres: autovacuum launcher process └─1712 postgres: stats collector process Dec 04 20:23:16 linux-rzhz manager[1583]: Starting PostgreSQL 9.3.5 ..done ----------------- The log is also clean: 2014-12-04 20:21:40 CET LOG: Datenbanksystem wurde am 2014-12-04 20:21:05 CET heruntergefahren 2014-12-04 20:21:40 CET LOG: Datenbanksystem ist bereit, um Verbindungen anzunehmen 2014-12-04 20:21:40 CET LOG: Autovacuum-Launcher startet 2014-12-04 20:22:11 CET LOG: schnelles Herunterfahren verlangt 2014-12-04 20:22:11 CET LOG: etwaige aktive Transaktionen werden abgebrochen 2014-12-04 20:22:11 CET LOG: Autovacuum-Launcher f?hrt herunter 2014-12-04 20:22:11 CET LOG: fahre herunter 2014-12-04 20:22:11 CET LOG: Datenbanksystem ist heruntergefahren ----- Of course I have only one standard postgres instance running and I am not an Linux expert, so I cannot say anything about more complex use cases. Again, thanks a lot for your help. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #55 from Andrei Borzenkov
Werner, is there a scriptable (I know it can be done in C) way to acchieve the side effects of "su -" without creating a new login session?
Why "su -" needs logind session in the first place? This seems to work in Arch without it; what are the real reasons to have pam_systemd for su? Anyway, here is test package for systemd that should fix it on systemd side. It sets KillMode=none for scope units started from within sysvinit scripts. Change is suprisingly small (all infrastructure was there already). zypper ar obs://home:arvidjaar:bnc:906900/standard bnc906900 zypper refresh bnc906900 zypper dup -r bnc906900 You will need to reboot to make sure all parts are actually using updated components. Of course, if initscript was already converted to systemd unit, it will have no effects. For the cases when systemd unit calls initscript that calls su you could set Environment=XDG_SESSION_CLASS=service though. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
Achim Klausmann
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #61 from Achim Klausmann
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #66 from Achim Klausmann
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #70 from Achim Klausmann
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #72 from Achim Klausmann
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #73 from Reinhard Max
http://bugzilla.opensuse.org/show_bug.cgi?id=906900
--- Comment #75 from Achim Klausmann
participants (1)
-
bugzilla_noreply@novell.com