Commit Graph

321 Commits

Author SHA1 Message Date
Tom Lane 9473bb96d0 Further thoughts about temp_file_limit patch.
Move FileClose's decrement of temporary_files_size up, so that it will be
executed even if elog() throws an error.  This is reasonable since if the
unlink() fails, the fact the file is still there is not our fault, and we
are going to forget about it anyhow.  So we won't count it against
temp_file_limit anymore.

Update fileSize and temporary_files_size correctly in FileTruncate.
We probably don't have any places that truncate temp files, but fd.c
surely should not assume that.
2011-07-17 15:05:44 -04:00
Tom Lane 23e5b16c71 Add temp_file_limit GUC parameter to constrain temporary file space usage.
The limit is enforced against the total amount of temp file space used by
each session.

Mark Kirkwood, reviewed by Cédric Villemain and Tatsuo Ishii
2011-07-17 14:19:31 -04:00
Alvaro Herrera fba105b109 Use "transient" files for blind writes, take 2
"Blind writes" are a mechanism to push buffers down to disk when
evicting them; since they may belong to different databases than the one
a backend is connected to, the backend does not necessarily have a
relation to link them to, and thus no way to blow them away.  We were
keeping those files open indefinitely, which would cause a problem if
the underlying table was deleted, because the operating system would not
be able to reclaim the disk space used by those files.

