Hackers, I attach a updated nested transactions patch. Hopefully the list server will actually distribute it this time. I'd really like to get some testing and comment. Does this actually work on the scenarios where those of you who would be using it expect it to work?
In this patch, relcache and catcache reference counting is handled as previously discussed on pgsql-hackers: each item carries a stack onto which the current refcount is pushed when a subtransaction starts, and it is restored if the subtransaction aborts. This is a "first cut" and probably there some bug in the logic, but the basic cases work. Also, Locks are released on subtrans abort based on the list of committed child transactions, rather than relabeling at subtrans commit; I suspect it's cheaper as we don't have to rehash the lock with the new tag. Main transaction commit and abort are logged with a list of committed subtransactions. At recovery, those are marked committed or aborted. I added some logic to the pg_subtrans code so that a subcommitted transaction whose parent is either committed or aborted (recursively) is marked as committed/aborted if its Xid is lesser than a cutoff point. The cutoff is taken from the xmin calculated at GetSnapshotData, so by the time pg_clog is modified, no transaction is running which should see them as in-progress. Please comment on this, as the idea is new. The change is done in TransactionIdDidCommit() and TransactionIdDidAbort() (and so the SubtransCutoffXid is kept in transam.c, which may seem strange but it's actually the only place where it can be). What's missing: - deferred trigger handling - Tom mentioned buffer manager state reversing. I haven't investigated this yet. - check that relcache and catcache code is correct. I'm almost sure there's a bug. Hopefully not much else. -- Alvaro Herrera (<alvherre[a]dcc.uchile.cl>) Tulio: oh, para qué servirá este boton, Juan Carlos? Policarpo: No, aléjense, no toquen la consola! Juan Carlos: Lo apretaré una y otra vez.
Description: Binary data
/* * subtrans.h * * PostgreSQL subtrans-log manager * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * $PostgreSQL$ */ #ifndef SUBTRANS_H #define SUBTRANS_H #include "access/xlog.h" /* exported because lwlock.c needs it */ #define NUM_SUBTRANS_BUFFERS 8 extern void SubTransSetParent(TransactionId xid, TransactionId parent); extern TransactionId SubTransGetParent(TransactionId xid); extern TransactionId SubTransGetTopmostTransaction(TransactionId xid); extern bool SubTransXidsHaveCommonAncestor(TransactionId xid1, TransactionId xid2); extern int SUBTRANSShmemSize(void); extern void SUBTRANSShmemInit(void); extern void BootStrapSUBTRANS(void); extern void StartupSUBTRANS(void); extern void ShutdownSUBTRANS(void); extern void CheckPointSUBTRANS(void); extern void ExtendSUBTRANS(TransactionId newestXact); extern void TruncateSUBTRANS(TransactionId oldestXact); #endif /* SUBTRANS_H */
Description: Binary data
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match