RE: [EXT] Re: BUG #17469: postgresql-11.service file not configured to match setup/initdb options specified

From: "Joe Hebert (jhebert)" <jhebert(at)micron(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: RE: [EXT] Re: BUG #17469: postgresql-11.service file not configured to match setup/initdb options specified
Date: 2022-04-29 17:34:44
Message-ID: SN4PR0801MB7935B3791EF5A14F7E4EDDC6C7FC9@SN4PR0801MB7935.namprd08.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Micron Confidential

Hi David,

Thanks for your response. Initially I was attempting to use sudo to initialize the DB per the sample commands provided at the following web page:

https://www.postgresql.org/download/linux/redhat/

From the recommended script on that page:
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
sudo systemctl enable postgresql-11

Due to encountering error "failed to find PGDATA setting in /postgres/data/datafiles.service", it looked like I had encountered bug #15108<https://www.postgresql.org/message-id/152094313655.1225.9005657715834235284%40wrigleys.postgresql.org>, which led me to use initdb instead of postgresql-11-setup per Sergei's recommendation. Below are the actual commands I used, which were successful:

/usr/pgsql-11/bin/initdb -A ldap -E utf8 -D /postgres/data/datafiles -X /postgres/tranlog
sudo systemctl enable postgresql-11

Anyway, since the above recommended commands were to be run with sudo, I presumed the systemctl template for postgresql would have been generated with the -D option value I provided embedded in the PGDATA environment variable in the template (/usr/lib/systemd/system/postgresql-11.service). However, after realizing that I could not use sudo with initdb, it makes sense that it would not integrate with the postgresql-11.service template.

I guess I am not sure where that template file comes from (and which process generates it), but it would be nice if we didn't have to edit the template every time we install. On my side, finding a way to edit the file (sudo systemctl edit --full postgresql-11) in an automated way (for unattended installs) may be problematic.

Hopefully this helps explain the path I took and my thought process.

Joe

Micron Confidential
From: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Sent: Thursday, April 28, 2022 5:58 PM
To: Joe Hebert (jhebert) <jhebert(at)micron(dot)com>; PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: [EXT] Re: BUG #17469: postgresql-11.service file not configured to match setup/initdb options specified

CAUTION: EXTERNAL EMAIL. Do not click links or open attachments unless you recognize the sender and were expecting this message.

On Thu, Apr 28, 2022 at 4:42 PM PG Bug reporting form <noreply(at)postgresql(dot)org<mailto:noreply(at)postgresql(dot)org>> wrote:
The following bug has been logged on the website:

Bug reference: 17469
Logged by: Joe Hebert
Email address: jhebert(at)micron(dot)com<mailto:jhebert(at)micron(dot)com>
PostgreSQL version: 11.11
Operating system: RHEL 8.5
Description:

After researching further, I reviewed file
/usr/lib/systemd/system/postgresql-11.service
and found the following offending line:
Environment=PGDATA=/var/lib/pgsql/11/data/

Which should have been set to /postgres/data/datafiles based in the option
provided to the initdb command.

I'm curious to know where you got the idea that initdb integrated with systemd. I'm under the impression it doesn't. PostgreSQL core doesn't generally deal with such platform-specific concerns (i.e., it isn't a feature enhancement we would consider).

If you go against the conventions of your packaged distribution (or do not avail yourself of its tooling) you have to do the customizations yourself.

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2022-04-29 19:19:27 BUG #17473: Custom range type with timestamp doesn't respect precision
Previous Message Pavel Stehule 2022-04-29 09:40:48 Re: BUG #17472: Jsonb[] operations not working