1. 31 8月, 2012 1 次提交
    • A
      Split tuple struct defs from htup.h to htup_details.h · c219d9b0
      Alvaro Herrera 提交于
      This reduces unnecessary exposure of other headers through htup.h, which
      is very widely included by many files.
      
      I have chosen to move the function prototypes to the new file as well,
      because that means htup.h no longer needs to include tupdesc.h.  In
      itself this doesn't have much effect in indirect inclusion of tupdesc.h
      throughout the tree, because it's also required by execnodes.h; but it's
      something to explore in the future, and it seemed best to do the htup.h
      change now while I'm busy with it.
      c219d9b0
  2. 26 6月, 2012 1 次提交
    • P
      Unify calling conventions for postgres/postmaster sub-main functions · eeece9e6
      Peter Eisentraut 提交于
      There was a wild mix of calling conventions: Some were declared to
      return void and didn't return, some returned an int exit code, some
      claimed to return an exit code, which the callers checked, but
      actually never returned, and so on.
      
      Now all of these functions are declared to return void and decorated
      with attribute noreturn and don't return.  That's easiest, and most
      code already worked that way.
      eeece9e6
  3. 18 6月, 2012 1 次提交
    • T
      Fix stats collector to recover nicely when system clock goes backwards. · 9e18eacb
      Tom Lane 提交于
      Formerly, if the system clock went backwards, the stats collector would
      fail to update the stats file any more until the clock reading again
      exceeds whatever timestamp was last written into the stats file.  Such
      glitches in the clock's behavior are not terribly unlikely on machines
      not using NTP.  Such a scenario has been observed to cause regression test
      failures in the buildfarm, and it could have bad effects on the behavior
      of autovacuum, so it seems prudent to install some defenses.
      
      We could directly detect the clock going backwards by adding
      GetCurrentTimestamp calls in the stats collector's main loop, but that
      would hurt performance on platforms where GetCurrentTimestamp is expensive.
      To minimize the performance hit in normal cases, adopt a more complicated
      scheme wherein backends check for clock skew when reading the stats file,
      and if they see it, signal the stats collector by sending an extra stats
      inquiry message.  The stats collector does an extra GetCurrentTimestamp
      only when it receives an inquiry with an apparently out-of-order
      timestamp.
      
      To avoid unnecessary GetCurrentTimestamp calls, expand the inquiry messages
      to carry the backend's current clock reading as well as its stats cutoff
      time.  The latter, being intentionally slightly in-the-past, would trigger
      more clock rechecks than we need if it were used for this purpose.
      
      We might want to backpatch this change at some point, but let's let it
      shake out in the buildfarm for awhile first.
      9e18eacb
  4. 11 6月, 2012 1 次提交
  5. 15 5月, 2012 3 次提交
    • T
      In pgstat.c, use a timeout in WaitLatchOrSocket only on Windows. · 9b63e986
      Tom Lane 提交于
      We have no need for a timeout here really, but some broken products from
      Redmond seem to lose FD_READ events occasionally, and waking up and
      retrying the recv() is the only known way to work around that.  Perhaps
      somebody will be motivated to figure out a better answer here; but not I.
      9b63e986
    • T
      Revert "Add some temporary instrumentation to pgstat.c." · 5a2bb060
      Tom Lane 提交于
      This reverts commit 7d88bb73.
      That instrumentation has served its purpose.
      5a2bb060
    • T
      For testing purposes, reinsert a timeout in pgstat.c's wait call. · d461d050
      Tom Lane 提交于
      Test results from buildfarm members mastodon/narwhal (Windows Server 2003)
      make it look like that platform just plain loses FD_READ events
      occasionally, and the only reason our previous coding seemed to work was
      that it timed out every couple of seconds and retried the whole operation.
      Try to verify this by reinserting a finite timeout into the pgstat loop.
      This isn't meant to be a permanent patch either, just to confirm or
      disprove a theory.
      d461d050
  6. 14 5月, 2012 3 次提交
    • T
      Force pgwin32_recv into nonblock mode when called from pgstat.c. · f1ca5154
      Tom Lane 提交于
      This should get rid of the usage of pgwin32_waitforsinglesocket entirely,
      and perhaps thereby remove the race condition that's evidently still
      present on some versions of Windows.  The previous arrangement was a bit
      unsafe anyway, since waiting at the recv() would not allow pgstat to notice
      postmaster death.
      f1ca5154
    • T
      Add some temporary instrumentation to pgstat.c. · 7d88bb73
      Tom Lane 提交于
      Log main-loop blocking events and the results of inquiry messages.
      This is to get some clarity as to what's happening on those Windows
      buildfarm members that still don't like the latch-ified stats collector.
      This bulks up the postmaster log a tad, so I won't leave it in place for
      long.
      7d88bb73
    • T
      Re-revert stats collector latch changes. · 966970ed
      Tom Lane 提交于
      This reverts commit cb2f2873, restoring
      the latch-ified stats collector logic.  We'll soon see if this works any
      better on the Windows buildfarm machines.
      966970ed
  7. 11 5月, 2012 2 次提交
    • T
      Temporarily revert stats collector latch changes so we can ship beta1. · cb2f2873
      Tom Lane 提交于
      This patch reverts commit 49340037 and some
      follow-on tweaking in pgstat.c.  While the basic scheme of latch-ifying the
      stats collector seems sound enough, it's failing on most Windows buildfarm
      members for unknown reasons, and there's no time left to debug that before
      9.2beta1.  Better to ship a beta version without this improvement.  I hope
      to re-revert this once beta1 is out, though.
      cb2f2873
    • T
      Make WaitLatch's WL_POSTMASTER_DEATH result trustworthy; simplify callers. · f40022f1
      Tom Lane 提交于
      Per a suggestion from Peter Geoghegan, make WaitLatch responsible for
      verifying that the WL_POSTMASTER_DEATH bit it returns is truthful (by
      testing PostmasterIsAlive).  Then simplify its callers, who no longer
      need to do that for themselves.  Remove weasel wording about falsely-set
      result bits from WaitLatch's API contract.
      f40022f1
  8. 10 5月, 2012 1 次提交
    • T
      Improve tests for postmaster death in auxiliary processes. · fd71421b
      Tom Lane 提交于
      In checkpointer and walwriter, avoid calling PostmasterIsAlive unless
      WaitLatch has reported WL_POSTMASTER_DEATH.  This saves a kernel call per
      iteration of the process's outer loop, which is not all that much, but a
      cycle shaved is a cycle earned.  I had already removed the unconditional
      PostmasterIsAlive calls in bgwriter and pgstat in previous patches, but
      forgot that WL_POSTMASTER_DEATH is supposed to be treated as untrustworthy
      (per comment in unix_latch.c); so adjust those two cases to match.
      
      There are a few other places where the same idea might be applied, but only
      after substantial code rearrangement, so I didn't bother.
      fd71421b
  9. 09 5月, 2012 1 次提交
    • T
      Reduce idle power consumption of stats collector process. · 49340037
      Tom Lane 提交于
      Latch-ify the stats collector, so that it does not need an arbitrary wakeup
      cycle to check for postmaster death.  The incremental savings in idle power
      is pretty marginal, since we only had it waking every two seconds; but I
      believe that this patch may also improve the collector's performance under
      load, by reducing the number of kernel calls made per message when messages
      are arriving constantly (we now avoid a select/poll call except when we
      need to sleep).  The change also reduces the time needed for a normal
      database shutdown on platforms where signals don't interrupt select().
      49340037
  10. 01 5月, 2012 1 次提交
    • T
      Converge all SQL-level statistics timing values to float8 milliseconds. · 809e7e21
      Tom Lane 提交于
      This patch adjusts the core statistics views to match the decision already
      taken for pg_stat_statements, that values representing elapsed time should
      be represented as float8 and measured in milliseconds.  By using float8,
      we are no longer tied to a specific maximum precision of timing data.
      (Internally, it's still microseconds, but we could now change that without
      needing changes at the SQL level.)
      
      The columns affected are
      pg_stat_bgwriter.checkpoint_write_time
      pg_stat_bgwriter.checkpoint_sync_time
      pg_stat_database.blk_read_time
      pg_stat_database.blk_write_time
      pg_stat_user_functions.total_time
      pg_stat_user_functions.self_time
      pg_stat_xact_user_functions.total_time
      pg_stat_xact_user_functions.self_time
      
      The first four of these are new in 9.2, so there is no compatibility issue
      from changing them.  The others require a release note comment that they
      are now double precision (and can show a fractional part) rather than
      bigint as before; also their underlying statistics functions now match
      the column definitions, instead of returning bigint microseconds.
      809e7e21
  11. 30 4月, 2012 1 次提交
  12. 29 4月, 2012 1 次提交
  13. 06 4月, 2012 1 次提交
  14. 05 4月, 2012 1 次提交
  15. 26 1月, 2012 3 次提交
  16. 25 1月, 2012 1 次提交
  17. 19 1月, 2012 1 次提交
    • M
      Separate state from query string in pg_stat_activity · 4f42b546
      Magnus Hagander 提交于
      This separates the state (running/idle/idleintransaction etc) into
      it's own field ("state"), and leaves the query field containing just
      query text.
      
      The query text will now mean "current query" when a query is running
      and "last query" in other states. Accordingly,the field has been
      renamed from current_query to query.
      
      Since backwards compatibility was broken anyway to make that, the procpid
      field has also been renamed to pid - along with the same field in
      pg_stat_replication for consistency.
      
      Scott Mead and Magnus Hagander, review work from Greg Smith
      4f42b546
  18. 02 1月, 2012 1 次提交
  19. 09 11月, 2011 1 次提交
    • H
      In COPY, insert tuples to the heap in batches. · d326d9e8
      Heikki Linnakangas 提交于
      This greatly reduces the WAL volume, especially when the table is narrow.
      The overhead of locking the heap page is also reduced. Reduced WAL traffic
      also makes it scale a lot better, if you run multiple COPY processes at
      the same time.
      d326d9e8
  20. 22 10月, 2011 2 次提交
    • T
      Code review for pgstat_get_crashed_backend_activity patch. · f9c92a5a
      Tom Lane 提交于
      Avoid possibly dumping core when pgstat_track_activity_query_size has a
      less-than-default value; avoid uselessly searching for the query string
      of a successfully-exited backend; don't bother putting out an ERRDETAIL if
      we don't have a query to show; some other minor stylistic improvements.
      f9c92a5a
    • R
      Try to log current the query string when a backend crashes. · c8e8b5a6
      Robert Haas 提交于
      To avoid minimize risk inside the postmaster, we subject this feature
      to a number of significant limitations.  We very much wish to avoid
      doing any complex processing inside the postmaster, due to the
      posssibility that the crashed backend has completely corrupted shared
      memory.  To that end, no encoding conversion is done; instead, we just
      replace anything that doesn't look like an ASCII character with a
      question mark.  We limit the amount of data copied to 1024 characters,
      and carefully sanity check the source of that data.  While these
      restrictions would doubtless be unacceptable in a general-purpose
      logging facility, even this limited facility seems like an improvement
      over the status quo ante.
      
      Marti Raudsepp, reviewed by PDXPUG and myself
      c8e8b5a6
  21. 19 10月, 2011 1 次提交
    • T
      Suppress -Wunused-result warnings about write() and fwrite(). · aa90e148
      Tom Lane 提交于
      This is merely an exercise in satisfying pedants, not a bug fix, because
      in every case we were checking for failure later with ferror(), or else
      there was nothing useful to be done about a failure anyway.  Document
      the latter cases.
      aa90e148
  22. 17 9月, 2011 1 次提交
    • T
      Remove debug logging for pgstat wait timeout. · 99b54541
      Tom Lane 提交于
      This reverts commit 79b2ee20, which proved
      to not be very informative; it looks like the "pgstat wait timeout"
      warnings in the buildfarm are just a symptom of running on heavily loaded
      machines, and there isn't any weird mechanism causing them to appear.
      
      To try to reduce the frequency of buildfarm failures from this effect,
      increase PGSTAT_MAX_WAIT_TIME from 5 seconds to 10.
      
      Also, arrange to not send a fresh inquiry message every single time through
      the loop, as that seems more likely to cause problems (by swamping the
      collector) than fix them.  We'll now send an inquiry the first time through
      the delay loop, and every 640 msec thereafter.
      99b54541
  23. 10 9月, 2011 1 次提交
    • T
      Move Timestamp/Interval typedefs and basic macros into datatype/timestamp.h. · a7801b62
      Tom Lane 提交于
      As per my recent proposal, this refactors things so that these typedefs and
      macros are available in a header that can be included in frontend-ish code.
      I also changed various headers that were undesirably including
      utils/timestamp.h to include datatype/timestamp.h instead.  Unsurprisingly,
      this showed that half the system was getting utils/timestamp.h by way of
      xlog.h.
      
      No actual code changes here, just header refactoring.
      a7801b62
  24. 11 8月, 2011 1 次提交
    • T
      Add a bit of debug logging to backend_read_statsfile(). · 79b2ee20
      Tom Lane 提交于
      This is in hopes of learning more about what causes "pgstat wait timeout"
      warnings in the buildfarm.  This patch should probably be reverted once
      we've learned what we can.  As coded, it will result in regression test
      "failures" at half the delay that the existing code does, so I expect
      to see a few more than before.
      79b2ee20
  25. 08 7月, 2011 1 次提交
    • H
      Introduce a pipe between postmaster and each backend, which can be used to · 89fd72cb
      Heikki Linnakangas 提交于
      detect postmaster death. Postmaster keeps the write-end of the pipe open,
      so when it dies, children get EOF in the read-end. That can conveniently
      be waited for in select(), which allows eliminating some of the polling
      loops that check for postmaster death. This patch doesn't yet change all
      the loops to use the new mechanism, expect a follow-on patch to do that.
      
      This changes the interface to WaitLatch, so that it takes as argument a
      bitmask of events that it waits for. Possible events are latch set, timeout,
      postmaster death, and socket becoming readable or writeable.
      
      The pipe method behaves slightly differently from the kill() method
      previously used in PostmasterIsAlive() in the case that postmaster has died,
      but its parent has not yet read its exit code with waitpid(). The pipe
      returns EOF as soon as the process dies, but kill() continues to return
      true until waitpid() has been called (IOW while the process is a zombie).
      Because of that, change PostmasterIsAlive() to use the pipe too, otherwise
      WaitLatch() would return immediately with WL_POSTMASTER_DEATH, while
      PostmasterIsAlive() would claim it's still alive. That could easily lead to
      busy-waiting while postmaster is in zombie state.
      
      Peter Geoghegan with further changes by me, reviewed by Fujii Masao and
      Florian Pflug.
      89fd72cb
  26. 31 5月, 2011 1 次提交
    • T
      Fix VACUUM so that it always updates pg_class.reltuples/relpages. · b4b6923e
      Tom Lane 提交于
      When we added the ability for vacuum to skip heap pages by consulting the
      visibility map, we made it just not update the reltuples/relpages
      statistics if it skipped any pages.  But this could leave us with extremely
      out-of-date stats for a table that contains any unchanging areas,
      especially for TOAST tables which never get processed by ANALYZE.  In
      particular this could result in autovacuum making poor decisions about when
      to process the table, as in recent report from Florian Helmberger.  And in
      general it's a bad idea to not update the stats at all.  Instead, use the
      previous values of reltuples/relpages as an estimate of the tuple density
      in unvisited pages.  This approach results in a "moving average" estimate
      of reltuples, which should converge to the correct value over multiple
      VACUUM and ANALYZE cycles even when individual measurements aren't very
      good.
      
      This new method for updating reltuples is used by both VACUUM and ANALYZE,
      with the result that we no longer need the grotty interconnections that
      caused ANALYZE to not update the stats depending on what had happened
      in the parent VACUUM command.
      
      Also, fix the logic for skipping all-visible pages during VACUUM so that it
      looks ahead rather than behind to decide what to do, as per a suggestion
      from Greg Stark.  This eliminates useless scanning of all-visible pages at
      the start of the relation or just after a not-all-visible page.  In
      particular, the first few pages of the relation will not be invariably
      included in the scanned pages, which seems to help in not overweighting
      them in the reltuples estimate.
      
      Back-patch to 8.4, where the visibility map was introduced.
      b4b6923e
  27. 10 4月, 2011 1 次提交
  28. 08 3月, 2011 1 次提交
  29. 18 2月, 2011 1 次提交
  30. 10 2月, 2011 1 次提交
  31. 03 1月, 2011 1 次提交
  32. 02 1月, 2011 1 次提交