* [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C
@ 2023-10-10 16:45 Adam Duskett
2023-10-10 16:45 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_postgresql.py: new test Adam Duskett
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Adam Duskett @ 2023-10-10 16:45 UTC (permalink / raw)
To: buildroot; +Cc: Maxim Kochetkov, Adam Duskett, Peter Seiderer
From: Peter Seiderer <ps.report@gmx.net>
From this patch from Sept. 20, 2020, postgresql.service is still broken on
startup:
Postgresql systemd startup fails with:
Starting PostgreSQL database server...
[FAILED] Failed to start PostgreSQL database server.
See 'systemctl status postgresql.service' for details.
$ systemctl status postgresql.service | cat
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-09-12 12:16:35 UTC; 35s ago
Process: 164 ExecStartPre=/bin/sh -c if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi (code=exited, status=1/FAILURE)
Sep 12 12:16:35 buildroot systemd[1]: Starting PostgreSQL database server...
Sep 12 12:16:35 buildroot postgres[166]: The files belonging to this database system will be owned by user "postgres".
Sep 12 12:16:35 buildroot postgres[166]: This user must also own the server process.
Sep 12 12:16:35 buildroot postgres[166]: initdb: error: invalid locale settings; check LANG and LC_* environment variables
Sep 12 12:16:35 buildroot systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
Sep 12 12:16:35 buildroot postgres[164]: pg_ctl: database system initialization failed
Sep 12 12:16:35 buildroot systemd[1]: postgresql.service: Failed with result 'exit-code'.
Sep 12 12:16:35 buildroot systemd[1]: Failed to start PostgreSQL database server.
Fix it by setting a sane/always available locale=C in the startup files.
A similare failure/fix was reported by Pascal de Bruijn ([1]), but with
en_US.UTF-8 instead of C.
[1] http://lists.busybox.net/pipermail/buildroot/2019-November/266700.html
Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
package/postgresql/postgresql.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/postgresql/postgresql.service b/package/postgresql/postgresql.service
index 539eea8964..245375b77d 100644
--- a/package/postgresql/postgresql.service
+++ b/package/postgresql/postgresql.service
@@ -16,7 +16,7 @@ StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=postgres
-ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi"
+ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=C; fi"
ExecStart=/usr/bin/postgres -D /var/lib/pgsql
ExecReload=/usr/bin/kill -HUP $MAINPID
KillMode=mixed
--
2.41.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread* [Buildroot] [PATCH 2/2] support/testing/tests/package/test_postgresql.py: new test
2023-10-10 16:45 [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C Adam Duskett
@ 2023-10-10 16:45 ` Adam Duskett
2023-11-01 16:43 ` Thomas Petazzoni via buildroot
2023-10-10 17:02 ` [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C Maxim Kochetkov via buildroot
2023-11-01 16:37 ` Thomas Petazzoni via buildroot
2 siblings, 1 reply; 5+ messages in thread
From: Adam Duskett @ 2023-10-10 16:45 UTC (permalink / raw)
To: buildroot; +Cc: Maxim Kochetkov, Adam Duskett
Perform a basic check that performs the following:
- Check if /var/lib/pgsql/postmaster.pid exists.
- Check if 'psql -c SHOW server_version;' returns sucessfully.
Note: systemd takes quite a while to start up, so check the output of
`systemctl is-active postgresql` until it shows "active" with a timeout
of 15 seconds.
Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
DEVELOPERS | 1 +
.../testing/tests/package/test_postgresql.py | 76 +++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 support/testing/tests/package/test_postgresql.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 3fffc4346c..2421bf8ff7 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -38,6 +38,7 @@ F: package/flutter-gallery/
F: package/flutter-pi/
F: package/flutter-sdk-bin/
F: support/testing/tests/package/test_flutter.py
+F: support/testing/tests/package/test_postgresql.py
N: Adam Heinrich <adam@adamh.cz>
F: package/jack1/
diff --git a/support/testing/tests/package/test_postgresql.py b/support/testing/tests/package/test_postgresql.py
new file mode 100644
index 0000000000..b510a02f44
--- /dev/null
+++ b/support/testing/tests/package/test_postgresql.py
@@ -0,0 +1,76 @@
+import os
+import time
+import infra.basetest
+
+
+class TestPostgreSQLInitd(infra.basetest.BRTest):
+ config: str = """
+ BR2_arm=y
+ BR2_cortex_a9=y
+ BR2_ARM_ENABLE_VFP=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+ BR2_PER_PACKAGE_DIRECTORIES=y
+ BR2_PACKAGE_POSTGRESQL=y
+ BR2_TARGET_ROOTFS_EXT2=y
+ BR2_TARGET_ROOTFS_EXT2_4=y
+ BR2_TARGET_ROOTFS_EXT2_SIZE="128M"
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+
+ def test_run(self):
+ img = os.path.join(self.builddir, "images", "rootfs.ext2")
+ self.emulator.boot(
+ arch="armv7",
+ kernel="builtin",
+ kernel_cmdline=["root=/dev/mmcblk0"],
+ options=["-drive", f"file={img},if=sd,format=raw"])
+ self.emulator.login()
+
+ # Check if the Daemon is running
+ self.assertRunOk("ls /var/lib/pgsql/postmaster.pid")
+
+ # Check if we can connect to the database.
+ self.assertRunOk("su postgres -c \"psql -c 'SHOW server_version;'\"")
+
+
+class TestPostgreSQLSystemd(infra.basetest.BRTest):
+ config: str = """
+ BR2_arm=y
+ BR2_cortex_a9=y
+ BR2_ARM_ENABLE_VFP=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+ BR2_INIT_SYSTEMD=y
+ BR2_PER_PACKAGE_DIRECTORIES=y
+ BR2_PACKAGE_POSTGRESQL=y
+ BR2_TARGET_ROOTFS_EXT2=y
+ BR2_TARGET_ROOTFS_EXT2_4=y
+ BR2_TARGET_ROOTFS_EXT2_SIZE="128M"
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+
+ def test_run(self):
+ img = os.path.join(self.builddir, "images", "rootfs.ext2")
+ self.emulator.boot(
+ arch="armv7",
+ kernel="builtin",
+ kernel_cmdline=["root=/dev/mmcblk0"],
+ options=["-drive", f"file={img},if=sd,format=raw"])
+ self.emulator.login()
+
+ # Check if the Daemon is running
+ self.assertRunOk("ls /var/lib/pgsql/postmaster.pid")
+
+ # It may take some time for PostgreSQL to finish startup. Give it at least 15 seconds.
+ is_active = False
+ for i in range(15):
+ output, _ = self.emulator.run("systemctl is-active postgresql")
+ if output[0] == "active":
+ is_active = True
+ break
+ time.sleep(1)
+ if not is_active:
+ self.fail("postgresql failed to active.")
+ # Check if we can connect to the database.
+ self.assertRunOk("cd / && su postgres -c \"psql -c 'SHOW server_version;'\"")
--
2.41.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [Buildroot] [PATCH 2/2] support/testing/tests/package/test_postgresql.py: new test
2023-10-10 16:45 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_postgresql.py: new test Adam Duskett
@ 2023-11-01 16:43 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-11-01 16:43 UTC (permalink / raw)
To: Adam Duskett; +Cc: Maxim Kochetkov, buildroot
Hello,
On Tue, 10 Oct 2023 18:45:54 +0200
Adam Duskett <adam.duskett@amarulasolutions.com> wrote:
> +class TestPostgreSQLInitd(infra.basetest.BRTest):
Initd is not a very good name. To me Initd doesn't mean
"Sysvinit/Busybox init".
I see the polkit tests already use that naming, though.
> + config: str = """
Any reason to use this syntax? I don't have anything against it, but
it's not consistent with how we define the configuration in other test
cases, and I like consistency.
> + BR2_arm=y
> + BR2_cortex_a9=y
> + BR2_ARM_ENABLE_VFP=y
> + BR2_TOOLCHAIN_EXTERNAL=y
> + BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
Any reason not to use BASIC_TOOLCHAIN_CONFIG instead?
> + BR2_PER_PACKAGE_DIRECTORIES=y
Not needed.
> + BR2_PACKAGE_POSTGRESQL=y
> + BR2_TARGET_ROOTFS_EXT2=y
> + BR2_TARGET_ROOTFS_EXT2_4=y
> + BR2_TARGET_ROOTFS_EXT2_SIZE="128M"
> + # BR2_TARGET_ROOTFS_TAR is not set
> + """
> +
> + def test_run(self):
> + img = os.path.join(self.builddir, "images", "rootfs.ext2")
> + self.emulator.boot(
> + arch="armv7",
This would have to be changed to arvm5 if you use the
BASIC_TOOLCHAIN_CONFIG.
Long term, maybe we could consider changing the BASIC_TOOLCHAIN_CONFIG
to use ARMv7, would perhaps be more sensible than the aging ARMv5
architecture.
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C
2023-10-10 16:45 [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C Adam Duskett
2023-10-10 16:45 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_postgresql.py: new test Adam Duskett
@ 2023-10-10 17:02 ` Maxim Kochetkov via buildroot
2023-11-01 16:37 ` Thomas Petazzoni via buildroot
2 siblings, 0 replies; 5+ messages in thread
From: Maxim Kochetkov via buildroot @ 2023-10-10 17:02 UTC (permalink / raw)
To: Adam Duskett, buildroot; +Cc: Peter Seiderer
On 10.10.2023 19:45, Adam Duskett wrote:
> From: Peter Seiderer <ps.report@gmx.net>
>
> From this patch from Sept. 20, 2020, postgresql.service is still broken on
> startup:
>
> Postgresql systemd startup fails with:
> Signed-off-by: Peter Seiderer <ps.report@gmx.net>
> Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
Reviewed-by: Maxim Kochetkov <fido_max@inbox.ru>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C
2023-10-10 16:45 [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C Adam Duskett
2023-10-10 16:45 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_postgresql.py: new test Adam Duskett
2023-10-10 17:02 ` [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C Maxim Kochetkov via buildroot
@ 2023-11-01 16:37 ` Thomas Petazzoni via buildroot
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-11-01 16:37 UTC (permalink / raw)
To: Adam Duskett; +Cc: Maxim Kochetkov, Peter Seiderer, buildroot
On Tue, 10 Oct 2023 18:45:53 +0200
Adam Duskett <adam.duskett@amarulasolutions.com> wrote:
> From: Peter Seiderer <ps.report@gmx.net>
>
> From this patch from Sept. 20, 2020, postgresql.service is still broken on
> startup:
Which "this patch" ?
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-01 16:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-10 16:45 [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C Adam Duskett
2023-10-10 16:45 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_postgresql.py: new test Adam Duskett
2023-11-01 16:43 ` Thomas Petazzoni via buildroot
2023-10-10 17:02 ` [Buildroot] [PATCH 1/2] package/postgresql/postgresql.service: set locale for initdb to C Maxim Kochetkov via buildroot
2023-11-01 16:37 ` Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox