summaryrefslogtreecommitdiff
path: root/src/backend/commands/async.c
AgeCommit message (Collapse)Author
2013-02-13Fix bogus when-to-deregister-from-listener-array logic.Tom Lane
Since a backend adds itself to the global listener array during Exec_ListenPreCommit, it's inappropriate for it to remove itself during Exec_UnlistenCommit or Exec_UnlistenAllCommit --- that leads to failure when committing a transaction that did UNLISTEN then LISTEN, since we end up not registered though we should be. (This leads to missing later notifications, or to Assert failures in assert-enabled builds.) Instead deal with deregistering at the bottom of AtCommit_Notify, when we know the final state of the listenChannels list. Also, simplify the representation of registration status by replacing the transient backendHasExecutedInitialListen flag with an amRegisteredListener flag. Per report from Greg Sabino Mullane. Back-patch to 9.0, where the problem was introduced during the LISTEN/NOTIFY rewrite.
2013-01-01Update copyrights for 2013Bruce Momjian
Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
2012-06-29Fix NOTIFY to cope with I/O problems, such as out-of-disk-space.Tom Lane
The LISTEN/NOTIFY subsystem got confused if SimpleLruZeroPage failed, which would typically happen as a result of a write() failure while attempting to dump a dirty pg_notify page out of memory. Subsequently, all attempts to send more NOTIFY messages would fail with messages like "Could not read from file "pg_notify/nnnn" at offset nnnnn: Success". Only restarting the server would clear this condition. Per reports from Kevin Grittner and Christoph Berg. Back-patch to 9.0, where the problem was introduced during the LISTEN/NOTIFY rewrite.
2012-02-24Add some enumeration commas, for consistencyPeter Eisentraut
2012-01-01Update copyright notices for year 2012.Bruce Momjian
2011-10-04Use callbacks in SlruScanDirectory for the actual actionAlvaro Herrera
Previously, the code assumed that the only possible action to take was to delete files behind a certain cutoff point. The async notify code was already a crock: it used a different "pagePrecedes" function for truncation than for regular operation. By allowing it to pass a callback to SlruScanDirectory it can do cleanly exactly what it needs to do. The clog.c code also had its own use for SlruScanDirectory, which is made a bit simpler with this.
2011-09-09Move Timestamp/Interval typedefs and basic macros into datatype/timestamp.h.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.
2011-05-27Preserve caller's memory context in ProcessCompletedNotifies().Tom Lane
This is necessary to avoid long-term memory leakage, because the main loop in PostgresMain expects to be executing in MessageContext, and hence is a bit sloppy about freeing stuff that is only needed for the duration of processing the current client message. The known case of an actual leak is when encoding conversion has to be done on the incoming command string, but there might be others. Per report from Per-Olov Esgard. Back-patch to 9.0, where the bug was introduced by the LISTEN/NOTIFY rewrite.
2011-01-01Stamp copyrights for year 2011.Bruce Momjian
2010-12-30Avoid unnecessary public struct declaration in slru.hAlvaro Herrera
Instead, declare a public wrapper of the sole function using it for external callers, so that they don't have to always pass a NULL argument. Author: Kevin Grittner
2010-09-23ProcessIncomingNotify *must* reset notifyInterruptOccurred when called.Tom Lane
This was broken in 9.0 by careless addition of an early-exit path. Bug report and diagnosis by Jeff Davis.
2010-09-20Remove cvs keywords from all files.Magnus Hagander
2010-04-28Modify ShmemInitStruct and ShmemInitHash to throw errors internally,Tom Lane
rather than returning NULL for some-but-not-all failures as they used to. Remove now-redundant tests for NULL from call sites. We had to do something about this because many call sites were failing to check for NULL; and changing it like this seems a lot more useful and mistake-proof than adding checks to the call sites without them.
2010-04-05Improve phrasing of warning message for NOTIFY queue getting too full.Tom Lane
Per gripe from Peter.
2010-02-26pgindent run for 9.0Bruce Momjian
2010-02-20Clean up handling of XactReadOnly and RecoveryInProgress checks.Tom Lane
Add some checks that seem logically necessary, in particular let's make real sure that HS slave sessions cannot create temp tables. (If they did they would think that temp tables belonging to the master's session with the same BackendId were theirs. We *must* not allow myTempNamespace to become set in a slave session.) Change setval() and nextval() so that they are only allowed on temp sequences in a read-only transaction. This seems consistent with what we allow for table modifications in read-only transactions. Since an HS slave can't have a temp sequence, this also provides a nicer cure for the setval PANIC reported by Erik Rijkers. Make the error messages more uniform, and have them mention the specific command being complained of. This seems worth the trifling amount of extra code, since people are likely to see such messages a lot more than before.
2010-02-17Take care to reprocess an uncommitted notify message.Tom Lane
Oversight in my changes to cope with possible errors during message processing; spotted by Joachim Wieland.
2010-02-17Make NOTIFY_PAYLOAD_MAX_LENGTH depend explicitly on BLCKSZ andTom Lane
NAMEDATALEN, so this code doesn't go nuts with smaller than default BLCKSZ or larger than default NAMEDATALEN. The standard value is still exactly 8000.
2010-02-16Replace the pg_listener-based LISTEN/NOTIFY mechanism with an in-memory queue.Tom Lane
In addition, add support for a "payload" string to be passed along with each notify event. This implementation should be significantly more efficient than the old one, and is also more compatible with Hot Standby usage. There is not yet any facility for HS slaves to receive notifications generated on the master, although such a thing is possible in future. Joachim Wieland, reviewed by Jeff Davis; also hacked on by me.
2010-01-02Update copyright for the year 2010.Bruce Momjian
2009-07-31Create a multiplexing structure for signals to Postgres child processes.Tom Lane
This patch gets us out from under the Unix limitation of two user-defined signal types. We already had done something similar for signals directed to the postmaster process; this adds multiplexing for signals directed to backends and auxiliary processes (so long as they're connected to shared memory). As proof of concept, replace the former usage of SIGUSR1 and SIGUSR2 for backends with use of the multiplexing mechanism. There are still some hard-wired definitions of SIGUSR1 and SIGUSR2 for other process types, but getting rid of those doesn't seem interesting at the moment. Fujii Masao
2009-07-21Change pg_listener attribute number constants to match the usual patternPeter Eisentraut
It appears that, for no particularly good reason, pg_listener.h deviates from the usual convention for declaring attribute number constants. Normally, it's #define Anum_{catalog-name}_{column-name} {attribute-number} pg_listener.h, however substitutes a different string that is similar, but not the same as, the column name. This change fixes that. Author: Robert Haas <robertmhaas@gmail.com>
2009-06-118.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian
provided by Andrew.
2009-02-13Fix UNLISTEN to fall out quickly if the current backend has never executedTom Lane
any LISTEN command. This is more important than it used to be because DISCARD ALL invokes UNLISTEN. Connection-pooled applications making heavy use of DISCARD ALL were seeing significant contention for pg_listener, as reported by Matteo Beccati. It seems unlikely that clients using LISTEN would use pooled connections, so this simple tweak seems sufficient, especially since the pg_listener implementation is slated to go away soon anyway. Back-patch to 8.3, where DISCARD ALL was introduced.
2009-01-01Update copyright for 2009.Bruce Momjian
2008-12-09Revert SIGUSR1 multiplexing patch, per Tom's objection.Heikki Linnakangas
2008-12-09Provide support for multiplexing SIGUSR1 signal. The upcoming synchronousHeikki Linnakangas
replication patch needs a signal, but we've already used SIGUSR1 and SIGUSR2 in normal backends. This patch allows reusing SIGUSR1 for that, and for other purposes too if the need arises.
2008-11-02Remove all uses of the deprecated functions heap_formtuple, heap_modifytuple,Tom Lane
and heap_deformtuple in favor of the newer functions heap_form_tuple et al (which do the same things but use bool control flags instead of arbitrary char values). Eliminate the former duplicate coding of these functions, reducing the deprecated functions to mere wrappers around the newer ones. We can't get rid of them entirely because add-on modules probably still contain many instances of the old coding style. Kris Jurka
2008-08-30Fix the raw-parsetree representation of star (as in SELECT * FROM orTom Lane
SELECT foo.*) so that it cannot be confused with a quoted identifier "*". Instead create a separate node type A_Star to represent this notation. Per pgsql-hackers discussion of 2007-Sep-27.
2008-03-26Move the HTSU_Result enum definition into snapshot.h, to avoid includingAlvaro Herrera
tqual.h into heapam.h. This makes all inclusion of tqual.h explicit. I also sorted alphabetically the includes on some source files.
2008-03-12Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponingTom Lane
pg_listener modifications commanded by LISTEN and UNLISTEN until the end of the current transaction. This allows us to hold the ExclusiveLock on pg_listener until after commit, with no greater risk of deadlock than there was before. Aside from fixing the race condition, this gets rid of a truly ugly kludge that was there before, namely having to ignore HeapTupleBeingUpdated failures during NOTIFY. There is a small potential incompatibility, which is that if a transaction issues LISTEN or UNLISTEN and then looks into pg_listener before committing, it won't see any resulting row insertion or deletion, where before it would have. It seems unlikely that anyone would be depending on that, though. This patch also disallows LISTEN and UNLISTEN inside a prepared transaction. That case had some pretty undesirable properties already, such as possibly allowing pg_listener entries to be made for PIDs no longer present, so disallowing it seems like a better idea than trying to maintain the behavior.
2008-01-01Update copyrights in source tree to 2008.Bruce Momjian
2007-11-30Avoid incrementing the CommandCounter when CommandCounterIncrement is calledTom Lane
but no database changes have been made since the last CommandCounterIncrement. This should result in a significant improvement in the number of "commands" that can typically be performed within a transaction before hitting the 2^32 CommandId size limit. In particular this buys back (and more) the possible adverse consequences of my previous patch to fix plan caching behavior. The implementation requires tracking whether the current CommandCounter value has been "used" to mark any tuples. CommandCounter values stored into snapshots are presumed not to be used for this purpose. This requires some small executor changes, since the executor used to conflate the curcid of the snapshot it was using with the command ID to mark output tuples with. Separating these concepts allows some small simplifications in executor APIs. Something for the TODO list: look into having CommandCounterIncrement not do AcceptInvalidationMessages. It seems fairly bogus to be doing it there, but exactly where to do it instead isn't clear, and I'm disinclined to mess with asynchronous behavior during late beta.
2007-04-12RESET SESSION, plus related new DDL commands. Patch from Marko Kreen,Neil Conway
reviewed by Neil Conway. This patch adds the following DDL command variants: RESET SESSION, RESET TEMP, RESET PLANS, CLOSE ALL, and DEALLOCATE ALL. RESET SESSION is intended for use by connection pool software and the like, in order to reset a client session to something close to its initial state. Note that while most of these command variants can be executed inside a transaction block (but are not transaction-aware!), RESET SESSION cannot. While this is inconsistent, it is intended to catch programmer mistakes: RESET SESSION in an open transaction block is probably unintended.
2007-01-05Update CVS HEAD for 2007 copyright. Back branches are typically notBruce Momjian
back-stamped for this.
2006-07-14Remove 576 references of include files that were not needed.Bruce Momjian
2006-07-13Allow include files to compile own their own.Bruce Momjian
Strip unused include files out unused include files, and add needed includes to C files. The next step is to remove unused include files in C files.
2006-06-27Add GUC update_process_title to control whether 'ps' display is updatedBruce Momjian
for every command, default to on.
2006-04-25Back out RESET CONNECTION until there is more discussion.Bruce Momjian
2006-04-25Add RESET CONNECTION, to reset all aspects of a session.Bruce Momjian
Hans-J?rgen Sch?nig
2006-03-05Update copyright for 2006. Update scripts.Bruce Momjian
2005-11-22Re-run pgindent, fixing a problem where comment lines after a blankBruce Momjian
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-03Rename the members of CommandDest enum so they don't collide with other uses ofAlvaro Herrera
those names. (Debug and None were pretty bad names anyway.) I hope I catched all uses of the names in comments too.
2005-10-15Standard pgindent run for 8.1.Bruce Momjian
2005-10-06Minor API cleanup for async notifications: we can only register theNeil Conway
current backend in pg_listener, so there is little point in making the PID to register part of async.c's public API. Other minor tweaks.
2005-08-20Repair problems with VACUUM destroying t_ctid chains too soon, and withTom Lane
insufficient paranoia in code that follows t_ctid links. (We must do both because even with VACUUM doing it properly, the intermediate state with a dangling t_ctid link is visible concurrently during lazy VACUUM, and could be seen afterwards if either type of VACUUM crashes partway through.) Also try to improve documentation about what's going on. Patch is a bit bulky because passing the XMAX information around required changing the APIs of some low-level heapam.c routines, but it's not conceptually very complicated. Per trouble report from Teodor and subsequent analysis. This needs to be back-patched, but I'll do that after 8.1 beta is out.
2005-06-17Two-phase commit. Original patch by Heikki Linnakangas, with additionalTom Lane
hacking by Alvaro Herrera and Tom Lane.
2005-05-06For some reason access/tupmacs.h has been #including utils/memutils.h,Tom Lane
which is neither needed by nor related to that header. Remove the bogus inclusion and instead include the header in those C files that actually need it. Also fix unnecessary inclusions and bad inclusion order in tsearch2 files.
2005-04-14Completion of project to use fixed OIDs for all system catalogs andTom Lane
indexes. Replace all heap_openr and index_openr calls by heap_open and index_open. Remove runtime lookups of catalog OID numbers in various places. Remove relcache's support for looking up system catalogs by name. Bulky but mostly very boring patch ...
2005-03-20Change the return value of HeapTupleSatisfiesUpdate() to be an enum,Neil Conway
rather than an integer, and fix the associated fallout. From Alvaro Herrera.