Commit Graph

252 Commits

Author SHA1 Message Date
Bruce Momjian b81844b173 pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
2001-10-25 05:50:21 +00:00
Tom Lane 94daee3cb7 Further cleanup of ps_status setup code. On platforms where the
environment strings need to be moved around, do so when called from
initial startup (main.c), not in init_ps_status.  This eliminates the
former risk of invalidating saved environment-string pointers, since
no code has yet had a chance to grab any such pointers when main.c
is running.
2001-10-22 19:41:38 +00:00
Tom Lane b2e92a712e Fix getopt-vs-init_ps_display problem by copying original argv[] info,
per suggestion from Peter.  Simplify several APIs by transmitting the
original argv location directly from main.c to ps_status.c, instead of
passing it down through several levels of subroutines.
2001-10-21 03:25:36 +00:00
Tom Lane 379268aa62 Proper fix for glibc getopt() botch. Surprising we did not see this
before.
2001-10-19 20:47:09 +00:00
Tom Lane 861a679fc1 Set optreset on platforms that have it before launching postmaster
subprocesses; perhaps this will fix portability problem just noted by
Lockhart.  Also, move test for bad permissions of DataDir to a more
logical place.
2001-10-19 18:19:41 +00:00
Tom Lane 6430e6e283 Ensure that all startup paths (postmaster, standalone postgres, or
bootstrap) check for a valid PG_VERSION file before looking at anything
else in the data directory.  This fixes confusing error report when
trying to start current sources in a pre-7.1 data directory.
Per trouble report from Rich Shepard 10/18/01.
2001-10-19 17:03:08 +00:00
Tom Lane eb133197b6 Move init_ps_display from postgres.c to postmaster.c, putting it
just after receipt of the startup packet.  Now, postmaster children
that are waiting for client authentication response will show as
'postgres: user database host authentication'.  Also, do an
init_ps_display for startup/shutdown/checkpoint subprocesses,
so that they are readily identifiable as well.  Fix an obscure race
condition that could lead to Assert failure in the postmaster ---
attempting to start a checkpoint process before any connections have
been received led to calling PostmasterRandom before setting random_seed.
2001-10-19 00:44:08 +00:00
Tom Lane fcd2e372a7 Consistently use gcc's __attribute__((format)) to check sprintf-style
format strings wherever possible.  Remarkably, this exercise didn't
turn up any inconsistencies, but it seems a good idea for the future.
2001-10-03 21:58:28 +00:00
Tom Lane e43d51fddc ISTM that IsUnderPostmaster should mean we are a child process of the
postmaster ... it should not be set in the postmaster itself.
2001-09-30 20:08:18 +00:00
Tom Lane c1c888a9de Code review for MD5 authorization patch. Clean up some breakage
(salts were always zero!?), add much missing documentation.
2001-09-21 20:31:49 +00:00
Tom Lane 35b7601b04 Add an overall timeout on the client authentication cycle, so that
a hung client or lost connection can't indefinitely block a postmaster
child (not to mention the possibility of deliberate DoS attacks).
Timeout is controlled by new authentication_timeout GUC variable,
which I set to 60 seconds by default ... does that seem reasonable?
2001-09-21 17:06:12 +00:00
Tom Lane 02b1a7fd51 Clean up some confusion about where and how to set whereToSendOutput.
We will no longer try to send elog messages to the client before we have
initialized backend libpq (oops); however, reporting bogus commandline
switches via elog does work now (not irrelevant, because of PGOPTIONS).
Fix problem with inappropriate sending of checkpoint-process messages
to stderr.
2001-09-08 01:10:21 +00:00
Jan Wieck 7e26a8241d Enable SIGTERM and SIGQUIT during client authentication so
the postmaster can kill the forked off processes when shutdown
is requested.

