Skip to content
Snippets Groups Projects
Commit 494fe087 authored by Georgiy Lebedev's avatar Georgiy Lebedev Committed by Aleksandr Lyapunov
Browse files

box: do not reassign PSN to prepared transactions during rollback

During transaction rollback, we unconditionally assign a PSN to it: we
should do this only when necessary, i.e., a transaction is RW and is not
already prepared.

Needed for #7930

NO_CHANGELOG=refactoring
NO_DOC=refactoring
NO_TEST=refactoring
parent c329e703
No related branches found
No related tags found
No related merge requests found
......@@ -357,6 +357,25 @@ txn_rollback_one_stmt(struct txn *txn, struct txn_stmt *stmt)
}
}
/**
* Assign's a PSN to a RW transaction that wasn't yet prepared.
*/
static void
txn_assign_psn(struct txn *txn)
{
if (txn->psn == 0) {
if (txn->status == TXN_IN_READ_VIEW) {
assert(stailq_empty(&txn->stmts));
} else {
assert(txn->status == TXN_INPROGRESS ||
txn->status == TXN_ABORTED);
txn->psn = ++txn_last_psn;
}
} else {
assert(txn->status == TXN_PREPARED);
}
}
/*
* Begins the rollback to savepoint process by assigning a PSN to the
* transaction (rolled back statements require a PSN).
......@@ -364,7 +383,7 @@ txn_rollback_one_stmt(struct txn *txn, struct txn_stmt *stmt)
static void
txn_rollback_to_svp_begin(struct txn *txn)
{
txn->psn = ++txn_last_psn;
txn_assign_psn(txn);
}
/*
......@@ -374,7 +393,8 @@ txn_rollback_to_svp_begin(struct txn *txn)
static void
txn_rollback_to_svp_finish(struct txn *txn)
{
txn->psn = 0;
if (txn->status != TXN_PREPARED)
txn->psn = 0;
}
static void
......@@ -966,23 +986,16 @@ txn_journal_entry_new(struct txn *txn)
static int
txn_prepare(struct txn *txn)
{
txn->psn = ++txn_last_psn;
if (txn_check_can_continue(txn) != 0)
return -1;
txn_assign_psn(txn);
if (txn->rollback_timer != NULL) {
ev_timer_stop(loop(), txn->rollback_timer);
txn->rollback_timer = NULL;
}
/*
* Somebody else has written some value that we have read.
* The RW transaction is not possible.
*/
if (txn->status == TXN_IN_READ_VIEW)
assert(stailq_empty(&txn->stmts));
/*
* Perform transaction conflict resolution. Engine == NULL when
* we have a bunch of IPROTO_NOP statements.
......@@ -1172,7 +1185,7 @@ txn_rollback(struct txn *txn)
/*
* Rolled back statements require a PSN.
*/
txn->psn = ++txn_last_psn;
txn_assign_psn(txn);
txn->status = TXN_ABORTED;
trigger_clear(&txn->fiber_on_stop);
trigger_clear(&txn->fiber_on_yield);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment