mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Partially revoke attempt to improve performance with many savepoints.
Maintain difference between subtransaction release and commit introduced by earlier patch.
This commit is contained in:
parent
dde70cc313
commit
df383b03e6
@ -269,7 +269,7 @@ static TransactionId RecordTransactionAbort(bool isSubXact);
|
|||||||
static void StartTransaction(void);
|
static void StartTransaction(void);
|
||||||
|
|
||||||
static void StartSubTransaction(void);
|
static void StartSubTransaction(void);
|
||||||
static void CommitSubTransaction(bool isTopLevel);
|
static void CommitSubTransaction(void);
|
||||||
static void AbortSubTransaction(void);
|
static void AbortSubTransaction(void);
|
||||||
static void CleanupSubTransaction(void);
|
static void CleanupSubTransaction(void);
|
||||||
static void PushTransaction(void);
|
static void PushTransaction(void);
|
||||||
@ -2578,7 +2578,7 @@ CommitTransactionCommand(void)
|
|||||||
case TBLOCK_SUBRELEASE:
|
case TBLOCK_SUBRELEASE:
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CommitSubTransaction(false);
|
CommitSubTransaction();
|
||||||
s = CurrentTransactionState; /* changed by pop */
|
s = CurrentTransactionState; /* changed by pop */
|
||||||
} while (s->blockState == TBLOCK_SUBRELEASE);
|
} while (s->blockState == TBLOCK_SUBRELEASE);
|
||||||
|
|
||||||
@ -2588,12 +2588,17 @@ CommitTransactionCommand(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* We were issued a COMMIT, so we end the current subtransaction
|
* We were issued a COMMIT, so we end the current subtransaction
|
||||||
* hierarchy and perform final commit.
|
* hierarchy and perform final commit. We do this by rolling up
|
||||||
|
* any subtransactions into their parent, which leads to O(N^2)
|
||||||
|
* operations with respect to resource owners - this isn't that
|
||||||
|
* bad until we approach a thousands of savepoints but is necessary
|
||||||
|
* for correctness should after triggers create new resource
|
||||||
|
* owners.
|
||||||
*/
|
*/
|
||||||
case TBLOCK_SUBCOMMIT:
|
case TBLOCK_SUBCOMMIT:
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CommitSubTransaction(true);
|
CommitSubTransaction();
|
||||||
s = CurrentTransactionState; /* changed by pop */
|
s = CurrentTransactionState; /* changed by pop */
|
||||||
} while (s->blockState == TBLOCK_SUBCOMMIT);
|
} while (s->blockState == TBLOCK_SUBCOMMIT);
|
||||||
/* If we had a COMMIT command, finish off the main xact too */
|
/* If we had a COMMIT command, finish off the main xact too */
|
||||||
@ -3745,7 +3750,7 @@ ReleaseCurrentSubTransaction(void)
|
|||||||
BlockStateAsString(s->blockState));
|
BlockStateAsString(s->blockState));
|
||||||
Assert(s->state == TRANS_INPROGRESS);
|
Assert(s->state == TRANS_INPROGRESS);
|
||||||
MemoryContextSwitchTo(CurTransactionContext);
|
MemoryContextSwitchTo(CurTransactionContext);
|
||||||
CommitSubTransaction(false);
|
CommitSubTransaction();
|
||||||
s = CurrentTransactionState; /* changed by pop */
|
s = CurrentTransactionState; /* changed by pop */
|
||||||
Assert(s->state == TRANS_INPROGRESS);
|
Assert(s->state == TRANS_INPROGRESS);
|
||||||
}
|
}
|
||||||
@ -4009,13 +4014,9 @@ StartSubTransaction(void)
|
|||||||
*
|
*
|
||||||
* The caller has to make sure to always reassign CurrentTransactionState
|
* The caller has to make sure to always reassign CurrentTransactionState
|
||||||
* if it has a local pointer to it after calling this function.
|
* if it has a local pointer to it after calling this function.
|
||||||
*
|
|
||||||
* isTopLevel means that this CommitSubTransaction() is being issued as a
|
|
||||||
* sequence of actions leading directly to a main transaction commit
|
|
||||||
* allowing some actions to be optimised.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
CommitSubTransaction(bool isTopLevel)
|
CommitSubTransaction(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
@ -4069,14 +4070,10 @@ CommitSubTransaction(bool isTopLevel)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Other locks should get transferred to their parent resource owner.
|
* Other locks should get transferred to their parent resource owner.
|
||||||
* Doing that is an O(N^2) operation, so if isTopLevel then we can just
|
|
||||||
* leave the lock records as they are, knowing they will all get released
|
|
||||||
* by the top level commit using ProcReleaseLocks(). We only optimize
|
|
||||||
* this for commit; aborts may need to do other cleanup.
|
|
||||||
*/
|
*/
|
||||||
ResourceOwnerRelease(s->curTransactionOwner,
|
ResourceOwnerRelease(s->curTransactionOwner,
|
||||||
RESOURCE_RELEASE_LOCKS,
|
RESOURCE_RELEASE_LOCKS,
|
||||||
true, isTopLevel);
|
true, false);
|
||||||
ResourceOwnerRelease(s->curTransactionOwner,
|
ResourceOwnerRelease(s->curTransactionOwner,
|
||||||
RESOURCE_RELEASE_AFTER_LOCKS,
|
RESOURCE_RELEASE_AFTER_LOCKS,
|
||||||
true, false);
|
true, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user