Jan
2001-09-07 16:12:49 +00:00
Tom Lane e67bb7af5a Missed a few places that referred to a compile-time limit on
max_connections.
2001-09-07 00:46:42 +00:00
Tom Lane 863aceb54f Get rid of PID entries in shmem hash table; there is no longer any need
for them, and making them just wastes time during backend startup/shutdown.
Also, remove compile-time MAXBACKENDS limit per long-ago proposal.
You can now set MaxBackends as high as your kernel can stand without
any reconfiguration/recompilation.
2001-09-07 00:27:30 +00:00
Peter Eisentraut 68e5360018 Convert some fprintf's to elog's. 2001-08-30 19:02:42 +00:00
Bruce Momjian da45a0bdb7 Add 4-byte MD5 salt. 2001-08-17 02:59:20 +00:00
Tom Lane e8f1097361 Endeavor to make pgstats buffer process (a) safe and (b) useful.
Make sure it exits immediately when collector process dies --- in old code,
buffer process would hang around and compete with the new buffer process
for packets.  Make sure it doesn't block on writing the pipe when the
collector falls more than a pipeload behind.  Avoid leaking pgstats FDs
into every backend.
2001-08-05 02:06:50 +00:00
Tom Lane dad8e410d0 Fix handling of SIGCHLD, per recent pghackers discussion: on some
platforms system(2) gets confused unless the signal handler is set to
SIG_DFL, not SIG_IGN.  pgstats.c now uses pqsignal() as it should,
not signal().  Also, arrange for the stats collector process to show
a reasonable ID in 'ps', rather than looking like a postmaster.
2001-08-04 00:14:43 +00:00
Tom Lane 77896d1fc9 Cleanup code for preparsing pg_hba.conf and pg_ident.conf. Store line
number in the data structure so that we can give at least a minimally
useful idea of where the mistake is when we issue syntax error messages.
Move the ClientAuthentication() call to where it should have been in
the first place, so that postmaster memory releasing can happen in a
reasonable place also.  Update obsolete comments, correct one real bug
(auth_argument was not picked up correctly).
2001-07-31 22:55:45 +00:00
Bruce Momjian 462b7d46d1 Load pg_hba.conf and pg_ident.conf on startup and SIGHUP into List of
Lists, and use that for user validation.

Bruce Momjian
2001-07-30 14:50:24 +00:00
Tom Lane 31c1fea6a8 Start the stats collector at a less randomly chosen time. Bad idea
to start it before we have acquired the data directory lock; also a
bad idea to start it before we have set up to catch SIGCHLD signals.
2001-07-03 16:52:12 +00:00
Tom Lane 109d50dd35 Under new theory of operation wherein postmaster forks children
immediately, we will fork a child even if the database state does not
permit connections to be accepted (eg, we are in recovery mode).
The child process will correctly reject the connection and exit as
soon as it's finished collecting the connection request message.
However, this means that reaper() must be prepared to see child
process exit signals even while it's waiting for startup or shutdown
process to finish.  As was, a connection request arriving during a
database recovery or shutdown would cause postmaster abort.
2001-07-01 00:06:23 +00:00
Tom Lane f889b12be9 Fix erroneous GUC variable references from commandline-GUC patch. 2001-06-29 16:05:57 +00:00
Tom Lane 2e67a67715 Fix a couple remaining places where GUC variables were assigned to
directly, rather than through SetConfigOption().
2001-06-25 22:56:05 +00:00
Bruce Momjian 6a7f23c213 > Marko Kreen <marko@l-t.ee> writes:
> > secure_ctx changes too.  it will be PGC_BACKEND after '-p'.
>
> Oh, okay, I missed that part.  Could we see the total state of the
> patch --- ie, a diff against current CVS, not a bunch of deltas?
> I've gotten confused about what's in and what's out.

Ok, here it is.  Cleared the ctx comment too - after -p
it will be PGC_BACKEND in any case.

Marko Kreen
2001-06-23 22:23:49 +00:00
Jan Wieck 8d80b0d980 Statistical system views (yet without the config stuff, but
it's hard to keep such massive changes in sync with the tree
so I need to get it in and work from there now).

