summaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/lmgr.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove 576 references of include files that were not needed.Bruce Momjian2006-07-141-3/+1
|
* Rethink the locking mechanisms used for CREATE/DROP/RENAME DATABASE.Tom Lane2006-05-041-1/+4
| | | | | | | | | | | | | The former approach used ExclusiveLock on pg_database, which being a cluster-wide lock meant only one of these operations could proceed at a time; worse, it also blocked all incoming connections in ReverifyMyDatabase. Now that we have LockSharedObject(), we can use locks of different types applied to databases considered as objects. This allows much more flexible management of the interlocking: two CREATE DATABASEs need not block each other, and need not block connections except to the template database being used. Similarly DROP DATABASE doesn't block unrelated operations. The locking used in flatfiles.c is also much narrower in scope than before. Per recent proposal.
* Update copyright for 2006. Update scripts.Bruce Momjian2006-03-051-2/+2
|
* Remove logic in XactLockTableWait() that attempted to mark a crashedTom Lane2006-01-131-15/+1
| | | | | | | | | | | | | | transaction as aborted. Since we only call XactLockTableWait on XIDs that we believe to be currently running, the odds of this code ever actually firing are minimal. It's certainly unnecessary, since a transaction that's not either running or committed will be presumed aborted anyway. What's more, it's not hard to imagine scenarios where this could result in corrupting pg_clog: for instance, if a bogus XID somehow got passed to XactLockTableWait. I think the code probably dates from the ancient era when we didn't have TransactionIdIsInProgress; back then it may have been necessary, but now I think it's a waste of cycles and potentially dangerous. Per discussion with Qingqing Zhou and Karsten Hilbert.
* Simplify lock manager data structures by making a clear separation betweenTom Lane2005-12-091-118/+24
| | | | | | | | | | | | the data defining the semantics of a lock method (ie, conflict resolution table and ancillary data, which is all constant) and the hash tables storing the current state. The only thing we give up by this is the ability to use separate hashtables for different lock methods, but there is no need for that anyway. Put some extra fields into the LockMethod definition structs to clean up some other uglinesses, like hard-wired tests for DEFAULT_LOCKMETHOD and USER_LOCKMETHOD. This commit doesn't do anything about the performance issues we were discussing, but it clears away some of the underbrush that's in the way of fixing that.
* Standard pgindent run for 8.1.Bruce Momjian2005-10-151-17/+17
|
* Add NOWAIT option to SELECT FOR UPDATE/SHARE.Tom Lane2005-08-011-1/+60
| | | | | Original patch by Hans-Juergen Schoenig, revisions by Karel Zak and Tom Lane.
* Two-phase commit. Original patch by Heikki Linnakangas, with additionalTom Lane2005-06-171-4/+3
| | | | hacking by Alvaro Herrera and Tom Lane.
* Simplify shared-memory lock data structures as per recent discussion:Tom Lane2005-06-141-38/+39
| | | | | | | | | | | | | | | | it is sufficient to track whether a backend holds a lock or not, and store information about transaction vs. session locks only in the inside-the-backend LocalLockTable. Since there can now be but one PROCLOCK per lock per backend, LockCountMyLocks() is no longer needed, thus eliminating some O(N^2) behavior when a backend holds many locks. Also simplify the LockAcquire/LockRelease API by passing just a 'sessionLock' boolean instead of a transaction ID. The previous API was designed with the idea that per-transaction lock holding would be important for subtransactions, but now that we have subtransactions we know that this is unwanted. While at it, add an 'isTempObject' parameter to LockAcquire to indicate whether the lock is being taken on a temp table. This is not used just yet, but will be needed shortly for two-phase commit.
* Improve LockAcquire API per my recent proposal. All error conditionsTom Lane2005-05-291-39/+44
| | | | | | | | are now reported via elog, eliminating the need to test the result code at most call sites. Make it possible for the caller to distinguish a freshly acquired lock from one already held in the current transaction. Use that capability to avoid redundant AcceptInvalidationMessages() calls in LockRelation().
* Split the shared-memory array of PGPROC pointers out of the sinvalTom Lane2005-05-191-2/+2
| | | | | | communication structure, and make it its own module with its own lock. This should reduce contention at least a little, and it definitely makes the code seem cleaner. Per my recent proposal.
* Use the standard lock manager to establish priority order when thereTom Lane2005-04-301-1/+125
| | | | | | is contention for a tuple-level lock. This solves the problem of a would-be exclusive locker being starved out by an indefinite succession of share-lockers. Per recent discussion with Alvaro.
* Restructure LOCKTAG as per discussions of a couple months ago.Tom Lane2005-04-291-50/+74
| | | | | | | | | | | | | | Essentially, we shoehorn in a lockable-object-type field by taking a byte away from the lockmethodid, which can surely fit in one byte instead of two. This allows less artificial definitions of all the other fields of LOCKTAG; we can get rid of the special pg_xactlock pseudo-relation, and also support locks on individual tuples and general database objects (including shared objects). None of those possibilities are actually exploited just yet, however. I removed pg_xactlock from pg_class, but did not force initdb for that change. At this point, relkind 's' (SPECIAL) is unused and could be removed entirely.
* Tag appropriate files for rc3PostgreSQL Daemon2004-12-311-2/+2
| | | | | | | | Also performed an initial run through of upgrading our Copyright date to extend to 2005 ... first run here was very simple ... change everything where: grep 1996-2004 && the word 'Copyright' ... scanned through the generated list with 'less' first, and after, to make sure that I only picked up the right entries ...
* Restructure subtransaction handling to reduce resource consumption,Tom Lane2004-09-161-17/+45
| | | | | | | | | | | | | | | | | as per recent discussions. Invent SubTransactionIds that are managed like CommandIds (ie, counter is reset at start of each top transaction), and use these instead of TransactionIds to keep track of subtransaction status in those modules that need it. This means that a subtransaction does not need an XID unless it actually inserts/modifies rows in the database. Accordingly, don't assign it an XID nor take a lock on the XID until it tries to do that. This saves a lot of overhead for subtransactions that are only used for error recovery (eg plpgsql exceptions). Also, arrange to release a subtransaction's XID lock as soon as the subtransaction exits, in both the commit and abort cases. This avoids holding many unique locks after a long series of subtransactions. The price is some additional overhead in XactLockTableWait, but that seems acceptable. Finally, restructure the state machine in xact.c to have a more orthogonal set of states for subtransactions.
* Pgindent run for 8.0.Bruce Momjian2004-08-291-3/+3
|
* Update copyright to 2004.Bruce Momjian2004-08-291-2/+2
|
* Tweak code so that pg_subtrans is never consulted for XIDs older thanTom Lane2004-08-221-2/+2
| | | | | | | | | | RecentXmin (== MyProc->xmin). This ensures that it will be safe to truncate pg_subtrans at RecentGlobalXmin, which should largely eliminate any fear of bloat. Along the way, eliminate SubTransXidsHaveCommonAncestor, which isn't really needed and could not give a trustworthy result anyway under the lookback restriction. In an unrelated but nearby change, #ifdef out GetUndoRecPtr, which has been dead code since 2001 and seems unlikely to ever be resurrected.
* Fix subtransaction behavior for large objects, temp namespace, files,Tom Lane2004-07-281-8/+8
| | | | | | | password/group files. Also allow read-only subtransactions of a read-write parent, but not vice versa. These are the reasonably noncontroversial parts of Alvaro's recent mop-up patch, plus further work on large objects to minimize use of the TopTransactionResourceOwner.
* Replace nested-BEGIN syntax for subtransactions with spec-compliantTom Lane2004-07-271-13/+10
| | | | | | | SAVEPOINT/RELEASE/ROLLBACK-TO syntax. (Alvaro) Cause COMMIT of a failed transaction to report ROLLBACK instead of COMMIT in its command tag. (Tom) Fix a few loose ends in the nested-transactions stuff.
* Nested transactions. There is still much left to do, especially on theTom Lane2004-07-011-6/+14
| | | | | | | performance front, but with feature freeze upon us I think it's time to drive a stake in the ground and say that this will be in 7.5. Alvaro Herrera, with some help from Tom Lane.
* Code review for EXEC_BACKEND changes. Reduce the number of #ifdefs byTom Lane2004-05-281-1/+8
| | | | | | | | | | | about a third, make it work on non-Windows platforms again. (But perhaps I broke the WIN32 code, since I have no way to test that.) Fold all the paths that fork postmaster child processes to go through the single routine SubPostmasterMain, which takes care of resurrecting the state that would normally be inherited from the postmaster (including GUC variables). Clean up some places where there's no particularly good reason for the EXEC and non-EXEC cases to work differently. Take care of one or two FIXMEs that remained in the code.
* Try to reduce confusion about what is a lock method identifier, a lockBruce Momjian2003-12-011-15/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | method control structure, or a table of control structures. . Use type LOCKMASK where an int is not a counter. . Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead. . Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because LOCKMETHOD is not a pointer. . Define and use macro LockMethodIsValid. . Rename LOCKMETHOD to LOCKMETHODID. . Remove global variable LongTermTableId in lmgr.c, because it is never used. . Make LockTableId static in lmgr.c, because it is used nowhere else. Why not remove it and use DEFAULT_LOCKMETHOD? . Rename the lock method control structure from LOCKMETHODTABLE to LockMethodData. Introduce a pointer type named LockMethod. . Remove elog(FATAL) after InitLockTable() call in CreateSharedMemoryAndSemaphores(), because if something goes wrong, there is elog(FATAL) in LockMethodTableInit(), and if this doesn't help, an elog(ERROR) in InitLockTable() is promoted to FATAL. . Make InitLockTable() void, because its only caller does not use its return value any more. . Rename variables in lock.c to avoid statements like LockMethodTable[NumLockMethods] = lockMethodTable; lockMethodTable = LockMethodTable[lockmethod]; . Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG. . Remove static variables BITS_OFF and BITS_ON from lock.c, because I agree to this doubt: * XXX is a fetch from a static array really faster than a shift? . Define and use macros LOCKBIT_ON/OFF. Manfred Koizar
* $Header: -> $PostgreSQL Changes ...PostgreSQL Daemon2003-11-291-1/+1
|
* Reimplement hash index locking algorithms, per my recent proposal toTom Lane2003-09-041-2/+22
| | | | | | | | pghackers. This fixes the problem recently reported by Markus KrÌutner (hash bucket split corrupts the state of scans being done concurrently), and I believe it also fixes all the known problems with deadlocks in hash index operations. Hash indexes are still not really ready for prime time (since they aren't WAL-logged), but this is a step forward.
* Clean up locktable init code per recent gripe from Kurt Roeckx.Tom Lane2003-08-171-2/+4
| | | | | No change in behavior, but old code would have failed to detect overrun of MAX_LOCKMODES.
* Update copyrights to 2003.Bruce Momjian2003-08-041-2/+2
|
* Error message editing in backend/storage.Tom Lane2003-07-241-11/+11
|
* Back out LOCKTAG changes by Rod Taylor, pending code review. Sorry.Bruce Momjian2003-02-191-84/+19
|
* - Modifies LOCKTAG to include a 'classId'. Relation receive a classId ofBruce Momjian2003-02-191-19/+84
| | | | | | | | | | | | | | | | | RelOid_pg_class, and transaction locks XactLockTableId. RelId is renamed to objId. - LockObject() and UnlockObject() functions created, and their use sprinkled throughout the code to do descent locking for domains and types. They accept lock modes AccessShare and AccessExclusive, as we only really need a 'read' and 'write' lock at the moment. Most locking cases are held until the end of the transaction. This fixes the cases Tom mentioned earlier in regards to locking with Domains. If the patch is good, I'll work on cleaning up issues with other database objects that have this problem (most of them). Rod Taylor
* * -Remove LockMethodTable.prio field, not used (Bruce)Bruce Momjian2002-08-011-24/+4
|
* Update copyright to 2002.Bruce Momjian2002-06-201-2/+2
|
* pgindent run on all C files. Java run to follow. initdb/regressionBruce Momjian2001-10-251-3/+3
| | | | tests pass.
* Remove useless LockDisable() function and associated overhead, per myTom Lane2001-09-271-48/+24
| | | | proposal of 26-Aug.
* Replace implementation of pg_log as a relation accessed through theTom Lane2001-08-251-2/+2
| | | | | | | | | | | buffer manager with 'pg_clog', a specialized access method modeled on pg_xlog. This simplifies startup (don't need to play games to open pg_log; among other things, OverrideTransactionSystem goes away), should improve performance a little, and opens the door to recycling commit log space by removing no-longer-needed segments of the commit log. Actual recycling is not there yet, but I felt I should commit this part separately since it'd still be useful if we chose not to do transaction ID wraparound.
* Add SHARE UPDATE EXCLUSIVE lock mode, coming soon to a VACUUM near you.Tom Lane2001-07-091-16/+28
| | | | Name chosen per pghackers discussion around 6/22/01.
* Add support to lock manager for conditionally locking a lock (ie,Tom Lane2001-06-221-17/+68
| | | | | return without waiting if we can't get the lock immediately). Not used yet, but will be needed for concurrent VACUUM.
* Clean up some longstanding problems in shared-cache invalidation.Tom Lane2001-06-191-2/+2
| | | | | | | | | | | | SI messages now include the relevant database OID, so that operations in one database do not cause useless cache flushes in backends attached to other databases. Declare SI messages properly using a union, to eliminate the former assumption that Oid is the same size as int or Index. Rewrite the nearly-unreadable code in inval.c, and document it better. Arrange for catcache flushes at end of command/transaction to happen before relcache flushes do --- this avoids loading a new tuple into the catcache while setting up new relcache entry, only to have it be flushed again immediately.
* Clean up various to-do items associated with system indexes:Tom Lane2001-06-121-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pg_database now has unique indexes on oid and on datname. pg_shadow now has unique indexes on usename and on usesysid. pg_am now has unique index on oid. pg_opclass now has unique index on oid. pg_amproc now has unique index on amid+amopclaid+amprocnum. Remove pg_rewrite's unnecessary index on oid, delete unused RULEOID syscache. Remove index on pg_listener and associated syscache for performance reasons (caching rows that are certain to change before you need 'em again is rather pointless). Change pg_attrdef's nonunique index on adrelid into a unique index on adrelid+adnum. Fix various incorrect settings of pg_class.relisshared, make that the primary reference point for whether a relation is shared or not. IsSharedSystemRelationName() is now only consulted to initialize relisshared during initial creation of tables and indexes. In theory we might now support shared user relations, though it's not clear how one would get entries for them into pg_class &etc of multiple databases. Fix recently reported bug that pg_attribute rows created for an index all have the same OID. (Proof that non-unique OID doesn't matter unless it's actually used to do lookups ;-)) There's no need to treat pg_trigger, pg_attrdef, pg_relcheck as bootstrap relations. Convert them into plain system catalogs without hardwired entries in pg_class and friends. Unify global.bki and template1.bki into a single init script postgres.bki, since the alleged distinction between them was misleading and pointless. Not to mention that it didn't work for setting up indexes on shared system relations. Rationalize locking of pg_shadow, pg_group, pg_attrdef (no need to use AccessExclusiveLock where ExclusiveLock or even RowExclusiveLock will do). Also, hold locks until transaction commit where necessary.
* pgindent run. Make it all clean.Bruce Momjian2001-03-221-2/+3
|
* Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group.Bruce Momjian2001-01-241-2/+2
|
* Revise lock manager to support "session level" locks as well as "transactionTom Lane2000-12-221-17/+64
| | | | | | | | | | | | | | | | level" locks. A session lock is not released at transaction commit (but it is released on transaction abort, to ensure recovery after an elog(ERROR)). In VACUUM, use a session lock to protect the master table while vacuuming a TOAST table, so that the TOAST table can be done in an independent transaction. I also took this opportunity to do some cleanup and renaming in the lock code. The previously noted bug in ProcLockWakeup, that it couldn't wake up any waiters beyond the first non-wakeable waiter, is now fixed. Also found a previously unknown bug of the same kind (failure to scan all members of a lock queue in some cases) in DeadLockCheck. This might have led to failure to detect a deadlock condition, resulting in indefinite waits, but it's difficult to characterize the conditions required to trigger a failure.
* Rearrange bufmgr header files so that buf_internals.h need not beTom Lane2000-11-301-1/+2
| | | | | | | included by everything that includes bufmgr.h --- it's supposed to be internals, after all, not part of the API! This fixes the conflict against FreeBSD headers reported by Rosenman, by making it unnecessary for s_lock.h to be included by plperl.c.
* Mark functions as static and ifdef NOT_USED as appropriate.Bruce Momjian2000-06-081-1/+3
|
* The heralded `Grand Unified Configuration scheme' (GUC)Peter Eisentraut2000-05-311-8/+1
| | | | | | | | | | | | | That means you can now set your options in either or all of $PGDATA/configuration, some postmaster option (--enable-fsync=off), or set a SET command. The list of options is in backend/utils/misc/guc.c, documentation will be written post haste. pg_options is gone, so is that pq_geqo config file. Also removed were backend -K, -Q, and -T options (no longer applicable, although -d0 does the same as -Q). Added to configure an --enable-syslog option. changed all callers from TPRINTF to elog(DEBUG)
* Ye-old pgindent run. Same 4-space tabs.Bruce Momjian2000-04-121-9/+9
|
* Add:Bruce Momjian2000-01-261-2/+3
| | | | | | * Portions Copyright (c) 1996-2000, PostgreSQL, Inc to all files copyright Regents of Berkeley. Man, that's a lot of files.
* lmgr.c didn't check for failure return from LockAcquire(). Boo hiss.Tom Lane1999-11-281-5/+10
|
* Fix problem with temp tables shown in regression test by Jan.Bruce Momjian1999-11-171-2/+2
|
* Mega-commit to make heap_open/heap_openr/heap_close take anTom Lane1999-09-181-66/+16
| | | | | | | | | | | | | | | | | additional argument specifying the kind of lock to acquire/release (or 'NoLock' to do no lock processing). Ensure that all relations are locked with some appropriate lock level before being examined --- this ensures that relevant shared-inval messages have been processed and should prevent problems caused by concurrent VACUUM. Fix several bugs having to do with mismatched increment/decrement of relation ref count and mismatched heap_open/close (which amounts to the same thing). A bogus ref count on a relation doesn't matter much *unless* a SI Inval message happens to arrive at the wrong time, which is probably why we got away with this sloppiness for so long. Repair missing grab of AccessExclusiveLock in DROP TABLE, ALTER/RENAME TABLE, etc, as noted by Hiroshi. Recommend 'make clean all' after pulling this update; I modified the Relation struct layout slightly. Will post further discussion to pghackers list shortly.