Commit Graph

61 Commits

Author SHA1 Message Date
Tom Lane ae293d33cf Make sure ControlFile logId/logSeg don't go backwards (barely possible given a
slow backend, if we update unconditionally as the code did before).
2001-03-18 00:30:27 +00:00
Tom Lane 5a38af7fd8 Rearrange XLogFileInit so that control-file spinlock is not held while filling
the new log file with zeroes, only while renaming it into place.  This should
prevent problems with 'stuck spinlock' errors under heavy load.
2001-03-17 20:54:13 +00:00
Tom Lane 9d645fd84c Support syncing WAL log to disk using either fsync(), fdatasync(),
O_SYNC, or O_DSYNC (as available on a given platform).  Add GUC parameter
to control sync method.
Also, add defense to XLogWrite to prevent it from going nuts if passed
a target write position that's past the end of the buffers so far filled
by XLogInsert.
2001-03-16 05:44:33 +00:00
Tom Lane cfab4f6541 Use SEP_CHAR consistently in forming XLOG pathnames. 2001-03-14 20:23:04 +00:00
Tom Lane 1b87e24c4a Change xlog page-header format to include StartUpID. Use the SUI to
detect case that next page in log came from an older run than the prior
page.  This avoids the necessity to re-zero the log after recovery from
a crash, which is good because we need not risk destroying valuable log
information.
This forces another initdb since yesterday :-(.  Need to get that log
reset utility done...
2001-03-13 20:32:37 +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 9c9936587c Implement COMMIT_SIBLINGS parameter to allow pre-commit delay to occur
only if at least N other backends currently have open transactions.  This
is not a great deal of intelligence about whether a delay might be
profitable ... but it beats no intelligence at all.  Note that the default
COMMIT_DELAY is still zero --- this new code does nothing unless that
setting is changed.
Also, mark ENABLEFSYNC as a system-wide setting.  It's no longer safe to
allow that to be set per-backend, since we may be relying on some other
backend's fsync to have synced the WAL log.
2001-02-26 00:50:08 +00:00
Tom Lane 33cc5d8a4d Change s_lock to not use any zero-delay select() calls; these are just a
waste of cycles on single-CPU machines, and of dubious utility on multi-CPU
machines too.
Tweak s_lock_stuck so that caller can specify timeout interval, and
increase interval before declaring stuck spinlock for buffer locks and XLOG
locks.
On systems that have fdatasync(), use that rather than fsync() to sync WAL
log writes.  Ensure that WAL file is entirely allocated during XLogFileInit.
2001-02-18 04:39:42 +00:00
Vadim B. Mikheev 7e04843ba7 Comments about GetFreeXLBuffer().
GetFreeXLBuffer(): use Insert->LgwrResult instead of private LgwrResult
copy if it's more fresh (attempt to avoid acquiring info_lck/lgwr_lck).
2001-02-13 20:40:25 +00:00
Vadim B. Mikheev 35273825dc Removed abort() in XLogFileOpen. 2001-02-13 08:44:09 +00:00
Bruce Momjian 623bf843d2 Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
Tom Lane 36839c1927 Restructure backend SIGINT/SIGTERM handling so that 'die' interrupts
are treated more like 'cancel' interrupts: the signal handler sets a
flag that is examined at well-defined spots, rather than trying to cope
with an interrupt that might happen anywhere.  See pghackers discussion
of 1/12/01.
2001-01-14 05:08:17 +00:00
Tom Lane 6162432de9 Add more critical-section calls: all code sections that hold spinlocks
are now critical sections, so as to ensure die() won't interrupt us while
we are munging shared-memory data structures.  Avoid insecure intermediate
states in some code that proc_exit will call, like palloc/pfree.  Rename
START/END_CRIT_CODE to START/END_CRIT_SECTION, since that seems to be
what people tend to call them anyway, and make them be called with () like
a function call, in hopes of not confusing pg_indent.
I doubt that this is sufficient to make SIGTERM safe anywhere; there's
just too much code that could get invoked during proc_exit().
2001-01-12 21:54:01 +00:00
Vadim B. Mikheev 4b59366e57 1. Checkpoint.undo may be after checkpoint itself:
- no more elog(STOP) in StartupXLOG();
   - both checkpoint' undo & redo are used to define
     oldest on-line log file.
2. Ability to pre-allocate a few log files at checkpoint time
   (wal_files option). Off by default.
2001-01-09 06:24:33 +00:00
Vadim B. Mikheev c193f19a39 Fixed misprint in heap update WALoging. 2000-12-30 06:52:34 +00:00
Tom Lane 7f60b81e1a Fix failure in CreateCheckPoint on some Alpha boxes --- it's not OK to
assume that TAS() will always succeed the first time, even if the lock
is known to be free.  Also, make sure that code will eventually time out
and report a stuck spinlock, rather than looping forever.  Small cleanups
in s_lock.h, too.
2000-12-29 21:31:21 +00:00
Vadim B. Mikheev 7ceeeb662f New WAL version - CRC and data blocks backup. 2000-12-28 13:00:29 +00:00
Bruce Momjian 1f159e562b >> Here is a patch for the beos port (All regression tests are OK).
>>     xlog.c : special case for beos to avoid 'link' which does not work yet
>>     beos/sem.c : implementation of new sem_ctl call (GETPID) and a new
>sem_op
>> flag (IPCNOWAIT)
>>     dynloader/beos.c : add a verification of symbol validity (seem that
the
>> loader sometime return OK with an invalid symbol)
>>     postmaster.c :  add beos forking support for the new checkpoint
process
>>     postgres.c : remove beos special case for getrusage
>>     beos.h : Correction of a bas definition of AF_UNIX, misc defnitions
>>
>>
>>     thanks
>>
>>
>>             cyril

Cyril VELTER
2000-12-18 18:45:05 +00:00
Tom Lane a626b78c89 Clean up backend-exit-time cleanup behavior. Use on_shmem_exit callbacks
to ensure that we have released buffer refcounts and so forth, rather than
putting ad-hoc operations before (some of the calls to) proc_exit.  Add
commentary to discourage future hackers from repeating that mistake.
2000-12-18 00:44:50 +00:00
Vadim B. Mikheev 5bb4f723d2 Remove elog for online log files. 2000-12-11 19:27:42 +00:00
Vadim B. Mikheev dae369d390 elog(LOG)-->elog(DEBUG) for skipped logs. 2000-12-11 18:02:25 +00:00
Tom Lane fb47385fc8 Resurrect -F switch: it controls fsyncs again, though the fsyncs are
mostly just on the WAL logfile nowadays.  But if people want to disable
fsync for performance, why should we say no?
2000-12-08 22:21:33 +00:00
Vadim B. Mikheev 65b362fae1 Disable elog(ERROR|FATAL) in signal handlers in
critical sections of code.
2000-12-03 10:27:29 +00:00
Vadim B. Mikheev 81c8c244b2 No more #ifdef XLOG. 2000-11-30 08:46:26 +00:00
Vadim B. Mikheev 741510521c XLOG stuff for sequences.
CommitDelay in guc.c
2000-11-30 01:47:33 +00:00
Tom Lane c715fdea26 Significant cleanups in SysV IPC handling (shared mem and semaphores).
IPC key assignment will now work correctly even when multiple postmasters
are using same logical port number (which is possible given -k switch).
There is only one shared-mem segment per postmaster now, not 3.
Rip out broken code for non-TAS case in bufmgr and xlog, substitute a
complete S_LOCK emulation using semaphores in spin.c.  TAS and non-TAS
logic is now exactly the same.
When deadlock is detected, "Deadlock detected" is now the elog(ERROR)
message, rather than a NOTICE that comes out before an unhelpful ERROR.
2000-11-28 23:27:57 +00:00
Tom Lane 230cf8d373 Check for link(2) failure. 2000-11-27 05:36:12 +00:00
Tom Lane bbea3643a3 Store current LC_COLLATE and LC_CTYPE settings in pg_control during initdb;
re-adopt these settings at every postmaster or standalone-backend startup.
This should fix problems with indexes becoming corrupt due to failure to
provide consistent locale environment for postmaster at all times.  Also,
refuse to start up a non-locale-enabled compilation in a database originally
initdb'd with a non-C locale.  Suppress LIKE index optimization if locale
is not "C" or "POSIX" (are there any other locales where it's safe?).
Issue NOTICE during initdb if selected locale disables LIKE optimization.
2000-11-25 20:33:54 +00:00
Peter Eisentraut 403abf1ca5 Refine log/error messages. Print out the errno message, not the number.
Remove timestamps from messages where this would be redundant with the
log_timestamp option.
2000-11-21 22:27:26 +00:00
Peter Eisentraut a70e74b060 Put external declarations into header files. 2000-11-21 21:16:06 +00:00
Vadim B. Mikheev 2536267404 misc 2000-11-21 10:17:57 +00:00
Vadim B. Mikheev e8ff221d8b Fix OID bootstraping. 2000-11-21 09:39:57 +00:00
Vadim B. Mikheev 01f2547c6b Init ShmemVariableCache in BootStrapXLOG()
(should fix OID bootstraping).
2000-11-21 02:11:06 +00:00
Vadim B. Mikheev a221d95f28 Compile WAL by default. 2000-11-20 05:18:40 +00:00
Bruce Momjian a5046ad13a That variable I removed broke XLOG, that part of the delta
should have read:

Alfred Perlstein
2000-11-16 06:16:00 +00:00
Bruce Momjian 312063c97b Make pgsql compile on FreeBSD-alpha.
Context diff this time.

Remove -m486 compile args for FreeBSD-i386, compile -O2 on i386.

Compile with only -O on alpha for codegen safety.

Make the port use the TEST_AND_SET for alpha and i386 on FreeBSD.

Fix a lot of bogus string formats for outputting pointers (cast to int
and %u/%x replaced with no cast and %p), and 'Size'(size_t) are now
cast to 'unsigned long' and output with %lu/

Remove an unused variable.

Alfred Perlstein
2000-11-16 05:51:07 +00:00
Vadim B. Mikheev b0299c5d37 Auto checkpoint creation. 2000-11-09 11:26:00 +00:00
Vadim B. Mikheev f0e37a8531 New CHECKPOINT command.
Auto removing of offline log files and creating new file
at checkpoint time.
2000-11-05 22:50:21 +00:00
Vadim B. Mikheev b98ba2a04c pg_variable is not used in WAL version now. 2000-11-03 11:39:36 +00:00
Vadim B. Mikheev 5b0740d3fc WAL 2000-10-28 16:21:00 +00:00
Vadim B. Mikheev db2faa943a WAL misc 2000-10-24 09:56:23 +00:00
Vadim B. Mikheev 4b65a2840b New relcache hash table with RelFileNode as key to be used
from bufmgr - it would be nice to have separate hash in smgr
for node <--> fd mappings, but for the moment it's easy to
add new hash to relcache.
Fixed small bug in xlog.c:ReadRecord.
2000-10-23 04:10:24 +00:00
Vadim B. Mikheev a7fcadd10a WAL 2000-10-21 15:43:36 +00:00
Vadim B. Mikheev b58c0411ba redo/undo support functions and cleanups. 2000-10-20 11:01:21 +00:00
Vadim B. Mikheev d0273c07ac misc 2000-07-04 01:49:44 +00:00
Bruce Momjian cc2b5e5815 Remove NT-specific file open defines by defining our own open macros for
"rb" and "wb".
2000-06-02 15:57:44 +00:00
Vadim B. Mikheev bf1c8f2b3b heap' xlog records 2000-06-02 10:20:27 +00:00
Tom Lane b659ab07a2 Create an fd.c entry point that is just like plain open(2) except that
it will close VFDs if necessary to surmount ENFILE or EMFILE failures.
Make use of this in md.c, xlog.c, and user.c routines that were
formerly vulnerable to these failures.  In particular, this should
handle failures of mdblindwrt() that have been observed under heavy
load conditions.  (By golly, every other process on the system may
crash after Postgres eats up all the kernel FDs, but Postgres will
keep going!)
2000-06-02 03:58:34 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Vadim B. Mikheev df238b2c06 Turn XLOG off (do not create log file). 2000-03-20 07:25:39 +00:00