To fix, have bufmgr mark such files as transient to smgr; the lower
layer is allowed to close the file descriptor when the current
transaction ends.  We must be careful to have any other access of the
file to remove the transient markings, to prevent unnecessary expensive
system calls when evicting buffers belonging to our own database (which
files we're likely to require again soon.)

This commit fixes a bug in the previous one, which neglected to cleanly
handle the LRU ring that fd.c uses to manage open files, and caused an
unacceptable failure just before beta2 and was thus reverted.
2011-06-10 13:43:02 -04:00
Alvaro Herrera 3d114b63b2 Use a constant sprintf format to silence compiler warning 2011-06-10 13:38:50 -04:00
Alvaro Herrera 9261557eb1 Revert "Use "transient" files for blind writes"
This reverts commit 54d9e8c6c1, which
caused a failure on the buildfarm.  Not a good thing to have just before
a beta release.
2011-06-09 16:41:44 -04:00
Alvaro Herrera 54d9e8c6c1 Use "transient" files for blind writes
"Blind writes" are a mechanism to push buffers down to disk when
evicting them; since they may belong to different databases than the one
a backend is connected to, the backend does not necessarily have a
relation to link them to, and thus no way to blow them away.  We were
keeping those files open indefinitely, which would cause a problem if
the underlying table was deleted, because the operating system would not
be able to reclaim the disk space used by those files.

To fix, have bufmgr mark such files as transient to smgr; the lower
layer is allowed to close the file descriptor when the current
transaction ends.  We must be careful to have any other access of the
file to remove the transient markings, to prevent unnecessary expensive
system calls when evicting buffers belonging to our own database (which
files we're likely to require again soon.)
2011-06-09 16:25:49 -04:00
Bruce Momjian bf50caf105 pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
Bruce Momjian 5d950e3b0c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
Robert Haas 53dbc27c62 Support unlogged tables.
The contents of an unlogged table are WAL-logged; thus, they are not
available on standby servers and are truncated whenever the database
system enters recovery.  Indexes on unlogged tables are also unlogged.
Unlogged GiST indexes are not currently supported.
2010-12-29 06:48:53 -05:00
Tom Lane 576477e73c Force default wal_sync_method to be fdatasync on Linux.
Recent versions of the Linux system header files cause xlogdefs.h to
believe that open_datasync should be the default sync method, whereas
formerly fdatasync was the default on Linux.  open_datasync is a bad
choice, first because it doesn't actually outperform fdatasync (in fact
the reverse), and second because we try to use O_DIRECT with it, causing
failures on certain filesystems (e.g., ext4 with data=journal option).
This part of the patch is largely per a proposal from Marti Raudsepp.
More extensive changes are likely to follow in HEAD, but this is as much
change as we want to back-patch.

Also clean up confusing code and incorrect documentation surrounding the
fsync_writethrough option.  Those changes shouldn't result in any actual
behavioral change, but I chose to back-patch them anyway to keep the
branches looking similar in this area.

In 9.0 and HEAD, also do some copy-editing on the WAL Reliability
documentation section.

Back-patch to all supported branches, since any of them might get used
on modern Linux versions.
2010-12-08 20:01:09 -05:00
Tom Lane 54428dbe90 Fix error handling in temp-file deletion with log_temp_files active.
The original coding in FileClose() reset the file-is-temp flag before
unlinking the file, so that if control came back through due to an error,
it wouldn't try to unlink the file twice.  This was correct when written,
but when the log_temp_files feature was added, the logging action was put
in between those two steps.  An error occurring during the logging action
--- such as a query cancel --- would result in the unlink not getting done
at all, as in recent report from Michael Glaesemann.

To fix this, make sure that we do both the stat and the unlink before doing
anything that could conceivably CHECK_FOR_INTERRUPTS.  There is a judgment
call here, which is which log message to emit first: if you can see only
one, which should it be?  I chose to log unlink failure at the risk of
losing the log_temp_files log message --- after all, if the unlink does
fail, the temp file is still there for you to see.

Back-patch to all versions that have log_temp_files.  The code was OK
before that.
2010-11-08 22:14:48 -05:00
Tom Lane 5ac144d5c2 Improve messages for too many private files/dirs. Per Alexey Parshin. 2010-09-28 18:08:02 -04:00
Magnus Hagander 9f2e211386 Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Robert Haas debcec7dc3 Include the backend ID in the relpath of temporary relations.
This allows us to reliably remove all leftover temporary relation
files on cluster startup without reference to system catalogs or WAL;
therefore, we no longer include temporary relations in XLOG_XACT_COMMIT
and XLOG_XACT_ABORT WAL records.

Since these changes require including a backend ID in each
SharedInvalSmgrMsg, the size of the SharedInvalidationMessage.id
field has been reduced from two bytes to one, and the maximum number
of connections has been reduced from INT_MAX / 4 to 2^23-1.  It would
be possible to remove these restrictions by increasing the size of
SharedInvalidationMessage by 4 bytes, but right now that doesn't seem
like a good trade-off.

Review by Jaime Casanova and Tom Lane.
2010-08-13 20:10:54 +00:00
Robert Haas 20be0d480a Make log_temp_files based on kB, and revert docs & comments to match.
Per extensive discussion on pgsql-hackers.  We are deliberately not
back-patching this even though the behavior of 8.3 and 8.4 is
unquestionably broken, for fear of breaking existing users of this
parameter.  This incompatibility should be release-noted.
2010-07-06 22:55:26 +00:00
Bruce Momjian 65e806cba1 pgindent run for 9.0 2010-02-26 02:01:40 +00:00
Tom Lane e9a383303c Adjust pg_fsync_writethrough so that it will set errno when failing
on a platform that doesn't support this operation.  The former coding
would allow an unrelated errno to be reported, which would be quite
misleading.  Not sure if this has anything to do with the current
buildfarm failures, but it's certainly bogus as-is.
2010-02-22 15:26:14 +00:00
Greg Stark f8c183a1ac Speed up CREATE DATABASE by deferring the fsyncs until after copying
all the data and using posix_fadvise to nudge the OS into flushing it
earlier. This also hopefully makes CREATE DATABASE avoid spamming the
cache.

Tests show a big speedup on Linux at least on some filesystems.

Idea and patch from Andres Freund.
2010-02-15 00:50:57 +00:00
Bruce Momjian 228170410d Please tablespace directories in their own subdirectory so pg_migrator
can upgrade clusters without renaming the tablespace directories.  New
directory structure format is, e.g.:

	$PGDATA/pg_tblspc/20981/PG_8.5_201001061/719849/83292814
2010-01-12 02:42:52 +00:00
Bruce Momjian 0239800893 Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
Heikki Linnakangas ab3148b712 Fix bug in temporary file management with subtransactions. A cursor opened
in a subtransaction stays open even if the subtransaction is aborted, so
any temporary files related to it must stay alive as well. With the patch,
we use ResourceOwners to track open temporary files and don't automatically
close them at subtransaction end (though in the normal case temporary files
are registered with the subtransaction resource owner and will therefore be
closed).

At end of top transaction, we still check that there's no temporary files
marked as close-at-end-of-transaction open, but that's now just a debugging
cross-check as the resource owner cleanup should've closed them already.
2009-12-03 11:03:29 +00:00
Heikki Linnakangas 23dc89d2c3 Improve error messages in md.c. When a filesystem operation like open() or
fsync() fails, say "file" rather than "relation" when printing the filename.

This makes messages that display block numbers a bit confusing. For example,
in message 'could not read block 150000 of file "base/1234/5678.1"', 150000
is the block number from the beginning of the relation, ie. segment 0, not
150000th block within that segment. Per discussion, users aren't usually
interested in the exact location within the file, so we can live with that.

To ease constructing error messages, add FilePathName(File) function to
return the pathname of a virtual fd.
2009-08-05 18:01:54 +00:00
Bruce Momjian d747140279 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
2009-06-11 14:49:15 +00:00
Peter Eisentraut 9add9f95c3 Don't actively violate the system limit of maximum open files (RLIMIT_NOFILE).
This avoids irritating kernel logs (if system overstep violations are enabled)
and also the grsecurity alert when starting PostgreSQL.

original patch by Jacek Drobiecki

References:
http://archives.postgresql.org/pgsql-bugs/2004-05/msg00103.php
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=248967
2009-03-04 09:12:49 +00:00
Tom Lane b7b8f0b609 Implement prefetching via posix_fadvise() for bitmap index scans. A new
GUC variable effective_io_concurrency controls how many concurrent block
prefetch requests will be issued.

(The best way to handle this for plain index scans is still under debate,
so that part is not applied yet --- tgl)

Greg Stark
2009-01-12 05:10:45 +00:00
Bruce Momjian 511db38ace Update copyright for 2009. 2009-01-01 17:24:05 +00:00
Alvaro Herrera 5817d861e9 Optimize CleanupTempFiles by having a boolean flag that keeps track of whether
there are FD_XACT_TEMPORARY files to clean up at transaction end.

Per performance profiling results on AWeber's huge systems.

Patch by me after an idea suggested by Simon Riggs.
2008-09-19 04:57:10 +00:00
Tom Lane f0828b2fc3 Provide a build-time option to store large relations as single files, rather
than dividing them into 1GB segments as has been our longtime practice.  This
requires working support for large files in the operating system; at least for
the time being, it won't be the default.

Zdenek Kotala
2008-03-10 20:06:27 +00:00
Bruce Momjian 9098ab9e32 Update copyrights in source tree to 2008. 2008-01-01 19:46:01 +00:00
Peter Eisentraut 5ca3d50db7 Clarify log messages 2007-12-13 11:55:44 +00:00
Bruce Momjian fdf5a5efb7 pgindent run for 8.3. 2007-11-15 21:14:46 +00:00
Tom Lane e4f4a7f5a4 Remove FileUnlink(), which wasn't being used anywhere and interacted poorly
with the recent patch to log temp file sizes at removal time.  Doesn't seem
worth fixing since it's unused.
In passing, make a few elog messages conform to the message style guide.
2007-07-26 15:15:18 +00:00
Tom Lane 24ee8af573 Rework temp_tablespaces patch so that temp tablespaces are assigned separately
for each temp file, rather than once per sort or hashjoin; this allows
spreading the data of a large sort or join across multiple tablespaces.
(I remain dubious that this will make any difference in practice, but certain
people insisted.)  Arrange to cache the results of parsing the GUC variable
instead of recomputing from scratch on every demand, and push usage of the
cache down to the bottommost fd.c level.
2007-06-07 19:19:57 +00:00
Tom Lane acfce502ba Create a GUC parameter temp_tablespaces that allows selection of the
tablespace(s) in which to store temp tables and temporary files.  This is a
list to allow spreading the load across multiple tablespaces (a random list
element is chosen each time a temp object is to be created).  Temp files are
not stored in per-database pgsql_tmp/ directories anymore, but per-tablespace
directories.

Jaime Casanova and Albert Cervera, with review by Bernd Helmle and Tom Lane.
2007-06-03 17:08:34 +00:00
Bruce Momjian a535cdf130 Revert temp_tablespaces because of coding problems, per Tom. 2007-03-06 02:06:15 +00:00
Magnus Hagander 2c6feff5e7 Remove temporary Windows-specific debugging code. 2007-02-28 15:59:30 +00:00
Bruce Momjian 148ea5cbea Add GUC temp_tablespaces to provide a default location for temporary
objects.

Jaime Casanova
2007-01-25 04:35:11 +00:00
Bruce Momjian d64995aa89 Remove trace macro call from new log_temp_files, until it gets more
research.
2007-01-09 22:03:51 +00:00
Bruce Momjian be8a431881 Add GUC log_temp_files to log the use of temporary files.
Bill Moran
2007-01-09 21:31:17 +00:00
Bruce Momjian 29dccf5fe0 Update CVS HEAD for 2007 copyright. Back branches are typically not
back-stamped for this.
2007-01-05 22:20:05 +00:00
Tom Lane 36e012e727 Remove temporary Windows-specific debugging code; it seems the problem
with fopen() not using FILE_SHARE_DELETE was indeed the bug we were after,
given lack of recent reports.
2006-11-06 17:10:22 +00:00
Bruce Momjian f99a569a2e pgindent run for 8.2. 2006-10-04 00:30:14 +00:00
Tom Lane f836c2e37e Add some debug logging code to AllocateFile's failure path to log the
specific Windows error code (GetLastError).  This is a hopefully temporary
hack to try to diagnose rare failures.  Magnus Hagander
2006-08-24 03:15:43 +00:00
Bruce Momjian 26cfefabad Fix printf mask for SizeVfdCache
Qingqing Zhou
2006-05-30 13:04:59 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Tom Lane 60d3c9fdf4 Declare the arguments of AllocateFile() as const char *, not char *.
This is consistent with the standard definition of fopen().
2006-03-04 21:32:47 +00:00
Tom Lane 558bc2584d Fix fsync code to test whether F_FULLFSYNC is available, instead of
assuming it always is on Darwin.  Per report from Neil Brandt.
2006-01-17 23:52:31 +00:00
Tom Lane f38c3e778a Fix thinko in comment. 2005-12-08 15:38:29 +00:00
Tom Lane ace17c1d82 Retry in FileRead and FileWrite if Windows returns ERROR_NO_SYSTEM_RESOURCES.
Also add a retry for Unixen returning EINTR, which hasn't been reported
as an issue but at least theoretically could be.  Patch by Qingqing Zhou,
some minor adjustments by me.
2005-12-01 20:24:18 +00:00
Bruce Momjian 436a2956d8 Re-run pgindent, fixing a problem where comment lines after a blank
comment line where output as too long, and update typedefs for /lib
directory.  Also fix case where identifiers were used as variable names
in the backend, but as typedefs in ecpg (favor the backend for
indenting).

Backpatch to 8.1.X.
2005-11-22 18:17:34 +00:00
Bruce Momjian 1dc3498251 Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Tom Lane 7117cd3a77 Cause ShutdownPostgres to do a normal transaction abort during backend
exit, instead of trying to take shortcuts.  Introduce some additional
shutdown callback routines to eliminate kluges like having ProcKill
be responsible for shutting down the buffer manager.  Ensure that the
order of operations during shutdown is predictable and what you would
expect given the module layering.
2005-08-08 03:12:16 +00:00
Tom Lane 5337ad464e Fix count_usable_fds() to stop trying to open files once it reaches
max_files_per_process.  Going further than that is just a waste of
cycles, and it seems that current Cygwin does not cope gracefully
with deliberately running the system out of FDs.  Per Andrew Dunstan.
2005-08-07 18:47:19 +00:00
Tom Lane eb5949d190 Arrange for the postmaster (and standalone backends, initdb, etc) to
chdir into PGDATA and subsequently use relative paths instead of absolute
paths to access all files under PGDATA.  This seems to give a small
performance improvement, and it should make the system more robust
against naive DBAs doing things like moving a database directory that
has a live postmaster in it.  Per recent discussion.
2005-07-04 04:51:52 +00:00
Tom Lane 3f749924f8 Simplify uses of readdir() by creating a function ReadDir() that
includes error checking and an appropriate ereport(ERROR) message.
This gets rid of rather tedious and error-prone manipulation of errno,
as well as a Windows-specific bug workaround, at more than a dozen
call sites.  After an idea in a recent patch by Heikki Linnakangas.
2005-06-19 21:34:03 +00:00
Bruce Momjian 6dc7760ac3 Add support for wal_fsync_writethrough for Darwin, and restructure the
code to better handle writethrough.

Chris Campbell
2005-05-20 14:53:26 +00:00
PostgreSQL Daemon 2ff501590b Tag appropriate files for rc3
Also performed an initial run through of upgrading our Copyright date to
extend to 2005 ... first run here was very simple ... change everything
where: grep 1996-2004 && the word 'Copyright' ... scanned through the
generated list with 'less' first, and after, to make sure that I only
picked up the right entries ...
2004-12-31 22:04:05 +00:00
Tom Lane eee5abce46 Refactor EXEC_BACKEND code so that postmaster child processes reattach
to shared memory as soon as possible, ie, right after read_backend_variables.
The effective difference from the original code is that this happens
before instead of after read_nondefault_variables(), which loads GUC
information and is apparently capable of expanding the backend's memory
allocation more than you'd think it should.  This should fix the
failure-to-attach-to-shared-memory reports we've been seeing on Windows.
Also clean up a few bits of unnecessarily grotty EXEC_BACKEND code.
2004-12-29 21:36:09 +00:00
Tom Lane 8f9f198603 Restructure subtransaction handling to reduce resource consumption,
as per recent discussions.  Invent SubTransactionIds that are managed like
CommandIds (ie, counter is reset at start of each top transaction), and
use these instead of TransactionIds to keep track of subtransaction status
in those modules that need it.  This means that a subtransaction does not
need an XID unless it actually inserts/modifies rows in the database.
Accordingly, don't assign it an XID nor take a lock on the XID until it
tries to do that.  This saves a lot of overhead for subtransactions that
are only used for error recovery (eg plpgsql exceptions).  Also, arrange
to release a subtransaction's XID lock as soon as the subtransaction
exits, in both the commit and abort cases.  This avoids holding many
unique locks after a long series of subtransactions.  The price is some
additional overhead in XactLockTableWait, but that seems acceptable.
Finally, restructure the state machine in xact.c to have a more orthogonal
set of states for subtransactions.
2004-09-16 16:58:44 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Bruce Momjian da9a8649d8 Update copyright to 2004. 2004-08-29 04:13:13 +00:00
Tom Lane 1bf3d61504 Fix subtransaction behavior for large objects, temp namespace, files,
password/group files.  Also allow read-only subtransactions of a read-write
parent, but not vice versa.  These are the reasonably noncontroversial
parts of Alvaro's recent mop-up patch, plus further work on large objects
to minimize use of the TopTransactionResourceOwner.
2004-07-28 14:23:31 +00:00
Tom Lane 9b178555fc Per previous discussions, get rid of use of sync(2) in favor of
explicitly fsync'ing every (non-temp) file we have written since the
last checkpoint.  In the vast majority of cases, the burden of the
fsyncs should fall on the bgwriter process not on backends.  (To this
end, we assume that an fsync issued by the bgwriter will force out
blocks written to the same file by other processes using other file
descriptors.  Anyone have a problem with that?)  This makes the world
safe for WIN32, which ain't even got sync(2), and really makes the world
safe for Unixen as well, because sync(2) never had the semantics we need:
it offers no way to wait for the requested I/O to finish.

Along the way, fix a bug I recently introduced in xlog recovery:
file truncation replay failed to clear bufmgr buffers for the dropped
blocks, which could result in 'PANIC:  heap_delete_redo: no block'
later on in xlog replay.
2004-05-31 03:48:10 +00:00
Tom Lane 7a57a67278 Replace opendir/closedir calls throughout the backend with AllocateDir
and FreeDir routines modeled on the existing AllocateFile/FreeFile.
Like the latter, these routines will avoid failing on EMFILE/ENFILE
conditions whenever possible, and will prevent leakage of directory
descriptors if an elog() occurs while one is open.
Also, reduce PANIC to ERROR in MoveOfflineLogs() --- this is not
critical code and there is no reason to force a DB restart on failure.
All per recent trouble report from Olivier Hubaut.
2004-02-23 23:03:10 +00:00
Tom Lane f83356c7f5 Do a direct probe during postmaster startup to determine the maximum
number of openable files and the number already opened.  This eliminates
depending on sysconf(_SC_OPEN_MAX), and allows much saner behavior on
platforms where open-file slots are used up by semaphores.
2004-02-23 20:45:59 +00:00
Tom Lane c77f363384 Ensure that close() and fclose() are checked for errors, at least in
cases involving writes.  Per recent discussion about the possibility
of close-time failures on some filesystems.  There is a TODO item for
this, too.
2004-01-26 22:35:32 +00:00
Bruce Momjian d75b2ec4eb This patch is the next step towards (re)allowing fork/exec.
Claudio Natoli
2003-12-20 17:31:21 +00:00
Peter Eisentraut 2afacfc403 This patch properly sets the prototype for the on_shmem_exit and
on_proc_exit functions, and adjust all other related code to use
the proper types too.

by Kurt Roeckx
2003-12-12 18:45:10 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
Peter Eisentraut feb4f44d29 Message editing: remove gratuitous variations in message wording, standardize
terms, add some clarifications, fix some untranslatable attempts at dynamic
message building.
2003-09-25 06:58:07 +00:00
Bruce Momjian f3c3deb7d0 Update copyrights to 2003. 2003-08-04 02:40:20 +00:00
Bruce Momjian 089003fb46 pgindent run. 2003-08-04 00:43:34 +00:00
Tom Lane cfa191f3b8 Error message editing in backend/storage. 2003-07-24 22:04:15 +00:00
Tom Lane 4a5f38c4e6 Code review for holdable-cursors patch. Fix error recovery, memory
context sloppiness, some other things.  Includes Neil's mopup patch
of 22-Apr.
2003-04-29 03:21:30 +00:00
Bruce Momjian d46e643822 Add Win32 path handling for / vs. \ and drive letters. 2003-04-04 20:42:13 +00:00
Bruce Momjian 54f7338fa1 This patch implements holdable cursors, following the proposal
(materialization into a tuple store) discussed on pgsql-hackers earlier.
I've updated the documentation and the regression tests.

Notes on the implementation:

- I needed to change the tuple store API slightly -- it assumes that it
won't be used to hold data across transaction boundaries, so the temp
files that it uses for on-disk storage are automatically reclaimed at
end-of-transaction. I added a flag to tuplestore_begin_heap() to control
this behavior. Is changing the tuple store API in this fashion OK?

- in order to store executor results in a tuple store, I added a new
CommandDest. This works well for the most part, with one exception: the
current DestFunction API doesn't provide enough information to allow the
Executor to store results into an arbitrary tuple store (where the
particular tuple store to use is chosen by the call site of
ExecutorRun). To workaround this, I've temporarily hacked up a solution
that works, but is not ideal: since the receiveTuple DestFunction is
passed the portal name, we can use that to lookup the Portal data
structure for the cursor and then use that to get at the tuple store the
Portal is using. This unnecessarily ties the Portal code with the
tupleReceiver code, but it works...

The proper fix for this is probably to change the DestFunction API --
Tom suggested passing the full QueryDesc to the receiveTuple function.
In that case, callers of ExecutorRun could "subclass" QueryDesc to add
any additional fields that their particular CommandDest needed to get
access to. This approach would work, but I'd like to think about it for
a little bit longer before deciding which route to go. In the mean time,
the code works fine, so I don't think a fix is urgent.

- (semi-related) I added a NO SCROLL keyword to DECLARE CURSOR, and
adjusted the behavior of SCROLL in accordance with the discussion on
-hackers.

- (unrelated) Cleaned up some SGML markup in sql.sgml, copy.sgml

Neil Conway
2003-03-27 16:51:29 +00:00
Bruce Momjian a12b4e279b I checked all the previous string handling errors and most of them were
already fixed by You. However there were a few left and attached patch
should fix the rest of them.

I used StringInfo only in 2 places and both of them are inside debug
ifdefs. Only performance penalty will come from using strlen() like all
the other code does.

I also modified some of the already patched parts by changing
snprintf(buf, 2 * BUFSIZE, ... style lines to
snprintf(buf, sizeof(buf), ... where buf is an array.

Jukka Holappa
2002-09-02 06:11:43 +00:00
Bruce Momjian 97ac103289 Remove sys/types.h in files that include postgres.h, and hence c.h,
because c.h has sys/types.h.
2002-09-02 02:47:07 +00:00
Tom Lane 5df307c778 Restructure local-buffer handling per recent pghackers discussion.
The local buffer manager is no longer used for newly-created relations
(unless they are TEMP); a new non-TEMP relation goes through the shared
bufmgr and thus will participate normally in checkpoints.  But TEMP relations
use the local buffer manager throughout their lifespan.  Also, operations
in TEMP relations are not logged in WAL, thus improving performance.
Since it's no longer necessary to fsync relations as they move out of the
local buffers into shared buffers, quite a lot of smgr.c/md.c/fd.c code
is no longer needed and has been removed: there's no concept of a dirty
relation anymore in md.c/fd.c, and we never fsync anything but WAL.
Still TODO: improve local buffer management algorithms so that it would
be reasonable to increase NLocBuffer.
2002-08-06 02:36:35 +00:00
Bruce Momjian d84fe82230 Update copyright to 2002. 2002-06-20 20:29:54 +00:00
Tom Lane 72a3902a66 Create an internal semaphore API that is not tied to SysV semaphores.
As proof of concept, provide an alternate implementation based on POSIX
semaphores.  Also push the SysV shared-memory implementation into a
separate file so that it can be replaced conveniently.
2002-05-05 00:03:29 +00:00
Bruce Momjian 92288a1cf9 Change made to elog:
o  Change all current CVS messages of NOTICE to WARNING.  We were going
to do this just before 7.3 beta but it has to be done now, as you will
see below.

o Change current INFO messages that should be controlled by
client_min_messages to NOTICE.

o Force remaining INFO messages, like from EXPLAIN, VACUUM VERBOSE, etc.
to always go to the client.

o Remove INFO from the client_min_messages options and add NOTICE.

Seems we do need three non-ERROR elog levels to handle the various
behaviors we need for these messages.

Regression passed.
2002-03-06 06:10:59 +00:00
Bruce Momjian a033daf566 Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages.  Added more text to
highlight ordering difference between it and client_min_messages.

---------------------------------------------------------------------------

REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
        DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
        DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
Tom Lane d99fb0d909 Don't Assert() that fsync() and close() never fail; I have seen this
crash on Solaris when over disk quota.  Instead, report such failures
via elog(DEBUG).
2002-02-10 22:56:31 +00:00
Bruce Momjian ea08e6cd55 New pgindent run with fixes suggested by Tom. Patch manually reviewed,
initdb/regression tests pass.
2001-11-05 17:46:40 +00:00
Bruce Momjian 6783b2372e Another pgindent run. Fixes enum indenting, and improves #endif
spacing.  Also adds space for one-line comments.
2001-10-28 06:26:15 +00:00
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 f9f258281e Create a GUC parameter max_files_per_process that is a configurable
upper limit on what we will believe from sysconf(_SC_OPEN_MAX).  The
default value is 1000, so that under ordinary conditions it won't
affect the behavior.  But on platforms where the kernel promises far
more than it can deliver, this can be used to prevent running out of
file descriptors.  See numerous past discussions, eg, pgsql-hackers
around 23-Dec-2000.
2001-09-30 18:57:45 +00:00
Bruce Momjian 3e51868226 This patch is because Hurd does not support NOFILE. It is against current
cvs.

The Debian bug report says, "The upstream source makes use of NOFILE
unconditionalized.  As the Hurd doesn't have an arbitrary limit on the
number of open files, this is not defined.  But _SC_OPEN_MAX works fine
and returns 1024 (applications can increase this as they want), so I
suggest the below diff.  Please forward this upstream, too."

Oliver Elphick
2001-08-04 19:42:34 +00:00
Bruce Momjian 49ce6fff1d Allow removal of system-named pg_* temp tables. Rename temp file/dir as
pgsql_tmp.
2001-06-18 16:13:21 +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
Tom Lane 1173344e74 Adjust WAL code so that checkpoints truncate the xlog at the previous
checkpoint's redo pointer, not its undo pointer, per discussion in
pghackers a few days ago.  No point in hanging onto undo information
until we have the ability to do something with it --- and this solves
a rather large problem with log space for long-running transactions.
Also, change all calls of write() to detect the case where write
returned a count less than requested, but failed to set errno.
Presume that this situation indicates ENOSPC, and give the appropriate
error message, rather than a random message associated with the previous
value of errno.
2001-06-06 17:07:46 +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
Tom Lane 08bf4d797b Check for failure of malloc() and realloc() when allocating space for
VFD entries.  On platforms where dereferencing a null pointer doesn't
lead to coredump, it's possible that this omission could have led to
unpleasant behavior like deleting the wrong file.
2001-04-03 04:07:02 +00:00
Tom Lane 6cc6f18d15 open(2) flags saved for re-opening a virtual file should probably not
include O_CREAT.
2001-04-03 02:31:52 +00:00
Bruce Momjian 9e1552607a pgindent run. Make it all clean. 2001-03-22 04:01:46 +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
Tom Lane b634118af9 Add current seek position to FDDEBUG output for FileRead,
FileWrite, FileSeek.
2001-02-17 01:00:04 +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 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
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 81c8c244b2 No more #ifdef XLOG. 2000-11-30 08:46:26 +00:00
Vadim B. Mikheev 5479c11bfa Set fdstate in fileNameOpenFile. 2000-11-23 01:08:57 +00:00
Vadim B. Mikheev 92875e6f44 pg_fsync is fsync in WAL version. 2000-11-10 03:53:45 +00:00
Vadim B. Mikheev 5b0740d3fc WAL 2000-10-28 16:21:00 +00:00
Peter Eisentraut 416bbbffa3 Banish caddr_t (mostly), use Datum where appropriate. 2000-10-02 19:42:56 +00:00
Tom Lane 5ba9d8c2d4 Change ReleaseLruFile() usage so that if we cannot release any more
virtual FDs, we just return the ENFILE/EMFILE error to the caller,
rather than immediate elog().  This allows more robust behavior in
the postmaster, which uses AllocateFile() but does not want elog().
2000-08-27 21:48:00 +00:00
Tom Lane 6d1ae0c91b Fix typo (extraneous semicolon) in fd.c patch to avoid excess seeks.
Now it skips useless SEEK_CUR 0 calls too, as intended.
2000-07-05 21:10:05 +00:00
Bruce Momjian 946e80c435 Final #include cleanup. 2000-06-15 04:10:30 +00:00
Bruce Momjian a194574dde > If read or write fails. Position will left the same. This
> situation is already tracked in File routines, but a little bit
> incorrectly.

> After small survey in Linux kernel code, I am not sure about
> it.  New patch set pos to unknown in the case of read/write
> fails. And do lseek again.

> Here is the full patch for this. This patch reduce amount of
> lseek call ten ti mes for update statement and twenty times for
> select statement. I tested joined up date and count(*) select
> for table with rows > 170000 and 10 indices.  I think this is
> worse of trying. Before lseek calls account for more than 5% o
> f time.  Now they are 0.89 and 0.15 respectevly.
>
> Due to only one file modification patch should be applied in
> src/backedn/stora ge/file/ dir.

-- Sincerely Yours,
Denis Perchine
2000-06-14 03:19:24 +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
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
Peter Eisentraut 6a68f42648 The heralded `Grand Unified Configuration scheme' (GUC)
That means you can now set your options in either or all of $PGDATA/configuration,
some postmaster option (--enable-fsync=off), or set a SET command. The list of
options is in backend/utils/misc/guc.c, documentation will be written post haste.

pg_options is gone, so is that pq_geqo config file. Also removed were backend -K,
-Q, and -T options (no longer applicable, although -d0 does the same as -Q).

Added to configure an --enable-syslog option.

changed all callers from TPRINTF to elog(DEBUG)
2000-05-31 00:28:42 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Tom Lane 1f6d8b90b8 Buffer manager modifications to keep a local buffer-dirtied bit as well
as a shared dirtybit for each shared buffer.  The shared dirtybit still
controls writing the buffer, but the local bit controls whether we need
to fsync the buffer's file.  This arrangement fixes a bug that allowed
some required fsyncs to be missed, and should improve performance as well.
For more info see my post of same date on pghackers.
2000-04-09 04:43:20 +00:00
Tom Lane 341b328b18 Fix a bunch of minor portability problems and maybe-bugs revealed by
running gcc and HP's cc with warnings cranked way up.  Signed vs unsigned
comparisons, routines declared static and then defined not-static,
that kind of thing.  Tedious, but perhaps useful...
2000-03-17 02:36:41 +00:00
Bruce Momjian cf1d2165b3 Fix comment spacing. 2000-02-28 08:51:43 +00:00
Bruce Momjian 5c25d60244 Add:
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc

to all files copyright Regents of Berkeley.  Man, that's a lot of files.
2000-01-26 05:58:53 +00:00
Tom Lane b04bdf1290 Reduce ReleaseLruFile failure from FATAL to ERROR grade; offhand I don't
see that this should be a worse way to fail to open a file than any other.
1999-11-23 01:08:36 +00:00
Tom Lane e1c76c2533 Change fd.c so that temp files are closed and deleted at
proc_exit time.  I discovered that if the frontend closes the connection
when you're inside a transaction block, there is nothing ensuring that
temp files go away ... I wonder whether proc_exit ought to try to do an
explicit transaction abort?
1999-10-17 23:09:02 +00:00
Tom Lane db3c4c3a2d Split 'BufFile' routines out of fd.c into a new module, buffile.c. Extend
BufFile so that it handles multi-segment temporary files transparently.
This allows sorts and hashes to work with data exceeding 2Gig (or whatever
the local limit on file size is).  Change psort.c to use relative seeks
instead of absolute seeks for backwards scanning, so that it won't fail
when the data volume exceeds 2Gig.
1999-10-13 15:02:32 +00:00
Vadim B. Mikheev 30659d43eb Transaction log manager core code.
It doesn't work currently but also don't break anything -:)
1999-09-27 15:48:12 +00:00
Bruce Momjian 3406901a29 Move some system includes into c.h, and remove duplicates. 1999-07-17 20:18:55 +00:00
Bruce Momjian 9b645d481c Update #include cleanups 1999-07-16 03:14:30 +00:00
Bruce Momjian 4b2c2850bf Clean up #include in /include directory. Add scripts for checking includes. 1999-07-15 15:21:54 +00:00
Bruce Momjian 0cf1b79528 Cleanup of /include #include's, for 6.6 only. 1999-07-14 01:20:30 +00:00
Bruce Momjian 70ce98b77a Rename pg_temp to pg_sorttemp so it does not conflict with temp table names. 1999-07-08 02:46:39 +00:00
Bruce Momjian 278bbf4572 Make functions static or NOT_USED as appropriate. 1999-05-26 12:57:23 +00:00
Bruce Momjian fcff1cdf4e Another pgindent run. Sorry folks. 1999-05-25 22:43:53 +00:00
Bruce Momjian 07842084fe pgindent run over code. 1999-05-25 16:15:34 +00:00
Tom Lane c1167a08ca Add 'temporary file' facility to fd.c, and arrange for temp
files to be closed automatically at transaction abort or commit, should
they still be open.  Also close any still-open stdio files allocated with
AllocateFile at abort/commit.  This should eliminate problems with leakage
of file descriptors after an error.  Also, put in some primitive buffered-IO
support so that psort.c can use virtual files without severe performance
penalties.
1999-05-09 00:52:08 +00:00
Bruce Momjian 58118db39d Add new postgres -O option to allow system table structure changes. 1999-03-17 22:53:31 +00:00
Bruce Momjian 6724a50787 Change my-function-name-- to my_function_name, and optimizer renames. 1999-02-13 23:22:53 +00:00
Bruce Momjian 9322950aa4 Cleanup of source files where 'return' or 'var =' is alone on a line. 1999-02-03 21:18:02 +00:00
Tom Lane 3d87216ab9 Get rid of some minor compiler warnings.
(HP's cc doesn't like if you forward-declare a routine static,
and then don't make it static in the actual definition...)
1998-10-26 01:00:13 +00:00
Bruce Momjian fa1a8d6a97 OK, folks, here is the pgindent output. 1998-09-01 04:40:42 +00:00
Bruce Momjian af74855a60 Renaming cleanup, no pgindent yet. 1998-09-01 03:29:17 +00:00
Bruce Momjian 6bd323c6b3 Remove un-needed braces around single statements. 1998-06-15 19:30:31 +00:00
Bruce Momjian 4b6fcc4459 Remove GetDatabaseName/Path and use globals. Make consts later. 1998-04-05 21:04:50 +00:00
Bruce Momjian a32450a585 pgindent run before 6.3 release, with Thomas' requested changes. 1998-02-26 04:46:47 +00:00
Bruce Momjian 679d39b9c8 Goodbye ABORT. Hello ERROR for all errors. 1998-01-07 21:07:04 +00:00
Bruce Momjian 0d9fc5afd6 Change elog(WARN) to elog(ERROR) and elog(ABORT). 1998-01-05 03:35:55 +00:00
Thomas G. Lockhart 7d1f2f8a27 Support alternate database locations. 1997-11-07 06:38:51 +00:00
Bruce Momjian 3f365ba0fc Inline memset() as MemSet(). 1997-09-18 20:22:58 +00:00
Bruce Momjian 59f6a57e59 Used modified version of indent that understands over 100 typedefs. 1997-09-08 21:56:23 +00:00
Bruce Momjian 319dbfa736 Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting. 1997-09-08 02:41:22 +00:00
Bruce Momjian 1ccd423235 Massive commit to run PGINDENT on all *.c and *.h files. 1997-09-07 05:04:48 +00:00
Bruce Momjian 1d8bbfd2e7 Make functions static where possible, enclose unused functions in #ifdef NOT_USED. 1997-08-19 21:40:56 +00:00
Bruce Momjian 022903f22e Reduce open() calls. Replace fopen() calls with calls to fd.c functions. 1997-08-18 02:15:04 +00:00
Bruce Momjian ea5b5357cd Remove more (void) and fix -Wall warnings. 1997-08-12 22:55:25 +00:00
Bruce Momjian 79e78f0b80 Added SCO support, from Daniel Harris. 1997-07-28 00:57:08 +00:00
Vadim B. Mikheev d865228807 AllocateFile():
fdleft = pg_nofile() - allocatedFiles - nfile;
looks more realistic, but too noisy -
   fdleft = pg_nofile() - allocatedFiles;
restored.
1997-05-23 02:56:48 +00:00
Vadim B. Mikheev ff8ce5230d 1. Cleanup (no more FreeFd - unuseful; others).
2. FreeFile() has to do nothing with nfile (# of files opened
   by VFD manager).
1997-05-22 16:51:19 +00:00
Marc G. Fournier 2280e62d39 Make the error message output by AllocateFile() if failes to
open Nulldev a *bit* more user friendly...or, at least, admin
friendly...have it print strerror(errno) as well
1997-02-20 22:54:18 +00:00
Bruce Momjian 31c8e94b34 Remove WIN32 defines. They never worked. 1997-02-14 04:19:07 +00:00
Marc G. Fournier a246e87d12 Convert MISSING_SYSCONF to !HAVE_SYSCONF for autoconf
From: Keith Parks
1997-01-27 00:09:47 +00:00
Marc G. Fournier ef228cb170 From: Keith Parks <emkxp01@mtcc.demon.co.uk>
OK, The votes are in for the NOFILES limit.

With the exception of Next, for which I've not yet heard, all supported platforms
seem to have the sysconf() call.


port           supported	default	Source.
aix            yes		2000	darrenk@insightdist.com
alpha          yes		4096	mjl@wwx.vip.at
BSD44_derived  yes		64	scrappy@hub.org
bsdi           yes		???	maillist@candle.pha.pa.us
dgux           yes		???	geek@andrew.cmu.edu
hpux           yes		60	emkxp01@mtcc.demon.co.uk
i386_solaris   yes		64	emkxp01@mtcc.demon.co.uk
irix5          yes		200	martin@biochem.uc.ac.uk
linux          yes		256	emkxp01@mtcc.demon.co.uk
next           ????		???
sparc_solaris  yes		64	emkxp01@mtcc.demon.co.uk
sunos4         yes		64	emkxp01@mtcc.demon.co.uk
svr4           yes		64	chicks@chicks.net
ultrix4        yes		64	erik@sockdev.uni-c.dk

So here's a patch that I think will do the job.
(I assume Next will have sysconf() but if not just add MISSING_SYSCONF to
 the config.h file )

Thanks,
Keith.
1997-01-13 01:25:29 +00:00
Bruce Momjian fd12c8f85e Fixed Assert check where ! should be !=. 1996-12-28 22:44:14 +00:00
Bryan Henderson 634b38aa86 Add asserts to check for file descriptor ring corruption. 1996-12-27 22:57:51 +00:00
Bryan Henderson 9005a38bdb Change portname "sparc" to "sunos4" and change some portname dependencies to
feature dependencies.  Thanks Kurt J. Lidl.
1996-12-04 03:06:33 +00:00
Bruce Momjian 4b2b8592a0 Compile and warning cleanup 1996-11-08 06:02:30 +00:00
Marc G. Fournier ce4c0ce1de Some compile failure fixes from Keith Parks <emkxp01@mtcc.demon.co.uk> 1996-11-06 06:52:23 +00:00
Bruce Momjian 18bbad7696 Remove OPENLINK define 1996-11-04 04:53:51 +00:00
Marc G. Fournier 4df1a41478 more removals of PORTNAME_* 1996-10-31 10:20:09 +00:00
Marc G. Fournier e7c3adcd94 *** src/backend/storage/file/fd.c.orig Thu Sep 12 17:17:21 1996
--- src/backend/storage/file/fd.c       Thu Sep 12 17:23:38 1996
***************
*** 262,268 ****
      Delete(file);

      /* save the seek position */
!     fileP->seekPos = lseek(fileP->fd, 0L, SEEK_CUR);
      Assert( fileP->seekPos != -1);

      /* if we have written to the file, sync it */
--- 262,268 ----
      Delete(file);

      /* save the seek position */
!     fileP->seekPos = (long) lseek(fileP->fd, 0L, SEEK_CUR);
      Assert( fileP->seekPos != -1);

      /* if we have written to the file, sync it */


Submitted by: Randy Terbush <randy@zyzzyva.com>
1996-09-22 01:30:52 +00:00
Marc G. Fournier 5108a5b320 More merges from Dr. George's tree...
- src/backend/tcop/*
                - cosmetic changes to OPENLINK patches
        - src/backend/storage/*
                - more changes, mostly cosmetic
        - src/backend/ports/*
                - merge in patches for aix and i386_solaris
1996-07-22 23:00:26 +00:00
Marc G. Fournier bc0bd47c6a Fixes: In the solaris port the file descriptors are hard coded to 20 (from the
include file sys/param.h

Submitted by:  michael.siebenborn@ae3.Hypo.DE (Michael Siebenborn (6929))
1996-07-18 04:59:42 +00:00
Marc G. Fournier faf21935d1 fsync patch from openlink 1996-07-15 19:22:17 +00:00
Marc G. Fournier d31084e9d1 Postgres95 1.01 Distribution - Virgin Sources 1996-07-09 06:22:35 +00:00