mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Restructure subtransaction handling to reduce resource consumption,
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.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.19 2004/08/29 05:06:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.20 2004/09/16 16:58:39 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -42,9 +42,9 @@ extern void register_on_commit_action(Oid relid, OnCommitAction action);
|
||||
extern void remove_on_commit_action(Oid relid);
|
||||
|
||||
extern void PreCommit_on_commit_actions(void);
|
||||
extern void AtEOXact_on_commit_actions(bool isCommit, TransactionId xid);
|
||||
extern void AtEOXact_on_commit_actions(bool isCommit);
|
||||
extern void AtEOSubXact_on_commit_actions(bool isCommit,
|
||||
TransactionId childXid,
|
||||
TransactionId parentXid);
|
||||
SubTransactionId mySubid,
|
||||
SubTransactionId parentSubid);
|
||||
|
||||
#endif /* TABLECMDS_H */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Commands for manipulating users and groups.
|
||||
*
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/commands/user.h,v 1.24 2004/08/29 05:06:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/commands/user.h,v 1.25 2004/09/16 16:58:39 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,7 +32,8 @@ extern void RenameGroup(const char *oldname, const char *newname);
|
||||
extern Datum update_pg_pwd_and_pg_group(PG_FUNCTION_ARGS);
|
||||
|
||||
extern void AtEOXact_UpdatePasswordFile(bool isCommit);
|
||||
extern void AtEOSubXact_UpdatePasswordFile(bool isCommit, TransactionId myXid,
|
||||
TransactionId parentXid);
|
||||
extern void AtEOSubXact_UpdatePasswordFile(bool isCommit,
|
||||
SubTransactionId mySubid,
|
||||
SubTransactionId parentSubid);
|
||||
|
||||
#endif /* USER_H */
|
||||
|
||||
Reference in New Issue
Block a user