Jan
2001-06-22 19:16:24 +00:00
Tom Lane f3868f8af9 A bit of code beautification/cleanup of obsolete comments. Rethink
ordering of startup operations in one or two places.
2001-06-21 16:43:24 +00:00
Peter Eisentraut 9b4bfbdc2c Handle reading of startup packet and authentication exchange after forking
a new postmaster child process.  This should eliminate problems with
authentication blocking (e.g., ident, SSL init) and also reduce problems
with the accept queue filling up under heavy load.

The option to send elog output to a different file per backend (postgres -o)
has been disabled for now because the initialization would have to happen
in a different order and it's not clear we want to keep this anyway.
2001-06-20 18:07:56 +00:00
Bruce Momjian 2e81f3d204 Back out SET ALL patch because it is breaking things. 2001-06-19 23:40:10 +00:00
Bruce Momjian 3709a5ada7 RESET ALL secondary patch:
Here is Tomified version of my 2 pending patches.
Dropped the set_.._real change as it is not needed.
Desc would be:

* use GUC for settings from cmdline

Marko Kreen
2001-06-18 23:42:32 +00:00
Tom Lane 2917f0a5dd Tweak startup sequence so that running out of PROC array slots is
detected sooner in backend startup, and is treated as an expected error
(it gives 'Sorry, too many clients already' now).  This allows us not
to have to enforce the MaxBackends limit exactly in the postmaster.
Also, remove ProcRemove() and fold its functionality into ProcKill().
There's no good reason for a backend not to be responsible for removing
its PROC entry, and there are lots of good reasons for the postmaster
not to be touching shared-memory data structures.
2001-06-16 22:58:17 +00:00
Tom Lane 823ab92295 Add missing PG_SETMASK(&BlockSig) to SIGHUP_handler(). 2001-06-14 19:59:24 +00:00
Tom Lane 2938eec7fe Extend GUC concepts of parse_hook and assign_hook to all four supported
datatypes, not only strings.  parse_hook is useless for bool, I suppose,
but it seems possibly useful for int and double to apply variable-specific
constraints that are more complex than simple range limits.  assign_hook
is definitely useful for all datatypes --- we need it right now for bool
to support date cache reset when changing Australian timezone rule setting.
Also, clean up some residual problems with the reset all/show all patch,
including memory leaks and mistaken reset of PostPortNumber.  It seems
best that RESET ALL not touch variables that don't have SUSET or
USERSET context.
2001-06-12 22:54:06 +00:00
Tom Lane 2a6f7ac456 Move temporary files into 'pg_tempfiles' subdirectory of each database
directory (which can be made a symlink to put temp files on another disk).
Add code to delete leftover temp files during postmaster startup.
Bruce, with some kibitzing from Tom.
2001-06-11 04:12:29 +00:00
Bruce Momjian 4ee76ad884 reset all: command line and .conf options change defaults
on RESET ALL those are restored.

show all: GUC + non-GUC.

SHOW ALL, RESET ALL

Marko Kreen
2001-06-07 04:50:57 +00:00
Peter Eisentraut 12c1552066 Mark many strings in backend not covered by elog for translation. Also,
make strings in xlog.c look more like English and less like binary noise.
2001-06-03 14:53:56 +00:00
Bruce Momjian 33f2614aa1 Remove SEP_CHAR, replace with / or '/' as appropriate. 2001-05-30 14:15:27 +00:00
Bruce Momjian f6923ff3ac Oops, only wanted python change in the last commit. Backing out. 2001-05-25 15:45:34 +00:00
Bruce Momjian dffb673692 While changing Cygwin Python to build its core as a DLL (like Win32
Python) to support shared extension modules, I have learned that Guido
prefers the style of the attached patch to solve the above problem.
I feel that this solution is particularly appropriate in this case
because the following:

    PglargeType
    PgType
    PgQueryType

are already being handled in the way that I am proposing for PgSourceType.

