Skip to content
Snippets Groups Projects
  1. Jan 02, 2013
  2. Jan 01, 2013
  3. Nov 26, 2012
    • Tom Lane's avatar
      Revert patch for taking fewer snapshots. · 53299429
      Tom Lane authored
      This reverts commit d573e239, "Take fewer
      snapshots".  While that seemed like a good idea at the time, it caused
      execution to use a snapshot that had been acquired before locking any of
      the tables mentioned in the query.  This created user-visible anomalies
      that were not present in any prior release of Postgres, as reported by
      Tomas Vondra.  While this whole area could do with a redesign (since there
      are related cases that have anomalies anyway), it doesn't seem likely that
      any future patch would be reasonably back-patchable; and we don't want 9.2
      to exhibit a behavior that's subtly unlike either past or future releases.
      Hence, revert to prior code while we rethink the problem.
      53299429
  4. Oct 05, 2012
    • Heikki Linnakangas's avatar
      Use the regular main processing loop also in walsenders. · fd5942c1
      Heikki Linnakangas authored
      The regular backend's main loop handles signal handling and error recovery
      better than the current WAL sender command loop does. For example, if the
      client hangs and a SIGTERM is received before starting streaming, the
      walsender will now terminate immediately, rather than hang until the
      connection times out.
      fd5942c1
  5. Aug 10, 2012
    • Tom Lane's avatar
      Support having multiple Unix-domain sockets per postmaster. · c9b0cbe9
      Tom Lane authored
      Replace unix_socket_directory with unix_socket_directories, which is a list
      of socket directories, and adjust postmaster's code to allow zero or more
      Unix-domain sockets to be created.
      
      This is mostly a straightforward change, but since the Unix sockets ought
      to be created after the TCP/IP sockets for safety reasons (better chance
      of detecting a port number conflict), AddToDataDirLockFile needs to be
      fixed to support out-of-order updates of data directory lockfile lines.
      That's a change that had been foreseen to be necessary someday anyway.
      
      Honza Horak, reviewed and revised by Tom Lane
      c9b0cbe9
  6. Jul 17, 2012
    • Alvaro Herrera's avatar
      Introduce timeout handling framework · f34c68f0
      Alvaro Herrera authored
      Management of timeouts was getting a little cumbersome; what we
      originally had was more than enough back when we were only concerned
      about deadlocks and query cancel; however, when we added timeouts for
      standby processes, the code got considerably messier.  Since there are
      plans to add more complex timeouts, this seems a good time to introduce
      a central timeout handling module.
      
      External modules register their timeout handlers during process
      initialization, and later enable and disable them as they see fit using
      a simple API; timeout.c is in charge of keeping track of which timeouts
      are in effect at any time, installing a common SIGALRM signal handler,
      and calling setitimer() as appropriate to ensure timely firing of
      external handlers.
      
      timeout.c additionally supports pluggable modules to add their own
      timeouts, though this capability isn't exercised anywhere yet.
      
      Additionally, as of this commit, walsender processes are aware of
      timeouts; we had a preexisting bug there that made those ignore SIGALRM,
      thus being subject to unhandled deadlocks, particularly during the
      authentication phase.  This has already been fixed in back branches in
      commit 0bf8eb2a, which see for more details.
      
      Main author: Zoltán Böszörményi
      Some review and cleanup by Álvaro Herrera
      Extensive reworking by Tom Lane
      f34c68f0
  7. Jul 16, 2012
    • Peter Eisentraut's avatar
      Remove unreachable code · dd16f948
      Peter Eisentraut authored
      The Solaris Studio compiler warns about these instances, unlike more
      mainstream compilers such as gcc.  But manual inspection showed that
      the code is clearly not reachable, and we hope no worthy compiler will
      complain about removing this code.
      dd16f948
  8. Jun 25, 2012
    • Peter Eisentraut's avatar
      Unify calling conventions for postgres/postmaster sub-main functions · eeece9e6
      Peter Eisentraut authored
      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
  9. Jun 10, 2012
  10. May 07, 2012
  11. May 02, 2012
  12. Apr 18, 2012
    • Robert Haas's avatar
      Tighten up error recovery for fast-path locking. · 53c5b869
      Robert Haas authored
      The previous code could cause a backend crash after BEGIN; SAVEPOINT a;
      LOCK TABLE foo (interrupted by ^C or statement timeout); ROLLBACK TO
      SAVEPOINT a; LOCK TABLE foo, and might have leaked strong-lock counts
      in other situations.
      
      Report by Zoltán Böszörményi; patch review by Jeff Davis.
      53c5b869
  13. Apr 08, 2012
    • Heikki Linnakangas's avatar
      set_stack_base() no longer needs to be called in PostgresMain. · 03529a3f
      Heikki Linnakangas authored
      This was a thinko in previous commit. Now that stack base pointer is now set
      in PostmasterMain and SubPostmasterMain, it doesn't need to be set in
      PostgresMain anymore.
      03529a3f
    • Heikki Linnakangas's avatar
      Do stack-depth checking in all postmaster children. · ef3883d1
      Heikki Linnakangas authored
      We used to only initialize the stack base pointer when starting up a regular
      backend, not in other processes. In particular, autovacuum workers can run
      arbitrary user code, and without stack-depth checking, infinite recursion
      in e.g an index expression will bring down the whole cluster.
      
      The comment about PL/Java using set_stack_base() is not yet true. As the
      code stands, PL/java still modifies the stack_base_ptr variable directly.
      However, it's been discussed in the PL/Java mailing list that it should be
      changed to use the function, because PL/Java is currently oblivious to the
      register stack used on Itanium. There's another issues with PL/Java, namely
      that the stack base pointer it sets is not really the base of the stack, it
      could be something close to the bottom of the stack. That's a separate issue
      that might need some further changes to this code, but that's a different
      story.
      
      Backpatch to all supported releases.
      ef3883d1
  14. Mar 27, 2012
    • Tom Lane's avatar
      Add some infrastructure for contrib/pg_stat_statements. · a40fa613
      Tom Lane authored
      Add a queryId field to Query and PlannedStmt.  This is not used by the
      core backend, except for being copied around at appropriate times.
      It's meant to allow plug-ins to track a particular query forward from
      parse analysis to execution.
      
      The queryId is intentionally not dumped into stored rules (and hence this
      commit doesn't bump catversion).  You could argue that choice either way,
      but it seems better that stored rule strings not have any dependency
      on plug-ins that might or might not be present.
      
      Also, add a post_parse_analyze_hook that gets invoked at the end of
      parse analysis (but only for top-level analysis of complete queries,
      not cases such as analyzing a domain's default-value expression).
      This is mainly meant to be used to compute and assign a queryId,
      but it could have other applications.
      
      Peter Geoghegan
      a40fa613
  15. Mar 20, 2012
    • Tom Lane's avatar
      Restructure SELECT INTO's parsetree representation into CreateTableAsStmt. · 9dbf2b7d
      Tom Lane authored
      Making this operation look like a utility statement seems generally a good
      idea, and particularly so in light of the desire to provide command
      triggers for utility statements.  The original choice of representing it as
      SELECT with an IntoClause appendage had metastasized into rather a lot of
      places, unfortunately, so that this patch is a great deal more complicated
      than one might at first expect.
      
      In particular, keeping EXPLAIN working for SELECT INTO and CREATE TABLE AS
      subcommands required restructuring some EXPLAIN-related APIs.  Add-on code
      that calls ExplainOnePlan or ExplainOneUtility, or uses
      ExplainOneQuery_hook, will need adjustment.
      
      Also, the cases PREPARE ... SELECT INTO and CREATE RULE ... SELECT INTO,
      which formerly were accepted though undocumented, are no longer accepted.
      The PREPARE case can be replaced with use of CREATE TABLE AS EXECUTE.
      The CREATE RULE case doesn't seem to have much real-world use (since the
      rule would work only once before failing with "table already exists"),
      so we'll not bother with that one.
      
      Both SELECT INTO and CREATE TABLE AS still return a command tag of
      "SELECT nnnn".  There was some discussion of returning "CREATE TABLE nnnn",
      but for the moment backwards compatibility wins the day.
      
      Andres Freund and Tom Lane
      9dbf2b7d
  16. Mar 11, 2012
  17. Jan 19, 2012
    • Magnus Hagander's avatar
      Separate state from query string in pg_stat_activity · 4f42b546
      Magnus Hagander authored
      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. Jan 02, 2012
  19. Dec 21, 2011
    • Robert Haas's avatar
      Take fewer snapshots. · d573e239
      Robert Haas authored
      When a PORTAL_ONE_SELECT query is executed, we can opportunistically
      reuse the parse/plan shot for the execution phase.  This cuts down the
      number of snapshots per simple query from 2 to 1 for the simple
      protocol, and 3 to 2 for the extended protocol.  Since we are only
      reusing a snapshot taken early in the processing of the same protocol
      message, the change shouldn't be user-visible, except that the remote
      possibility of the planning and execution snapshots being different is
      eliminated.
      
      Note that this change does not make it safe to assume that the parse/plan
      snapshot will certainly be reused; that will currently only happen if
      PortalStart() decides to use the PORTAL_ONE_SELECT strategy.  It might
      be worth trying to provide some stronger guarantees here in the future,
      but for now we don't.
      
      Patch by me; review by Dimitri Fontaine.
      d573e239
  20. Dec 09, 2011
  21. Oct 08, 2011
    • Tom Lane's avatar
      Support index-only scans using the visibility map to avoid heap fetches. · a2822fb9
      Tom Lane authored
      When a btree index contains all columns required by the query, and the
      visibility map shows that all tuples on a target heap page are
      visible-to-all, we don't need to fetch that heap page.  This patch depends
      on the previous patches that made the visibility map reliable.
      
      There's a fair amount left to do here, notably trying to figure out a less
      chintzy way of estimating the cost of an index-only scan, but the core
      functionality seems ready to commit.
      
      Robert Haas and Ibrar Ahmed, with some previous work by Heikki Linnakangas.
      a2822fb9
  22. Oct 06, 2011
  23. Sep 16, 2011
    • Tom Lane's avatar
      Redesign the plancache mechanism for more flexibility and efficiency. · e6faf910
      Tom Lane authored
      Rewrite plancache.c so that a "cached plan" (which is rather a misnomer
      at this point) can support generation of custom, parameter-value-dependent
      plans, and can make an intelligent choice between using custom plans and
      the traditional generic-plan approach.  The specific choice algorithm
      implemented here can probably be improved in future, but this commit is
      all about getting the mechanism in place, not the policy.
      
      In addition, restructure the API to greatly reduce the amount of extraneous
      data copying needed.  The main compromise needed to make that possible was
      to split the initial creation of a CachedPlanSource into two steps.  It's
      worth noting in particular that SPI_saveplan is now deprecated in favor of
      SPI_keepplan, which accomplishes the same end result with zero data
      copying, and no need to then spend even more cycles throwing away the
      original SPIPlan.  The risk of long-term memory leaks while manipulating
      SPIPlans has also been greatly reduced.  Most of this improvement is based
      on use of the recently-added MemoryContextSetParent primitive.
      e6faf910
  24. Sep 09, 2011
    • Tom Lane's avatar
      Simplify handling of the timezone GUC by making initdb choose the default. · ca4af308
      Tom Lane authored
      We were doing some amazingly complicated things in order to avoid running
      the very expensive identify_system_timezone() procedure during GUC
      initialization.  But there is an obvious fix for that, which is to do it
      once during initdb and have initdb install the system-specific default into
      postgresql.conf, as it already does for most other GUC variables that need
      system-environment-dependent defaults.  This means that the timezone (and
      log_timezone) settings no longer have any magic behavior in the server.
      Per discussion.
      ca4af308
    • Tom Lane's avatar
      Move Timestamp/Interval typedefs and basic macros into datatype/timestamp.h. · a7801b62
      Tom Lane authored
      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
  25. Aug 10, 2011
    • Tom Lane's avatar
      Change the autovacuum launcher to use WaitLatch instead of a poll loop. · 4dab3d5a
      Tom Lane authored
      In pursuit of this (and with the expectation that WaitLatch will be needed
      in more places), convert the latch field that was already added to PGPROC
      for sync rep into a generic latch that is activated for all PGPROC-owning
      processes, and change many of the standard backend signal handlers to set
      that latch when a signal happens.  This will allow WaitLatch callers to be
      wakened properly by these signals.
      
      In passing, fix a whole bunch of signal handlers that had been hacked to do
      things that might change errno, without adding the necessary save/restore
      logic for errno.  Also make some minor fixes in unix_latch.c, and clean
      up bizarre and unsafe scheme for disowning the process's latch.  Much of
      this has to be back-patched into 9.1.
      
      Peter Geoghegan, with additional work by Tom
      4dab3d5a
  26. Jul 16, 2011
  27. Jun 29, 2011
  28. Apr 25, 2011
    • Bruce Momjian's avatar
      Add postmaster/postgres undocumented -b option for binary upgrades. · 76dd09bb
      Bruce Momjian authored
      This option turns off autovacuum, prevents non-super-user connections,
      and enables oid setting hooks in the backend.  The code continues to use
      the old autoavacuum disable settings for servers with earlier catalog
      versions.
      
      This includes a catalog version bump to identify servers that support
      the -b option.
      76dd09bb
  29. Apr 13, 2011
  30. Apr 10, 2011
  31. Apr 07, 2011
    • Tom Lane's avatar
      Revise the API for GUC variable assign hooks. · 2594cf0e
      Tom Lane authored
      The previous functions of assign hooks are now split between check hooks
      and assign hooks, where the former can fail but the latter shouldn't.
      Aside from being conceptually clearer, this approach exposes the
      "canonicalized" form of the variable value to guc.c without having to do
      an actual assignment.  And that lets us fix the problem recently noted by
      Bernd Helmle that the auto-tune patch for wal_buffers resulted in bogus
      log messages about "parameter "wal_buffers" cannot be changed without
      restarting the server".  There may be some speed advantage too, because
      this design lets hook functions avoid re-parsing variable values when
      restoring a previous state after a rollback (they can store a pre-parsed
      representation of the value instead).  This patch also resolves a
      longstanding annoyance about custom error messages from variable assign
      hooks: they should modify, not appear separately from, guc.c's own message
      about "invalid parameter value".
      2594cf0e
  32. Mar 17, 2011
    • Robert Haas's avatar
      Fix various possible problems with synchronous replication. · 9a56dc33
      Robert Haas authored
      1. Don't ignore query cancel interrupts.  Instead, if the user asks to
      cancel the query after we've already committed it, but before it's on
      the standby, just emit a warning and let the COMMIT finish.
      
      2. Don't ignore die interrupts (pg_terminate_backend or fast shutdown).
      Instead, emit a warning message and close the connection without
      acknowledging the commit.  Other backends will still see the effect of
      the commit, but there's no getting around that; it's too late to abort
      at this point, and ignoring die interrupts altogether doesn't seem like
      a good idea.
      
      3. If synchronous_standby_names becomes empty, wake up all backends
      waiting for synchronous replication to complete.  Without this, someone
      attempting to shut synchronous replication off could easily wedge the
      entire system instead.
      
      4. Avoid depending on the assumption that if a walsender updates
      MyProc->syncRepState, we'll see the change even if we read it without
      holding the lock.  The window for this appears to be quite narrow (and
      probably doesn't exist at all on machines with strong memory ordering)
      but protecting against it is practically free, so do that.
      
      5. Remove useless state SYNC_REP_MUST_DISCONNECT, which isn't needed and
      doesn't actually do anything.
      
      There's still some further work needed here to make the behavior of fast
      shutdown plausible, but that looks complex, so I'm leaving it for a
      separate commit.  Review by Fujii Masao.
      9a56dc33
  33. Mar 01, 2011
    • Tom Lane's avatar
      Rearrange snapshot handling to make rule expansion more consistent. · c0b00760
      Tom Lane authored
      With this patch, portals, SQL functions, and SPI all agree that there
      should be only a CommandCounterIncrement between the queries that are
      generated from a single SQL command by rule expansion.  Fetching a whole
      new snapshot now happens only between original queries.  This is equivalent
      to the existing behavior of EXPLAIN ANALYZE, and it was judged to be the
      best choice since it eliminates one source of concurrency hazards for
      rules.  The patch should also make things marginally faster by reducing the
      number of snapshot push/pop operations.
      
      The patch removes pg_parse_and_rewrite(), which is no longer used anywhere.
      There was considerable discussion about more aggressive refactoring of the
      query-processing functions exported by postgres.c, but for the moment
      nothing more has been done there.
      
      I also took the opportunity to refactor snapmgr.c's API slightly: the
      former PushUpdatedSnapshot() has been split into two functions.
      
      Marko Tiikkaja, reviewed by Steve Singer and Tom Lane
      c0b00760
  34. Feb 01, 2011
  35. Jan 27, 2011
    • Tom Lane's avatar
      Don't include <asm/ia64regs.h> unnecessarily. · 0ac8c8df
      Tom Lane authored
      We only need that header when compiling with icc, since the gcc variant of
      ia64_get_bsp() uses in-line assembly code.  Per report from Frank Brendel,
      the header doesn't exist on all IA64 platforms; so don't include it unless
      we need it.
      0ac8c8df
  36. Jan 03, 2011
Loading