Thread: TRAP during backend startup

TRAP during backend startup

From
Grant Finnemore
Date:
Hi all,

After an installation from CVS tip, I start the postmaster with the
-d(anything) flag. The postmaster starts up normally. I then try to
connect using psql, and either a TRAP is triggered (not using -A 0)
or an invalid cache id is found (using -A 0)

When I start the postmaster without the -d flag, I have no problems
in connecting from psql.

Any ideas?

Regards,
Grant

Necessary info:
. Sources are CVS tip, pulled today
. uname -a
Linux localhost.localdomain 2.4.20-19.9 #1 Tue Jul 15 17:18:13 EDT 2003 i686 
i686 i386 GNU/Linux
.  gcc --version
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

. make maintainer-clean check install
./configure --with-java --prefix=/home/grant/bin/pgsql/ 
--with-integer-datetimes --enable-debug --enable-cassert

[grant@localhost pgsql-HEAD]$ postmaster -d1
LOG:  database system was shut down at 2004-04-07 12:51:06 SAST
LOG:  checkpoint record is at 0/9DCE0C
LOG:  redo record is at 0/9DCE0C; undo record is at 0/0; shutdown TRUE
LOG:  next transaction ID: 465; next OID: 17208
LOG:  database system is ready

Now, from another console do : psql -l

TRAP: BadState("!(((bool) ((CurrentUserId) != 0)))", File: "miscinit.c", Line: 252)
LOG:  server process (PID 16802) was terminated by signal 6
LOG:  terminating any other active server processes


[grant@localhost pgsql-HEAD]$ postmaster -A 0 -d1
LOG:  database system was shut down at 2004-04-07 12:51:36 SAST
LOG:  checkpoint record is at 0/9DCE8C
LOG:  redo record is at 0/9DCE8C; undo record is at 0/0; shutdown TRUE
LOG:  next transaction ID: 465; next OID: 17208
LOG:  database system is ready
FATAL:  invalid cache id: 30



Re: TRAP during backend startup

From
Tom Lane
Date:
Grant Finnemore <grantf@guruhut.co.za> writes:
> After an installation from CVS tip, I start the postmaster with the
> -d(anything) flag. The postmaster starts up normally. I then try to
> connect using psql, and either a TRAP is triggered (not using -A 0)
> or an invalid cache id is found (using -A 0)

The backtrace points the finger at Bruce's recent changes in guc.c:
he is trying to call superuser() before the data is available.  Bruce,
please fix or revert.
        regards, tom lane

#4  0x2a1010 in ExceptionalCondition (   conditionName=0xc21a0 "!(((bool) ((CurrentUserId) != 0)))",
errorType=0xc2130"BadState", fileName=0xc20d0 "miscinit.c",   lineNumber=252) at assert.c:46
 
#5  0x2aac18 in GetUserId () at miscinit.c:252
#6  0x2ad1dc in superuser () at superuser.c:37
#7  0x2afb64 in set_config_option (name=0x0, value=0x7b00dc28 "", context=258,   source=PGC_S_ARGV, isLocal=0,
changeVal=1)at guc.c:3026
 
#8  0x2affb8 in SetConfigOption (name=0x7b00dc48 "",   value=0x6 <Address 0x6 out of bounds>, context=PGC_INTERNAL,
source=2063656604)at guc.c:3195
 
#9  0x221d20 in PostgresMain (argc=5, argv=0x40050a40,   username=0x40050a00 "postgres") at postgres.c:2271
#10 0x1ee494 in BackendRun (port=0x4005ced0) at postmaster.c:2697
#11 0x1edc74 in BackendStartup (port=0x4005ced0) at postmaster.c:2330
#12 0x1ec3e8 in ServerLoop () at postmaster.c:1167
#13 0x1ebe90 in PostmasterMain (argc=4, argv=0x7b03ab14) at postmaster.c:928
#14 0x1ac368 in main (argc=4, argv=0x7b03ab14) at main.c:257
#15 0xc0065784 in ?? () from /usr/lib/libc.1


Re: TRAP during backend startup

From
Bruce Momjian
Date:
Tom Lane wrote:
> Grant Finnemore <grantf@guruhut.co.za> writes:
> > After an installation from CVS tip, I start the postmaster with the
> > -d(anything) flag. The postmaster starts up normally. I then try to
> > connect using psql, and either a TRAP is triggered (not using -A 0)
> > or an invalid cache id is found (using -A 0)
> 
> The backtrace points the finger at Bruce's recent changes in guc.c:
> he is trying to call superuser() before the data is available.  Bruce,
> please fix or revert.

OK, I moved superuser() back down to the bottom of the if() statement
tree.  I had moved it up in the patch in hopes of reducing code
duplication, but obviously that didn't work.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073