1. 07 2月, 2016 1 次提交
    • R
      Introduce group locking to prevent parallel processes from deadlocking. · a1c1af2a
      Robert Haas 提交于
      For locking purposes, we now regard heavyweight locks as mutually
      non-conflicting between cooperating parallel processes.  There are some
      possible pitfalls to this approach that are not to be taken lightly,
      but it works OK for now and can be changed later if we find a better
      approach.  Without this, it's very easy for parallel queries to
      silently self-deadlock if the user backend holds strong relation locks.
      
      Robert Haas, with help from Amit Kapila.  Thanks to Noah Misch and
      Andres Freund for extensive discussion of possible issues with this
      approach.
      a1c1af2a
  2. 29 1月, 2016 1 次提交
    • R
      Migrate PGPROC's backendLock into PGPROC itself, using a new tranche. · b319356f
      Robert Haas 提交于
      Previously, each PGPROC's backendLock was part of the main tranche,
      and the PGPROC just contained a pointer.  Now, the actual LWLock is
      part of the PGPROC.
      
      As with previous, similar patches, this makes it significantly easier
      to identify these lwlocks in LWLOCK_STATS or Trace_lwlocks output
      and improves modularity.
      
      Author: Ildus Kurbangaliev
      Reviewed-by: Amit Kapila, Robert Haas
      b319356f
  3. 03 1月, 2016 1 次提交
  4. 17 10月, 2015 1 次提交
  5. 04 9月, 2015 1 次提交
    • R
      Assorted code review for recent ProcArrayLock patch. · 4aec4989
      Robert Haas 提交于
      Post-commit review by Andres Freund discovered a couple of concurrency
      bugs in the original patch: specifically, if the leader cleared a
      follower's XID before it reached PGSemaphoreLock, the semaphore would be
      left in the wrong state; and if another process did PGSemaphoreUnlock
      for some unrelated reason, we might resume execution before the fact
      that our XID was cleared was globally visible.
      
      Also, improve the wording of some comments, rename nextClearXidElem
      to firstClearXidElem in PROC_HDR for clarity, and drop some volatile
      qualifiers that aren't necessary.
      
      Amit Kapila, reviewed and slightly revised by me.
      4aec4989
  6. 07 8月, 2015 1 次提交
    • R
      Reduce ProcArrayLock contention by removing backends in batches. · 0e141c0f
      Robert Haas 提交于
      When a write transaction commits, it must clear its XID advertised via
      the ProcArray, which requires that we hold ProcArrayLock in exclusive
      mode in order to prevent concurrent processes running GetSnapshotData
      from seeing inconsistent results.  When many processes try to commit
      at once, ProcArrayLock must change hands repeatedly, with each
      concurrent process trying to commit waking up to acquire the lock in
      turn.  To make things more efficient, when more than one backend is
      trying to commit a write transaction at the same time, have just one
      of them acquire ProcArrayLock in exclusive mode and clear the XIDs of
      all processes in the group.  Benchmarking reveals that this is much
      more efficient at very high client counts.
      
      Amit Kapila, heavily revised by me, with some review also from Pavan
      Deolasee.
      0e141c0f
  7. 29 7月, 2015 2 次提交
    • T
      Reduce chatter from signaling of autovacuum workers. · d8f15c95
      Tom Lane 提交于
      Don't print a WARNING if we get ESRCH from a kill() that's attempting
      to cancel an autovacuum worker.  It's possible (and has been seen in the
      buildfarm) that the worker is already gone by the time we are able to
      execute the kill, in which case the failure is harmless.  About the only
      plausible reason for reporting such cases would be to help debug corrupted
      lock table contents, but this is hardly likely to be the most important
      symptom if that happens.  Moreover issuing a WARNING might scare users
      more than is warranted.
      
      Also, since sending a signal to an autovacuum worker is now entirely a
      routine thing, and the worker will log the query cancel on its end anyway,
      reduce the message saying we're doing that from LOG to DEBUG1 level.
      
      Very minor cosmetic cleanup as well.
      
      Since the main practical reason for doing this is to avoid unnecessary
      buildfarm failures, back-patch to all active branches.
      d8f15c95
    • R
      Centralize decision-making about where to get a backend's PGPROC. · 6f2871f1
      Robert Haas 提交于
      This code was originally written as part of parallel query effort, but
      it seems to have independent value, because if we make one decision
      about where to get a PGPROC when we allocate and then put it back on a
      different list at backend-exit time, bad things happen.  This isn't
      just a theoretical risk; we fixed an actual problem of this type in
      commit e280c630.
      6f2871f1
  8. 24 5月, 2015 1 次提交
  9. 04 2月, 2015 1 次提交
    • A
      Move deadlock and other interrupt handling in proc.c out of signal handlers. · 6753333f
      Andres Freund 提交于
      Deadlock checking was performed inside signal handlers up to
      now. While it's a remarkable feat to have made this work reliably,
      it's quite complex to understand why that is the case. Partially it
      worked due to the assumption that semaphores are signal safe - which
      is not actually documented to be the case for sysv semaphores.
      
      The reason we had to rely on performing this work inside signal
      handlers is that semaphores aren't guaranteed to be interruptable by
      signals on all platforms. But now that latches provide a somewhat
      similar API, which actually has the guarantee of being interruptible,
      we can avoid doing so.
      
      Signalling between ProcSleep, ProcWakeup, ProcWaitForSignal and
      ProcSendSignal is now done using latches. This increases the
      likelihood of spurious wakeups. As spurious wakeup already were
      possible and aren't likely to be frequent enough to be an actual
      problem, this seems acceptable.
      
      This change would allow for further simplification of the deadlock
      checking, now that it doesn't have to run in a signal handler. But
      even if I were motivated to do so right now, it would still be better
      to do that separately. Such a cleanup shouldn't have to be reviewed a
      the same time as the more fundamental changes in this commit.
      
      There is one possible usability regression due to this commit. Namely
      it is more likely than before that log_lock_waits messages are output
      more than once.
      
      Reviewed-By: Heikki Linnakangas
      6753333f
  10. 02 2月, 2015 1 次提交
    • H
      Be more careful to not lose sync in the FE/BE protocol. · 2b3a8b20
      Heikki Linnakangas 提交于
      If any error occurred while we were in the middle of reading a protocol
      message from the client, we could lose sync, and incorrectly try to
      interpret a part of another message as a new protocol message. That will
      usually lead to an "invalid frontend message" error that terminates the
      connection. However, this is a security issue because an attacker might
      be able to deliberately cause an error, inject a Query message in what's
      supposed to be just user data, and have the server execute it.
      
      We were quite careful to not have CHECK_FOR_INTERRUPTS() calls or other
      operations that could ereport(ERROR) in the middle of processing a message,
      but a query cancel interrupt or statement timeout could nevertheless cause
      it to happen. Also, the V2 fastpath and COPY handling were not so careful.
      It's very difficult to recover in the V2 COPY protocol, so we will just
      terminate the connection on error. In practice, that's what happened
      previously anyway, as we lost protocol sync.
      
      To fix, add a new variable in pqcomm.c, PqCommReadingMsg, that is set
      whenever we're in the middle of reading a message. When it's set, we cannot
      safely ERROR out and continue running, because we might've read only part
      of a message. PqCommReadingMsg acts somewhat similarly to critical sections
      in that if an error occurs while it's set, the error handler will force the
      connection to be terminated, as if the error was FATAL. It's not
      implemented by promoting ERROR to FATAL in elog.c, like ERROR is promoted
      to PANIC in critical sections, because we want to be able to use
      PG_TRY/CATCH to recover and regain protocol sync. pq_getmessage() takes
      advantage of that to prevent an OOM error from terminating the connection.
      
      To prevent unnecessary connection terminations, add a holdoff mechanism
      similar to HOLD/RESUME_INTERRUPTS() that can be used hold off query cancel
      interrupts, but still allow die interrupts. The rules on which interrupts
      are processed when are now a bit more complicated, so refactor
      ProcessInterrupts() and the calls to it in signal handlers so that the
      signal handlers always call it if ImmediateInterruptOK is set, and
      ProcessInterrupts() can decide to not do anything if the other conditions
      are not met.
      
      Reported by Emil Lenngren. Patch reviewed by Noah Misch and Andres Freund.
      Backpatch to all supported versions.
      
      Security: CVE-2015-0244
      2b3a8b20
  11. 15 1月, 2015 1 次提交
    • A
      Add a default local latch for use in signal handlers. · 59f71a0d
      Andres Freund 提交于
      To do so, move InitializeLatchSupport() into the new common process
      initialization functions, and add a new global variable MyLatch.
      
      MyLatch is usable as soon InitPostmasterChild() has been called
      (i.e. very early during startup). Initially it points to a process
      local latch that exists in all processes. InitProcess/InitAuxiliaryProcess
      then replaces that local latch with PGPROC->procLatch. During shutdown
      the reverse happens.
      
      This is primarily advantageous for two reasons: For one it simplifies
      dealing with the shared process latch, especially in signal handlers,
      because instead of having to check for MyProc, MyLatch can be used
      unconditionally. For another, a later patch that makes FEs/BE
      communication use latches, now can rely on the existence of a latch,
      even before having gone through InitProcess.
      
      Discussion: 20140927191243.GD5423@alap3.anarazel.de
      59f71a0d
  12. 07 1月, 2015 1 次提交
  13. 26 12月, 2014 1 次提交
    • A
      Convert the PGPROC->lwWaitLink list into a dlist instead of open coding it. · 7882c3b0
      Andres Freund 提交于
      Besides being shorter and much easier to read it changes the logic in
      LWLockRelease() to release all shared lockers when waking up any. This
      can yield some significant performance improvements - and the fairness
      isn't really much worse than before, as we always allowed new shared
      lockers to jump the queue.
      7882c3b0
  14. 30 6月, 2014 1 次提交
    • H
      Fix and enhance the assertion of no palloc's in a critical section. · 1c6821be
      Heikki Linnakangas 提交于
      The assertion failed if WAL_DEBUG or LWLOCK_STATS was enabled; fix that by
      using separate memory contexts for the allocations made within those code
      blocks.
      
      This patch introduces a mechanism for marking any memory context as allowed
      in a critical section. Previously ErrorContext was exempt as a special case.
      
      Instead of a blanket exception of the checkpointer process, only exempt the
      memory context used for the pending ops hash table.
      1c6821be
  15. 20 6月, 2014 1 次提交
    • A
      Don't allow to disable backend assertions via the debug_assertions GUC. · 3bdcf6a5
      Andres Freund 提交于
      The existance of the assert_enabled variable (backing the
      debug_assertions GUC) reduced the amount of knowledge some static code
      checkers (like coverity and various compilers) could infer from the
      existance of the assertion. That could have been solved by optionally
      removing the assertion_enabled variable from the Assert() et al macros
      at compile time when some special macro is defined, but the resulting
      complication doesn't seem to be worth the gain from having
      debug_assertions. Recompiling is fast enough.
      
      The debug_assertions GUC is still available, but readonly, as it's
      useful when diagnosing problems. The commandline/client startup option
      -A, which previously also allowed to enable/disable assertions, has
      been removed as it doesn't serve a purpose anymore.
      
      While at it, reduce code duplication in bufmgr.c and localbuf.c
      assertions checking for spurious buffer pins. That code had to be
      reindented anyway to cope with the assert_enabled removal.
      3bdcf6a5
  16. 07 5月, 2014 1 次提交
    • B
      pgindent run for 9.4 · 0a783200
      Bruce Momjian 提交于
      This includes removing tabs after periods in C comments, which was
      applied to back branches, so this change should not effect backpatching.
      0a783200
  17. 13 3月, 2014 1 次提交
  18. 04 3月, 2014 1 次提交
    • R
      Introduce logical decoding. · b89e1510
      Robert Haas 提交于
      This feature, building on previous commits, allows the write-ahead log
      stream to be decoded into a series of logical changes; that is,
      inserts, updates, and deletes and the transactions which contain them.
      It is capable of handling decoding even across changes to the schema
      of the effected tables.  The output format is controlled by a
      so-called "output plugin"; an example is included.  To make use of
      this in a real replication system, the output plugin will need to be
      modified to produce output in the format appropriate to that system,
      and to perform filtering.
      
      Currently, information can be extracted from the logical decoding
      system only via SQL; future commits will add the ability to stream
      changes via walsender.
      
      Andres Freund, with review and other contributions from many other
      people, including Álvaro Herrera, Abhijit Menon-Sen, Peter Gheogegan,
      Kevin Grittner, Robert Haas, Heikki Linnakangas, Fujii Masao, Abhijit
      Menon-Sen, Michael Paquier, Simon Riggs, Craig Ringer, and Steve
      Singer.
      b89e1510
  19. 02 3月, 2014 1 次提交
    • S
      Various Coverity-spotted fixes · b1aebbb6
      Stephen Frost 提交于
      A number of issues were identified by the Coverity scanner and are
      addressed in this patch.  None of these appear to be security issues
      and many are mostly cosmetic changes.
      
      Short comments for each of the changes follows.
      
      Correct the semi-colon placement in be-secure.c regarding SSL retries.
      Remove a useless comparison-to-NULL in proc.c (value is dereferenced
        prior to this check and therefore can't be NULL).
      Add checking of chmod() return values to initdb.
      Fix a couple minor memory leaks in initdb.
      Fix memory leak in pg_ctl- involves free'ing the config file contents.
      Use an int to capture fgetc() return instead of an enum in pg_dump.
      Fix minor memory leaks in pg_dump.
        (note minor change to convertOperatorReference()'s API)
      Check fclose()/remove() return codes in psql.
      Check fstat(), find_my_exec() return codes in psql.
      Various ECPG memory leak fixes.
      Check find_my_exec() return in ECPG.
      Explicitly ignore pqFlush return in libpq error-path.
      Change PQfnumber() to avoid doing an strdup() when no changes required.
      Remove a few useless check-against-NULL's (value deref'd beforehand).
      Check rmtree(), malloc() results in pg_regress.
      Also check get_alternative_expectfile() return in pg_regress.
      b1aebbb6
  20. 01 2月, 2014 2 次提交
    • R
      Introduce replication slots. · 858ec118
      Robert Haas 提交于
      Replication slots are a crash-safe data structure which can be created
      on either a master or a standby to prevent premature removal of
      write-ahead log segments needed by a standby, as well as (with
      hot_standby_feedback=on) pruning of tuples whose removal would cause
      replication conflicts.  Slots have some advantages over existing
      techniques, as explained in the documentation.
      
      In a few places, we refer to the type of replication slots introduced
      by this patch as "physical" slots, because forthcoming patches for
      logical decoding will also have slots, but with somewhat different
      properties.
      
      Andres Freund and Robert Haas
      858ec118
    • R
      Clear MyProc and MyProcSignalState before they become invalid. · d1981719
      Robert Haas 提交于
      Evidence from buildfarm member crake suggests that the new test_shm_mq
      module is routinely crashing the server due to the arrival of a SIGUSR1
      after the shared memory segment has been unmapped.  Although processes
      using the new dynamic background worker facilities are more likely to
      receive a SIGUSR1 around this time, the problem is also possible on older
      branches, so I'm back-patching the parts of this change that apply to
      older branches as far as they apply.
      
      It's already generally the case that code checks whether these pointers
      are NULL before deferencing them, so the important thing is mostly to
      make sure that they do get set to NULL before they become invalid.  But
      in master, there's one case in procsignal_sigusr1_handler that lacks a
      NULL guard, so add that.
      
      Patch by me; review by Tom Lane.
      d1981719
  21. 28 1月, 2014 1 次提交
    • R
      Relax the requirement that all lwlocks be stored in a single array. · ea9df812
      Robert Haas 提交于
      This makes it possible to store lwlocks as part of some other data
      structure in the main shared memory segment, or in a dynamic shared
      memory segment.  There is still a main LWLock array and this patch does
      not move anything out of it, but it provides necessary infrastructure
      for doing that in the future.
      
      This change is likely to increase the size of LWLockPadded on some
      platforms, especially 32-bit platforms where it was previously only
      16 bytes.
      
      Patch by me.  Review by Andres Freund and KaiGai Kohei.
      ea9df812
  22. 08 1月, 2014 1 次提交
  23. 30 11月, 2013 1 次提交
    • T
      Fix assorted race conditions in the new timeout infrastructure. · 16e1b7a1
      Tom Lane 提交于
      Prevent handle_sig_alarm from losing control partway through due to a query
      cancel (either an asynchronous SIGINT, or a cancel triggered by one of the
      timeout handler functions).  That would at least result in failure to
      schedule any required future interrupt, and might result in actual
      corruption of timeout.c's data structures, if the interrupt happened while
      we were updating those.
      
      We could still lose control if an asynchronous SIGINT arrives just as the
      function is entered.  This wouldn't break any data structures, but it would
      have the same effect as if the SIGALRM interrupt had been silently lost:
      we'd not fire any currently-due handlers, nor schedule any new interrupt.
      To forestall that scenario, forcibly reschedule any pending timer interrupt
      during AbortTransaction and AbortSubTransaction.  We can avoid any extra
      kernel call in most cases by not doing that until we've allowed
      LockErrorCleanup to kill the DEADLOCK_TIMEOUT and LOCK_TIMEOUT events.
      
      Another hazard is that some platforms (at least Linux and *BSD) block a
      signal before calling its handler and then unblock it on return.  When we
      longjmp out of the handler, the unblock doesn't happen, and the signal is
      left blocked indefinitely.  Again, we can fix that by forcibly unblocking
      signals during AbortTransaction and AbortSubTransaction.
      
      These latter two problems do not manifest when the longjmp reaches
      postgres.c, because the error recovery code there kills all pending timeout
      events anyway, and it uses sigsetjmp(..., 1) so that the appropriate signal
      mask is restored.  So errors thrown outside any transaction should be OK
      already, and cleaning up in AbortTransaction and AbortSubTransaction should
      be enough to fix these issues.  (We're assuming that any code that catches
      a query cancel error and doesn't re-throw it will do at least a
      subtransaction abort to clean up; but that was pretty much required already
      by other subsystems.)
      
      Lastly, ProcSleep should not clear the LOCK_TIMEOUT indicator flag when
      disabling that event: if a lock timeout interrupt happened after the lock
      was granted, the ensuing query cancel is still going to happen at the next
      CHECK_FOR_INTERRUPTS, and we want to report it as a lock timeout not a user
      cancel.
      
      Per reports from Dan Wood.
      
      Back-patch to 9.3 where the new timeout handling infrastructure was
      introduced.  We may at some point decide to back-patch the signal
      unblocking changes further, but I'll desist from that until we hear
      actual field complaints about it.
      16e1b7a1
  24. 17 9月, 2013 1 次提交
  25. 04 7月, 2013 1 次提交
    • R
      Add new GUC, max_worker_processes, limiting number of bgworkers. · 6bc8ef0b
      Robert Haas 提交于
      In 9.3, there's no particular limit on the number of bgworkers;
      instead, we just count up the number that are actually registered,
      and use that to set MaxBackends.  However, that approach causes
      problems for Hot Standby, which needs both MaxBackends and the
      size of the lock table to be the same on the standby as on the
      master, yet it may not be desirable to run the same bgworkers in
      both places.  9.3 handles that by failing to notice the problem,
      which will probably work fine in nearly all cases anyway, but is
      not theoretically sound.
      
      A further problem with simply counting the number of registered
      workers is that new workers can't be registered without a
      postmaster restart.  This is inconvenient for administrators,
      since bouncing the postmaster causes an interruption of service.
      Moreover, there are a number of applications for background
      processes where, by necessity, the background process must be
      started on the fly (e.g. parallel query).  While this patch
      doesn't actually make it possible to register new background
      workers after startup time, it's a necessary prerequisite.
      
      Patch by me.  Review by Michael Paquier.
      6bc8ef0b
  26. 30 5月, 2013 1 次提交
  27. 17 3月, 2013 1 次提交
    • T
      Add lock_timeout configuration parameter. · d43837d0
      Tom Lane 提交于
      This GUC allows limiting the time spent waiting to acquire any one
      heavyweight lock.
      
      In support of this, improve the recently-added timeout infrastructure
      to permit efficiently enabling or disabling multiple timeouts at once.
      That reduces the performance hit from turning on lock_timeout, though
      it's still not zero.
      
      Zoltán Böszörményi, reviewed by Tom Lane,
      Stephen Frost, and Hari Babu
      d43837d0
  28. 02 1月, 2013 1 次提交
  29. 07 12月, 2012 1 次提交
    • A
      Background worker processes · da07a1e8
      Alvaro Herrera 提交于
      Background workers are postmaster subprocesses that run arbitrary
      user-specified code.  They can request shared memory access as well as
      backend database connections; or they can just use plain libpq frontend
      database connections.
      
      Modules listed in shared_preload_libraries can register background
      workers in their _PG_init() function; this is early enough that it's not
      necessary to provide an extra GUC option, because the necessary extra
      resources can be allocated early on.  Modules can install more than one
      bgworker, if necessary.
      
      Care is taken that these extra processes do not interfere with other
      postmaster tasks: only one such process is started on each ServerLoop
      iteration.  This means a large number of them could be waiting to be
      started up and postmaster is still able to quickly service external
      connection requests.  Also, shutdown sequence should not be impacted by
      a worker process that's reasonably well behaved (i.e. promptly responds
      to termination signals.)
      
      The current implementation lets worker processes specify their start
      time, i.e. at what point in the server startup process they are to be
      started: right after postmaster start (in which case they mustn't ask
      for shared memory access), when consistent state has been reached
      (useful during recovery in a HOT standby server), or when recovery has
      terminated (i.e. when normal backends are allowed).
      
      In case of a bgworker crash, actions to take depend on registration
      data: if shared memory was requested, then all other connections are
      taken down (as well as other bgworkers), just like it were a regular
      backend crashing.  The bgworker itself is restarted, too, within a
      configurable timeframe (which can be configured to be never).
      
      More features to add to this framework can be imagined without much
      effort, and have been discussed, but this seems good enough as a useful
      unit already.
      
      An elementary sample module is supplied.
      
      Author: Álvaro Herrera
      
      This patch is loosely based on prior patches submitted by KaiGai Kohei,
      and unsubmitted code by Simon Riggs.
      
      Reviewed by: KaiGai Kohei, Markus Wanner, Andres Freund,
      Heikki Linnakangas, Simon Riggs, Amit Kapila
      da07a1e8
  30. 03 12月, 2012 1 次提交
    • S
      Refactor inCommit flag into generic delayChkpt flag. · f21bb9cf
      Simon Riggs 提交于
      Rename PGXACT->inCommit flag into delayChkpt flag,
      and generalise comments to allow use in other situations,
      such as the forthcoming potential use in checksum patch.
      Replace wait loop to look for VXIDs with delayChkpt set.
      No user visible changes, not behaviour changes at present.
      
      Simon Riggs, reviewed and rebased by Jeff Davis
      f21bb9cf
  31. 30 11月, 2012 1 次提交
  32. 15 10月, 2012 1 次提交
    • T
      Split up process latch initialization for more-fail-soft behavior. · e81e8f93
      Tom Lane 提交于
      In the previous coding, new backend processes would attempt to create their
      self-pipe during the OwnLatch call in InitProcess.  However, pipe creation
      could fail if the kernel is short of resources; and the system does not
      recover gracefully from a FATAL error right there, since we have armed the
      dead-man switch for this process and not yet set up the on_shmem_exit
      callback that would disarm it.  The postmaster then forces an unnecessary
      database-wide crash and restart, as reported by Sean Chittenden.
      
      There are various ways we could rearrange the code to fix this, but the
      simplest and sanest seems to be to split out creation of the self-pipe into
      a new function InitializeLatchSupport, which must be called from a place
      where failure is allowed.  For most processes that gets called in
      InitProcess or InitAuxiliaryProcess, but processes that don't call either
      but still use latches need their own calls.
      
      Back-patch to 9.1, which has only a part of the latch logic that 9.2 and
      HEAD have, but nonetheless includes this bug.
      e81e8f93
  33. 31 8月, 2012 1 次提交
  34. 26 7月, 2012 1 次提交
    • R
      Log a better message when canceling autovacuum. · d7318d43
      Robert Haas 提交于
      The old message was at DEBUG2, so typically it didn't show up in the
      log at all.  As a result, in most cases where autovacuum was canceled,
      the only information that was logged was the table being vacuumed,
      with no indication as to what problem caused the cancel.  Crank up
      the level to LOG and add some more details to assist with debugging.
      
      Back-patch all the way, per discussion on pgsql-hackers.
      d7318d43
  35. 17 7月, 2012 1 次提交
    • A
      Introduce timeout handling framework · f34c68f0
      Alvaro Herrera 提交于
      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
  36. 25 6月, 2012 1 次提交
    • H
      Replace XLogRecPtr struct with a 64-bit integer. · 0ab9d1c4
      Heikki Linnakangas 提交于
      This simplifies code that needs to do arithmetic on XLogRecPtrs.
      
      To avoid changing on-disk format of data pages, the LSN on data pages is
      still stored in the old format. That should keep pg_upgrade happy. However,
      we have XLogRecPtrs embedded in the control file, and in the structs that
      are sent over the replication protocol, so this changes breaks compatibility
      of pg_basebackup and server. I didn't do anything about this in this patch,
      per discussion on -hackers, the right thing to do would to be to change the
      replication protocol to be architecture-independent, so that you could use
      a newer version of pg_receivexlog, for example, against an older server
      version.
      0ab9d1c4
  37. 11 6月, 2012 1 次提交
  38. 14 5月, 2012 1 次提交
    • H
      Update comments that became out-of-date with the PGXACT struct. · 9e4637bf
      Heikki Linnakangas 提交于
      When the "hot" members of PGPROC were split off to separate PGXACT structs,
      many PGPROC fields referred to in comments were moved to PGXACT, but the
      comments were neglected in the commit. Mostly this is just a search/replace
      of PGPROC with PGXACT, but the way the dummy PGPROC entries are created for
      prepared transactions changed more, making some of the comments totally
      bogus.
      
      Noah Misch
      9e4637bf