Bug 56843

Summary: postgres /etc/rc.d/rc3.d/S97postgresql
Product: [Retired] Red Hat Linux Reporter: Need Real Name <dleonard>
Component: postgresqlAssignee: Trond Eivind Glomsrxd <teg>
Status: CLOSED NOTABUG QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dleonard
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-11-28 18:09:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2001-11-28 18:09:37 UTC
Description of Problem:
using runlevel editor to put postgres in runlevels 3,4,5 to start
postmaster at boot time fails; postmaster is not running.

Version-Release number of selected component (if applicable):
postgresl-server-7.0.3-8 
How Reproducible:
every time

Steps to Reproduce (glory details, maybe I do something wrong early):
1. change postgres user shell to tcsh using Control Panel->User
2. logout/login as postgres
3. initdb <return>
4. /usr/bin/postmaster -D /var/lib/pgsql <return>
5. createdb trend24new <return>
6. cp /root/OCC_Support_CD/trend24new /var/lib/pgsql <return>
7. cd /var/lib/pgsql <return>
8. chown postgres.postgres trend24new <return>
9. psql -e trend24new < trend24new <return>
     (trend24new is a flat command file, created with
      pg_dump trend24new > trend24new.out <return>
      mv trend24new.out trend24new <return>)
10. /usr/bin/pg_ctl -D /var/lib/pgsql stop <return>
11. /usr/bin/pg_ctl -D /var/lib/pgsql start <return>
   and can query the database
12. Now in the run level editor, add postgresql to the start 
   column 3,4,5 by copying and pasting it from the far left column 
   to start columns 3, 4, and 5.  Make it S97postgresql.
13. logout and reboot, login as postgres.  Actual Results:


Expected Results:

"psql trend24new" should connect -- it doesn't

ps -ef | grep postmaster should show it running  -- it doesn't

Actual results:
"psql trend24new" responds with error, unable to connect
"ps -ef | grep postmaster" shows postmaster isn't running

Additional Information:
I fixed by changing the /etc/rc.d/init.d/postgresl line 128 from:

su -l postgres -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster  \
                                   start >/dev/null 2>&1" < /dev/null

to:

su -l postgres -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster start"
\  < /dev/null > /dev/null 2>& 1

which matches the bash shell redirect used about twenty lines above.

Then reboot and login as postgres, and commanding "psql trend24new"
connects, the daemon postmaster is running, and the query:

select distinct msid from tbl_trend_data where msid like '2CHTRPZT';

responds with:

 msid
----------
2CHTRPZT
(1 row)

Comment 1 Trond Eivind Glomsrxd 2001-11-28 22:38:02 UTC
1) You shouldn't change the shell to tcsh for system users.
2) You shouldn't do initdb manually, it initializes the 

If you do, it should work. You probably created some permission problems by
running initdb manually.

Comment 2 Need Real Name 2001-11-28 23:07:10 UTC
The first comment about changing the shell works; I changed postgres shell back
to bash, restored the state of /etc/rc.d/init.d/postgresl to factory, logged out
and rebooted.  Then logged in as postgres; and postmaster was running and I
could connect and query okay.

I wasn't aware of the rule "that you shouldn't changed system user's shells". 
Thought the the first line in /etc/rc.d/init.d/postgresl "#! /bin/bash" dictated
this.  Of course redirection does feel the basic shell I suppose.

Seems to me that my change makes things more robust, though, allowing the user
to change postgres's shell.

Comment about doing initdb and permissions seems irrelevant.   Man pages on
initdb indicate it is an allowable user command, "to create a new database
installation".  Perhaps I can do without it though, and start at my step 4.