1. 11 9月, 2007 1 次提交
    • A
      Remove the vacuum_delay_point call in count_nondeletable_pages, because we hold · 21c27af6
      Alvaro Herrera 提交于
      an exclusive lock on the table at this point, which we want to release as soon
      as possible.  This is called in the phase of lazy vacuum where we truncate the
      empty pages at the end of the table.
      
      An alternative solution would be to lower the vacuum delay settings before
      starting the truncating phase, but this doesn't work very well in autovacuum
      due to the autobalancing code (which can cause other processes to change our
      cost delay settings).  This case could be considered in the balancing code, but
      it is simpler this way.
      21c27af6
  2. 06 9月, 2007 1 次提交
    • T
      Implement lazy XID allocation: transactions that do not modify any database · 295e6398
      Tom Lane 提交于
      rows will normally never obtain an XID at all.  We already did things this way
      for subtransactions, but this patch extends the concept to top-level
      transactions.  In applications where there are lots of short read-only
      transactions, this should improve performance noticeably; not so much from
      removal of the actual XID-assignments, as from reduction of overhead that's
      driven by the rate of XID consumption.  We add a concept of a "virtual
      transaction ID" so that active transactions can be uniquely identified even
      if they don't have a regular XID.  This is a much lighter-weight concept:
      uniqueness of VXIDs is only guaranteed over the short term, and no on-disk
      record is made about them.
      
      Florian Pflug, with some editorialization by Tom.
      295e6398
  3. 31 5月, 2007 1 次提交
    • T
      Make large sequential scans and VACUUMs work in a limited-size "ring" of · d526575f
      Tom Lane 提交于
      buffers, rather than blowing out the whole shared-buffer arena.  Aside from
      avoiding cache spoliation, this fixes the problem that VACUUM formerly tended
      to cause a WAL flush for every page it modified, because we had it hacked to
      use only a single buffer.  Those flushes will now occur only once per
      ring-ful.  The exact ring size, and the threshold for seqscans to switch into
      the ring usage pattern, remain under debate; but the infrastructure seems
      done.  The key bit of infrastructure is a new optional BufferAccessStrategy
      object that can be passed to ReadBuffer operations; this replaces the former
      StrategyHintVacuum API.
      
      This patch also changes the buffer usage-count methodology a bit: we now
      advance usage_count when first pinning a buffer, rather than when last
      unpinning it.  To preserve the behavior that a buffer's lifetime starts to
      decrease when it's released, the clock sweep code is modified to not decrement
      usage_count of pinned buffers.
      
      Work not done in this commit: teach GiST and GIN indexes to use the vacuum
      BufferAccessStrategy for vacuum-driven fetches.
      
      Original patch by Simon, reworked by Heikki and again by Tom.
      d526575f
  4. 17 5月, 2007 1 次提交
    • A
      Move the tuple freezing point in CLUSTER to a point further back in the past, · 3b0347b3
      Alvaro Herrera 提交于
      to avoid losing useful Xid information in not-so-old tuples.  This makes
      CLUSTER behave the same as VACUUM as far a tuple-freezing behavior goes
      (though CLUSTER does not yet advance the table's relfrozenxid).
      
      While at it, move the actual freezing operation in rewriteheap.c to a more
      appropriate place, and document it thoroughly.  This part of the patch from
      Tom Lane.
      3b0347b3
  5. 30 4月, 2007 1 次提交
    • T
      Implement rate-limiting logic on how often backends will attempt to send · 957d08c8
      Tom Lane 提交于
      messages to the stats collector.  This avoids the problem that enabling
      stats_row_level for autovacuum has a significant overhead for short
      read-only transactions, as noted by Arjen van der Meijden.  We can avoid
      an extra gettimeofday call by piggybacking on the one done for WAL-logging
      xact commit or abort (although that doesn't help read-only transactions,
      since they don't WAL-log anything).
      
      In my proposal for this, I noted that we could change the WAL log entries
      for commit/abort to record full TimestampTz precision, instead of only
      time_t as at present.  That's not done in this patch, but will be committed
      separately.
      957d08c8
  6. 20 4月, 2007 1 次提交
  7. 19 4月, 2007 1 次提交
  8. 22 2月, 2007 2 次提交
  9. 04 2月, 2007 1 次提交
  10. 06 1月, 2007 1 次提交
  11. 06 11月, 2006 1 次提交
    • T
      Fix recently-understood problems with handling of XID freezing, particularly · 48188e16
      Tom Lane 提交于
      in PITR scenarios.  We now WAL-log the replacement of old XIDs with
      FrozenTransactionId, so that such replacement is guaranteed to propagate to
      PITR slave databases.  Also, rather than relying on hint-bit updates to be
      preserved, pg_clog is not truncated until all instances of an XID are known to
      have been replaced by FrozenTransactionId.  Add new GUC variables and
      pg_autovacuum columns to allow management of the freezing policy, so that
      users can trade off the size of pg_clog against the amount of freezing work
      done.  Revise the already-existing code that forces autovacuum of tables
      approaching the wraparound point to make it more bulletproof; also, revise the
      autovacuum logic so that anti-wraparound vacuuming is done per-table rather
      than per-database.  initdb forced because of changes in pg_class, pg_database,
      and pg_autovacuum catalogs.  Heikki Linnakangas, Simon Riggs, and Tom Lane.
      48188e16
  12. 04 10月, 2006 1 次提交
  13. 22 9月, 2006 1 次提交
    • T
      Fix free space map to correctly track the total amount of FSM space needed · 9e936693
      Tom Lane 提交于
      even when a single relation requires more than max_fsm_pages pages.  Also,
      make VACUUM emit a warning in this case, since it likely means that VACUUM
      FULL or other drastic corrective measure is needed.  Per reports from Jeff
      Frost and others of unexpected changes in the claimed max_fsm_pages need.
      9e936693
  14. 14 9月, 2006 1 次提交
  15. 05 9月, 2006 1 次提交
  16. 01 8月, 2006 1 次提交
    • T
      Change the relation_open protocol so that we obtain lock on a relation · 09d3670d
      Tom Lane 提交于
      (table or index) before trying to open its relcache entry.  This fixes
      race conditions in which someone else commits a change to the relation's
      catalog entries while we are in process of doing relcache load.  Problems
      of that ilk have been reported sporadically for years, but it was not
      really practical to fix until recently --- for instance, the recent
      addition of WAL-log support for in-place updates helped.
      
      Along the way, remove pg_am.amconcurrent: all AMs are now expected to support
      concurrent update.
      09d3670d
  17. 14 7月, 2006 2 次提交
  18. 11 7月, 2006 1 次提交
    • A
      Improve vacuum code to track minimum Xids per table instead of per database. · d4cef0aa
      Alvaro Herrera 提交于
      To this end, add a couple of columns to pg_class, relminxid and relvacuumxid,
      based on which we calculate the pg_database columns after each vacuum.
      
      We now force all databases to be vacuumed, even template ones.  A backend
      noticing too old a database (meaning pg_database.datminxid is in danger of
      falling behind Xid wraparound) will signal the postmaster, which in turn will
      start an autovacuum iteration to process the offending database.  In principle
      this is only there to cope with frozen (non-connectable) databases without
      forcing users to set them to connectable, but it could force regular user
      database to go through a database-wide vacuum at any time.  Maybe we should
      warn users about this somehow.  Of course the real solution will be to use
      autovacuum all the time ;-)
      
      There are some additional improvements we could have in this area: for example
      the vacuum code could be smarter about not updating pg_database for each table
      when called by autovacuum, and do it only once the whole autovacuum iteration
      is done.
      
      I updated the system catalogs documentation, but I didn't modify the
      maintenance section.  Also having some regression tests for this would be nice
      but it's not really a very straightforward thing to do.
      
      Catalog version bumped due to system catalog changes.
      d4cef0aa
  19. 04 7月, 2006 1 次提交
    • T
      Code review for FILLFACTOR patch. Change WITH grammar as per earlier · b7b78d24
      Tom Lane 提交于
      discussion (including making def_arg allow reserved words), add missed
      opt_definition for UNIQUE case.  Put the reloptions support code in a less
      random place (I chose to make a new file access/common/reloptions.c).
      Eliminate header inclusion creep.  Make the index options functions safely
      user-callable (seems like client apps might like to be able to test validity
      of options before trying to make an index).  Reduce overhead for normal case
      with no options by allowing rd_options to be NULL.  Fix some unmaintainably
      klugy code, including getting rid of Natts_pg_class_fixed at long last.
      Some stylistic cleanup too, and pay attention to keeping comments in sync
      with code.
      
      Documentation still needs work, though I did fix the omissions in
      catalogs.sgml and indexam.sgml.
      b7b78d24
  20. 02 7月, 2006 1 次提交
  21. 03 5月, 2006 1 次提交
  22. 01 4月, 2006 1 次提交
    • T
      Clean up WAL/buffer interactions as per my recent proposal. Get rid of the · a8b8f4db
      Tom Lane 提交于
      misleadingly-named WriteBuffer routine, and instead require routines that
      change buffer pages to call MarkBufferDirty (which does exactly what it says).
      We also require that they do so before calling XLogInsert; this takes care of
      the synchronization requirement documented in SyncOneBuffer.  Note that
      because bufmgr takes the buffer content lock (in shared mode) while writing
      out any buffer, it doesn't matter whether MarkBufferDirty is executed before
      the buffer content change is complete, so long as the content change is
      completed before releasing exclusive lock on the buffer.  So it's OK to set
      the dirtybit before we fill in the LSN.
      This eliminates the former kluge of needing to set the dirtybit in LockBuffer.
      Aside from making the code more transparent, we can also add some new
      debugging assertions, in particular that the caller of MarkBufferDirty must
      hold the buffer content lock, not merely a pin.
      a8b8f4db
  23. 05 3月, 2006 2 次提交
  24. 12 2月, 2006 3 次提交
  25. 23 11月, 2005 1 次提交
  26. 21 11月, 2005 1 次提交
  27. 15 10月, 2005 1 次提交
  28. 04 10月, 2005 1 次提交
  29. 23 9月, 2005 1 次提交
    • T
      Take exclusive buffer lock in scan_heap() to eliminate some corner cases · a453951d
      Tom Lane 提交于
      in which invalid page data could be transiently written to disk by
      concurrent bgwriter activity.  There doesn't seem any risk of loss of
      actual user data, but an empty page could possibly be left corrupt if a
      crash occurs before the correct data gets written out.  Pointed out by
      Alvaro Herrera.
      a453951d
  30. 03 9月, 2005 1 次提交
    • T
      Clean up a couple of ad-hoc computations of the maximum number of tuples · 35e9b1cc
      Tom Lane 提交于
      on a page, as suggested by ITAGAKI Takahiro.  Also, change a few places
      that were using some other estimates of max-items-per-page to consistently
      use MaxOffsetNumber.  This is conservatively large --- we could have used
      the new MaxHeapTuplesPerPage macro, or a similar one for index tuples ---
      but those places are simply declaring a fixed-size buffer and assuming it
      will work, rather than actively testing for overrun.  It seems safer to
      size these buffers in a way that can't overflow even if the page is
      corrupt.
      35e9b1cc
  31. 21 8月, 2005 1 次提交
    • T
      Convert the arithmetic for shared memory size calculation from 'int' · 0007490e
      Tom Lane 提交于
      to 'Size' (that is, size_t), and install overflow detection checks in it.
      This allows us to remove the former arbitrary restrictions on NBuffers
      etc.  It won't make any difference in a 32-bit machine, but in a 64-bit
      machine you could theoretically have terabytes of shared buffers.
      (How efficiently we could manage 'em remains to be seen.)  Similarly,
      num_temp_buffers, work_mem, and maintenance_work_mem can be set above
      2Gb on a 64-bit machine.  Original patch from Koichi Suzuki, additional
      work by moi.
      0007490e
  32. 30 7月, 2005 1 次提交
    • T
      Clean up a number of autovacuum loose ends. Make the stats collector · 5d5f1a79
      Tom Lane 提交于
      track shared relations in a separate hashtable, so that operations done
      from different databases are counted correctly.  Add proper support for
      anti-XID-wraparound vacuuming, even in databases that are never connected
      to and so have no stats entries.  Miscellaneous other bug fixes.
      Alvaro Herrera, some additional fixes by Tom Lane.
      5d5f1a79
  33. 14 7月, 2005 1 次提交
  34. 20 5月, 2005 1 次提交
  35. 08 5月, 2005 1 次提交
    • T
      Repair very-low-probability race condition between relation extension · 30f540be
      Tom Lane 提交于
      and VACUUM: in the interval between adding a new page to the relation
      and formatting it, it was possible for VACUUM to come along and decide
      it should format the page too.  Though not harmful in itself, this would
      cause data loss if a third transaction were able to insert tuples into
      the vacuumed page before the original extender got control back.
      30f540be