Jason Tishler
2001-05-25 15:34:50 +00:00
Peter Eisentraut 47324d7689 Add extern int optreset declaration, per bug report from <info@decc.nl>. 2001-04-19 19:09:23 +00:00
Bruce Momjian 9e1552607a pgindent run. Make it all clean. 2001-03-22 04:01:46 +00:00
Tom Lane 5dd04603b9 Don't go belly-up if fork() fails for a routine checkpoint subprocess.
Just try again later.
2001-03-14 17:58:46 +00:00
Tom Lane 4d14fe0048 XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
  On startup, we fall back to the older checkpoint if the newer one
  is unreadable.  Also, a physical copy of the newest checkpoint record
  is kept in pg_control for possible use in disaster recovery (ie,
  complete loss of pg_xlog).  Also add a version number for pg_control
  itself.  Remove archdir from pg_control; it ought to be a GUC
  parameter, not a special case (not that it's implemented yet anyway).

* Suppress successive checkpoint records when nothing has been entered
  in the WAL log since the last one.  This is not so much to avoid I/O
  as to make it actually useful to keep track of the last two
  checkpoints.  If the things are right next to each other then there's
  not a lot of redundancy gained...

* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
  on alternate bytes.  Polynomial borrowed from ECMA DLT1 standard.

* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.

* Change XID allocation to work more like OID allocation.  (This is of
  dubious necessity, but I think it's a good idea anyway.)

* Fix a number of minor bugs, such as off-by-one logic for XLOG file
  wraparound at the 4 gig mark.

* Add documentation and clean up some coding infelicities; move file
  format declarations out to include files where planned contrib
  utilities can get at them.

* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
  every CHECKPOINT_TIMEOUT seconds, whichever comes first.  It is also
  possible to force a checkpoint by sending SIGUSR1 to the postmaster
  (undocumented feature...)

* Defend against kill -9 postmaster by storing shmem block's key and ID
  in postmaster.pid lockfile, and checking at startup to ensure that no
  processes are still connected to old shmem block (if it still exists).

* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
  stop, for symmetry with postmaster and xlog utilities.  Clean up signal
  handling in bootstrap.c so that xlog utilities launched by postmaster
  will react to signals better.

* Standalone bootstrap now grabs lockfile in target directory, as added
  insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
Tom Lane d18c1d1f51 Truncate incoming username and database name to NAMEDATALEN-1 characters
so that we don't reject overlength names unnecessarily.
2001-02-20 01:34:40 +00:00
Tom Lane 68590993ea Improve error message when startup or shutdown proc fails. 2001-02-11 23:12:28 +00:00
Tom Lane d08741eab5 Restructure the key include files per recent pghackers discussion: there
are now separate files "postgres.h" and "postgres_fe.h", which are meant
to be the primary include files for backend .c files and frontend .c files
respectively.  By default, only include files meant for frontend use are
installed into the installation include directory.  There is a new make
target 'make install-all-headers' that adds the whole content of the
src/include tree to the installed fileset, for use by people who want to
develop server-side code without keeping the complete source tree on hand.
Cleaned up a whole lot of crufty and inconsistent header inclusions.
2001-02-10 02:31:31 +00:00
Tom Lane 897a895d32 When launching a child backend, take care to close file descriptors for
any other client connections that may exist (which would only happen if
another client is currently in the authentication cycle).  This avoids
wastage of open descriptors in a child.  It might also explain peculiar
behaviors like not closing connections when expected, since the kernel
will probably not signal EOF as long as some other backend is randomly
holding open a reference to the connection, even if the client went away
long since ...
2001-02-08 00:35:10 +00:00
Tom Lane 1dc3051088 Re-read Unix-socket lock file every so often (every CheckPoint interval,
actually) to ensure that its file access time doesn't get old enough to
tempt a /tmp directory cleaner to remove it.  Still another reason we
should never have put the sockets in /tmp in the first place ...
2001-01-27 00:05:31 +00:00
Bruce Momjian 623bf843d2 Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00