postgresql: change systemd service type to notify
PATCH 1/1 postgresql: change systemd service type to notify
During activation, pg_ctl uses exec to start the db server, which causes the service to never finish activating when Type=forking. Upstream recommends configuring --with-systemd and using Type=notify.
https://www.postgresql.org/docs/10/static/server-start.html
--- package/postgresql/postgresql.mk | 8 ++++++++ package/postgresql/postgresql.service | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
package/postgresql/postgresql.mk +8 -0
@@ -70,6 +70,14 @@ else POSTGRESQL_CONF_OPTS += --without-ldap endif +# required for postgresql.service Type=notify +ifeq ($(BR2_PACKAGE_SYSTEMD),y) +POSTGRESQL_DEPENDENCIES += systemd +POSTGRESQL_CONF_OPTS += --with-systemd +else +POSTGRESQL_CONF_OPTS += --without-systemd +endif + define POSTGRESQL_USERS postgres -1 postgres -1 * /var/lib/pgsql /bin/sh - PostgreSQL Server endef
package/postgresql/postgresql.service +8 -4
@@ -3,7 +3,7 @@ Description=PostgreSQL database server After=network.target [Service] -Type=forking +Type=notify # start timeout disabled because initdb may run a little # longer (eg. 5 minutes on RaspberryPi)
@@ -12,13 +12,17 @@ TimeoutStartSec=0 User=postgres Group=postgres +StandardOutput=syslog +StandardError=syslog SyslogIdentifier=postgres PIDFile=/var/lib/pgsql/postmaster.pid ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi" -ExecStart=/usr/bin/pg_ctl start -D /var/lib/pgsql -w -l /var/lib/pgsql/logfile -ExecReload=/usr/bin/pg_ctl reload -D /var/lib/pgsql -ExecStop=/usr/bin/pg_ctl stop -D /var/lib/pgsql -m fast +ExecStart=/usr/bin/postgres -D /var/lib/pgsql +ExecReload=/usr/bin/kill -HUP $MAINPID +KillMode=mixed +KillSignal=SIGINT +TimeoutSec=0 [Install] WantedBy=multi-user.target
Signature · 1 line
2.18.0
PATCH 1/1 postgresql: change systemd service type to notify
Joseph, All,
On 2018-06-29 11:31 -0700, Joseph Kogut spake thusly:
Quoted 6 lines
During activation,
pg_ctluses exec to start the db server, which causes the service to never finish activating when Type=forking. Upstream recommends configuring --with-systemd and using Type=notify.https://www.postgresql.org/docs/10/static/server-start.html
Signed-off-by Joseph Kogut <[email protected]>
As I said on IRC, this should be actually two patches:
- the first to add the missing conditional code in the .mk;
- the second to change the type of the unit file.
But see below for an actual question...
Quoted 10 lines
--- package/postgresql/postgresql.mk | 8 ++++++++ package/postgresql/postgresql.service | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)package/postgresql/postgresql.mk +0
-0
package/postgresql/postgresql.mk else · line 75
Quoted 6 lines
package/postgresql/postgresql.mk +3
-0@@ -70,6 +70,14 @@ else POSTGRESQL_CONF_OPTS += --without-ldap endif +# required for postgresql.service Type=notify +ifeq ($(BR2_PACKAGE_SYSTEMD),y) +POSTGRESQL_DEPENDENCIES += systemd
Is it a build-time dependency at all, or is it needed only at runtime?
Regards,
Yann E. MORIN.
Quoted 49 lines
package/postgresql/postgresql.mk +5
-0+POSTGRESQL_CONF_OPTS += --with-systemd +else +POSTGRESQL_CONF_OPTS += --without-systemd +endif + define POSTGRESQL_USERS postgres -1 postgres -1 * /var/lib/pgsql /bin/sh - PostgreSQL Server endefpackage/postgresql/postgresql.service +8
-4@@ -3,7 +3,7 @@ Description=PostgreSQL database server After=network.target [Service] -Type=forking +Type=notify # start timeout disabled because initdb may run a little # longer (eg. 5 minutes on RaspberryPi)@@ -12,13 +12,17 @@ TimeoutStartSec=0 User=postgres Group=postgres +StandardOutput=syslog +StandardError=syslog SyslogIdentifier=postgres PIDFile=/var/lib/pgsql/postmaster.pid ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi" -ExecStart=/usr/bin/pg_ctl start -D /var/lib/pgsql -w -l /var/lib/pgsql/logfile -ExecReload=/usr/bin/pg_ctl reload -D /var/lib/pgsql -ExecStop=/usr/bin/pg_ctl stop -D /var/lib/pgsql -m fast +ExecStart=/usr/bin/postgres -D /var/lib/pgsql +ExecReload=/usr/bin/kill -HUP $MAINPID +KillMode=mixed +KillSignal=SIGINT +TimeoutSec=0 [Install] WantedBy=multi-user.targetSignature · 6 lines
2.18.0 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 postgresql: change systemd service type to notify
Joseph, All,
On 2018-08-21 23:47 +0200, Yann E. MORIN spake thusly:
Quoted 11 lines
On 2018-06-29 11:31 -0700, Joseph Kogut spake thusly:
Quoted 6 lines
During activation,
pg_ctluses exec to start the db server, which causes the service to never finish activating when Type=forking. Upstream recommends configuring --with-systemd and using Type=notify.https://www.postgresql.org/docs/10/static/server-start.html
Signed-off-by Joseph Kogut <[email protected]>As I said on IRC, this should be actually two patches:
- the first to add the missing conditional code in the .mk;
- the second to change the type of the unit file.
And now that I have read the upstream doc you pointed to (sorry for delaying that), maybe it makes sense to have a single patch afterall.
Upstream says:
When using systemd, you can use the following service unit file [...]
Using Type=notify requires that the server binary was built with configure --with-systemd.
So, it is quite sensible that the type of the unit file is changed, and that the same commit also adds the conditional code in the .mk file. But that warrants a bit more explanations in the commit log, maybe just by quoting the same as I did above?
Also, why don't we use just the unit file suggested by upstream, instead of our own canned version?
Regards,
Yann E. MORIN.
Quoted 85 lines
But see below for an actual question...
Quoted 10 lines
--- package/postgresql/postgresql.mk | 8 ++++++++ package/postgresql/postgresql.service | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)package/postgresql/postgresql.mk +0
-0package/postgresql/postgresql.mk else · line 75
Quoted 6 lines
package/postgresql/postgresql.mk +3
-0@@ -70,6 +70,14 @@ else POSTGRESQL_CONF_OPTS += --without-ldap endif +# required for postgresql.service Type=notify +ifeq ($(BR2_PACKAGE_SYSTEMD),y) +POSTGRESQL_DEPENDENCIES += systemdIs it a build-time dependency at all, or is it needed only at runtime?
Regards,
Yann E. MORIN.Quoted 49 lines
package/postgresql/postgresql.mk +5
-0+POSTGRESQL_CONF_OPTS += --with-systemd +else +POSTGRESQL_CONF_OPTS += --without-systemd +endif + define POSTGRESQL_USERS postgres -1 postgres -1 * /var/lib/pgsql /bin/sh - PostgreSQL Server endefpackage/postgresql/postgresql.service +8
-4@@ -3,7 +3,7 @@ Description=PostgreSQL database server After=network.target [Service] -Type=forking +Type=notify # start timeout disabled because initdb may run a little # longer (eg. 5 minutes on RaspberryPi)@@ -12,13 +12,17 @@ TimeoutStartSec=0 User=postgres Group=postgres +StandardOutput=syslog +StandardError=syslog SyslogIdentifier=postgres PIDFile=/var/lib/pgsql/postmaster.pid ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi" -ExecStart=/usr/bin/pg_ctl start -D /var/lib/pgsql -w -l /var/lib/pgsql/logfile -ExecReload=/usr/bin/pg_ctl reload -D /var/lib/pgsql -ExecStop=/usr/bin/pg_ctl stop -D /var/lib/pgsql -m fast +ExecStart=/usr/bin/postgres -D /var/lib/pgsql +ExecReload=/usr/bin/kill -HUP $MAINPID +KillMode=mixed +KillSignal=SIGINT +TimeoutSec=0 [Install] WantedBy=multi-user.targetSignature · 6 lines
2.18.0 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildrootSignature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 postgresql: change systemd service type to notify
Hi Yann,
Quoted 26 lines · Yann E. MORIN
Joseph, All,
On 2018-08-21 23:47 +0200, Yann E. MORIN spake thusly:
Quoted 11 lines
On 2018-06-29 11:31 -0700, Joseph Kogut spake thusly:
Quoted 6 lines
During activation,
pg_ctluses exec to start the db server, which causes the service to never finish activating when Type=forking. Upstream recommends configuring --with-systemd and using Type=notify.https://www.postgresql.org/docs/10/static/server-start.html
Signed-off-by Joseph Kogut <[email protected]>As I said on IRC, this should be actually two patches:
- the first to add the missing conditional code in the .mk;
- the second to change the type of the unit file.And now that I have read the upstream doc you pointed to (sorry for delaying that), maybe it makes sense to have a single patch afterall.
Upstream says:
When using systemd, you can use the following service unit file [...]
Using Type=notify requires that the server binary was built with configure --with-systemd.
Quoted 5 lines
So, it is quite sensible that the type of the unit file is changed, and that the same commit also adds the conditional code in the .mk file. But that warrants a bit more explanations in the commit log, maybe just by quoting the same as I did above?
Good point.
Quoted 3 lines
Also, why don't we use just the unit file suggested by upstream, instead of our own canned version?
There's a section of the existing service that leads me to believe that initializing the database on low-powered devices such as the RPi suffers issues with timing out using the upstream service.
Review TimeoutStartSec=0
Quoted 3 lines
# start timeout disabled because initdb may run a little # longer (eg. 5 minutes on RaspberryPi)(quoted diff) +0
-0@@ -12,13 +12,17 @@ TimeoutStartSec=0
I haven't tested this, so I don't know if it's necessary. I assume the original author put it there for a reason, and I lack a compelling reason to remove it.
Additionally, our paths are different from upstream, as it seems they reference the postgres binary at /usr/local/pgsql/bin, and ours is simply at /usr/bin.
Quoted 24 lines
(quoted diff) +0
-0Regards,Yann E. MORIN.
Quoted 21 lines
But see below for an actual question...
Quoted 10 lines
--- package/postgresql/postgresql.mk | 8 ++++++++ package/postgresql/postgresql.service | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)package/postgresql/postgresql.mk +0
-0package/postgresql/postgresql.mk else · line 75
Quoted 6 lines
package/postgresql/postgresql.mk +3
-0@@ -70,6 +70,14 @@ else POSTGRESQL_CONF_OPTS += --without-ldap endif +# required for postgresql.service Type=notify +ifeq ($(BR2_PACKAGE_SYSTEMD),y) +POSTGRESQL_DEPENDENCIES += systemdIs it a build-time dependency at all, or is it needed only at runtime?
It is a build-time dependency.
https://github.com/postgres/postgres/blob/master/src/backend/postmaster/postmaster.c#L88
Quoted 65 lines
Quoted 59 lines
Regards,
Yann E. MORIN.Quoted 45 lines
package/postgresql/postgresql.mk +5
-0+POSTGRESQL_CONF_OPTS += --with-systemd +else +POSTGRESQL_CONF_OPTS += --without-systemd +endif + define POSTGRESQL_USERS postgres -1 postgres -1 * /var/lib/pgsql /bin/sh - PostgreSQL Server endefpackage/postgresql/postgresql.service +8
-5@@ -3,7 +3,7 @@ Description=PostgreSQL database server After=network.target [Service] -Type=forking +Type=notify # start timeout disabled because initdb may run a little # longer (eg. 5 minutes on RaspberryPi)@@ -12,13 +12,17 @@ TimeoutStartSec=0 User=postgres Group=postgres +StandardOutput=syslog +StandardError=syslog SyslogIdentifier=postgres PIDFile=/var/lib/pgsql/postmaster.pid ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi" -ExecStart=/usr/bin/pg_ctl start -D /var/lib/pgsql -w -l /var/lib/pgsql/logfile -ExecReload=/usr/bin/pg_ctl reload -D /var/lib/pgsql -ExecStop=/usr/bin/pg_ctl stop -D /var/lib/pgsql -m fast +ExecStart=/usr/bin/postgres -D /var/lib/pgsql +ExecReload=/usr/bin/kill -HUP $MAINPID +KillMode=mixed +KillSignal=SIGINT +TimeoutSec=0 [Install] WantedBy=multi-user.target --2.18.0
Quoted 4 lines
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot--
.-----------------.--------------------.------------------.--------------------.| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |Quoted 5 lines
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Quoted 7 lines
--
.-----------------.--------------------.------------------.--------------------.| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |'------------------------------^-------^------------------^--------------------'
Best,
Joseph
PATCH 1/1 postgresql: change systemd service type to notify
In reply to Joseph KogutFrom: Joseph Kogut <[email protected]>
During activation, pg_ctl uses exec to start the db server, which causes the service to never finish activating when Type=forking. Upstream recommends configuring --with-systemd and using Type=notify.
https://www.postgresql.org/docs/10/static/server-start.html
Upstream says:
When using systemd, you can use the following service unit file [...]
Using Type=notify requires that the server binary was built with configure --with-systemd.
--- package/postgresql/postgresql.mk | 8 ++++++++ package/postgresql/postgresql.service | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
package/postgresql/postgresql.mk +8 -0
@@ -83,6 +83,14 @@ else POSTGRESQL_CONF_OPTS += --without-libxml endif +# required for postgresql.service Type=notify +ifeq ($(BR2_PACKAGE_SYSTEMD),y) +POSTGRESQL_DEPENDENCIES += systemd +POSTGRESQL_CONF_OPTS += --with-systemd +else +POSTGRESQL_CONF_OPTS += --without-systemd +endif + define POSTGRESQL_USERS postgres -1 postgres -1 * /var/lib/pgsql /bin/sh - PostgreSQL Server endef
package/postgresql/postgresql.service +8 -4
@@ -3,7 +3,7 @@ Description=PostgreSQL database server After=network.target [Service] -Type=forking +Type=notify # start timeout disabled because initdb may run a little # longer (eg. 5 minutes on RaspberryPi)
@@ -12,13 +12,17 @@ TimeoutStartSec=0 User=postgres Group=postgres +StandardOutput=syslog +StandardError=syslog SyslogIdentifier=postgres PIDFile=/var/lib/pgsql/postmaster.pid ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi" -ExecStart=/usr/bin/pg_ctl start -D /var/lib/pgsql -w -l /var/lib/pgsql/logfile -ExecReload=/usr/bin/pg_ctl reload -D /var/lib/pgsql -ExecStop=/usr/bin/pg_ctl stop -D /var/lib/pgsql -m fast +ExecStart=/usr/bin/postgres -D /var/lib/pgsql +ExecReload=/usr/bin/kill -HUP $MAINPID +KillMode=mixed +KillSignal=SIGINT +TimeoutSec=0 [Install] WantedBy=multi-user.target
Signature · 1 line
2.19.2
Thomas Petazzoni
AppliedPATCH 1/1 postgresql: change systemd service type to notify
Quoted 14 lines · On Mon, 4 Feb 2019 19:53:40 +0100 Titouan Christophe…
From: Joseph Kogut <[email protected]>
During activation,
pg_ctluses exec to start the db server, which causes the service to never finish activating when Type=forking. Upstream recommends configuring --with-systemd and using Type=notify.https://www.postgresql.org/docs/10/static/server-start.html
Upstream says:
When using systemd, you can use the following service unit file [...]
Using Type=notify requires that the server binary was built with configure --with-systemd.
Quoted 6 lines
Signed-off-by Joseph Kogut <[email protected]>Signed-off-by Titouan Christophe <[email protected]>--- package/postgresql/postgresql.mk | 8 ++++++++ package/postgresql/postgresql.service | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 postgresql: change systemd service type to notify
In reply to Titouan ChristopheQuoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Titouan" == Titouan Christophe <[email protected]> writes:
From: Joseph Kogut <[email protected]>
During activation,pg_ctluses exec to start the db server, which causes the service to never finish activating when Type=forking. Upstream recommends configuring --with-systemd and using Type=notify.
Quoted 8 lines
Upstream says:
When using systemd, you can use the following service unit file [...]
Using Type=notify requires that the server binary was built with configure --with-systemd.Signed-off-by Joseph Kogut <[email protected]>Signed-off-by Titouan Christophe <[email protected]>
Committed to 2018.11.x, thanks.
Quoted 65 lines
--- package/postgresql/postgresql.mk | 8 ++++++++ package/postgresql/postgresql.service | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)package/postgresql/postgresql.mk +8
-0@@ -83,6 +83,14 @@ else POSTGRESQL_CONF_OPTS += --without-libxml endif +# required for postgresql.service Type=notify +ifeq ($(BR2_PACKAGE_SYSTEMD),y) +POSTGRESQL_DEPENDENCIES += systemd +POSTGRESQL_CONF_OPTS += --with-systemd +else +POSTGRESQL_CONF_OPTS += --without-systemd +endif + define POSTGRESQL_USERS postgres -1 postgres -1 * /var/lib/pgsql /bin/sh - PostgreSQL Server endefpackage/postgresql/postgresql.service +8
-4@@ -3,7 +3,7 @@ Description=PostgreSQL database server After=network.target [Service] -Type=forking +Type=notify # start timeout disabled because initdb may run a little # longer (eg. 5 minutes on RaspberryPi)@@ -12,13 +12,17 @@ TimeoutStartSec=0 User=postgres Group=postgres +StandardOutput=syslog +StandardError=syslog SyslogIdentifier=postgres PIDFile=/var/lib/pgsql/postmaster.pid ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi" -ExecStart=/usr/bin/pg_ctl start -D /var/lib/pgsql -w -l /var/lib/pgsql/logfile -ExecReload=/usr/bin/pg_ctl reload -D /var/lib/pgsql -ExecStop=/usr/bin/pg_ctl stop -D /var/lib/pgsql -m fast +ExecStart=/usr/bin/postgres -D /var/lib/pgsql +ExecReload=/usr/bin/kill -HUP $MAINPID +KillMode=mixed +KillSignal=SIGINT +TimeoutSec=0 [Install] WantedBy=multi-user.targetSignature · 6 lines
2.19.2 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 1 line
Bye, Peter Korsgaard