Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
afa5586b
Commit
afa5586b
authored
10 years ago
by
Roman Tsisyk
Browse files
Options
Downloads
Patches
Plain Diff
Allocate transaction on_stop trigger with struct txn
Fix potential bug multiple parallel transactions
parent
83b27cd7
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/box/txn.cc
+11
-9
11 additions, 9 deletions
src/box/txn.cc
src/box/txn.h
+2
-0
2 additions, 0 deletions
src/box/txn.h
with
13 additions
and
9 deletions
src/box/txn.cc
+
11
−
9
View file @
afa5586b
...
...
@@ -54,16 +54,12 @@ txn_add_redo(struct txn_stmt *stmt, struct request *request)
stmt
->
row
=
row
;
}
extern
"C"
void
static
void
txn_on_yield
(
struct
trigger
*
/* trigger */
,
void
*
/* event */
)
{
txn_rollback
();
/* doesn't throw */
}
struct
trigger
on_yield
=
{
rlist_nil
,
txn_on_yield
,
NULL
,
NULL
};
void
txn_replace
(
struct
txn
*
txn
,
struct
space
*
space
,
struct
tuple
*
old_tuple
,
struct
tuple
*
new_tuple
,
...
...
@@ -95,8 +91,10 @@ txn_replace(struct txn *txn, struct space *space,
if
(
txn
->
autocommit
==
false
)
{
if
(
txn
->
n_stmts
==
1
)
{
txn
->
engine
=
engine_id
(
space
->
engine
);
if
(
engine_no_yield
(
txn
->
engine
))
trigger_add
(
&
fiber
()
->
on_yield
,
&
on_yield
);
if
(
engine_no_yield
(
txn
->
engine
))
{
trigger_add
(
&
fiber
()
->
on_yield
,
&
txn
->
fiber_on_yield
);
}
}
else
if
(
txn
->
engine
!=
engine_id
(
space
->
engine
))
tnt_raise
(
ClientError
,
ER_CROSS_ENGINE_TRANSACTION
);
if
(
!
engine_transactional
(
txn
->
engine
))
{
...
...
@@ -137,6 +135,10 @@ txn_begin(bool autocommit)
rlist_create
(
&
txn
->
stmts
);
rlist_create
(
&
txn
->
on_commit
);
rlist_create
(
&
txn
->
on_rollback
);
txn
->
fiber_on_yield
=
{
rlist_nil
,
txn_on_yield
,
NULL
,
NULL
};
txn
->
autocommit
=
autocommit
;
in_txn
()
=
txn
;
return
txn
;
...
...
@@ -171,7 +173,7 @@ txn_commit(struct txn *txn)
assert
(
txn
==
in_txn
());
struct
txn_stmt
*
stmt
;
/* if (!txn->autocommit && txn->n_stmts && engine_no_yield(txn->engine)) */
trigger_clear
(
&
on_yield
);
trigger_clear
(
&
txn
->
fiber_
on_yield
);
rlist_foreach_entry
(
stmt
,
&
txn
->
stmts
,
next
)
{
if
((
!
stmt
->
old_tuple
&&
!
stmt
->
new_tuple
)
||
space_is_temporary
(
stmt
->
space
))
...
...
@@ -252,7 +254,7 @@ txn_rollback()
tuple_ref
(
stmt
->
new_tuple
,
-
1
);
}
/* if (!txn->autocommit && txn->n_stmts && engine_no_yield(txn->engine)) */
trigger_clear
(
&
on_yield
);
trigger_clear
(
&
txn
->
fiber_
on_yield
);
TRASH
(
txn
);
/** Free volatile txn memory. */
fiber_gc
();
...
...
This diff is collapsed.
Click to expand it.
src/box/txn.h
+
2
−
0
View file @
afa5586b
...
...
@@ -69,6 +69,8 @@ struct txn {
bool
autocommit
;
/** Id of the engine involved in multi-statement transaction. */
uint8_t
engine
;
/** Trigger on fiber yield to abort transaction for in-memory engine */
struct
trigger
fiber_on_yield
;
};
/* Pointer to the current transaction (if any) */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment