Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
06aa3e5f
Commit
06aa3e5f
authored
14 years ago
by
Andy Yates
Browse files
Options
Downloads
Patches
Plain Diff
Changing the code and now we issue a begin_work() call and eval the call.
parent
114b97ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Bio/EnsEMBL/Utils/SqlHelper.pm
+20
-16
20 additions, 16 deletions
modules/Bio/EnsEMBL/Utils/SqlHelper.pm
with
20 additions
and
16 deletions
modules/Bio/EnsEMBL/Utils/SqlHelper.pm
+
20
−
16
View file @
06aa3e5f
...
@@ -468,11 +468,13 @@ previous setting. If your DBI/DBD driver does not support manual commits
...
@@ -468,11 +468,13 @@ previous setting. If your DBI/DBD driver does not support manual commits
then this code will break. The code will turn off the
then this code will break. The code will turn off the
C<disconnect_when_idle()> method to allow transactions to work as expected.
C<disconnect_when_idle()> method to allow transactions to work as expected.
If the connection given already had AutoCommit off we will issue a rollback
All connections are issued a C<begin_work()> call on the DBI handle which
before handing the connection into the closure. This ensures the connection
informs the target engine we are starting a transaction. Giving this method
contains as fresh information from the database as possible. An effect of
a connection already in a transaction will cause an error to be raised and
using REPEATABLE READ transaction isolation (InnoDB's default) is that
the abortion of the running transaction.
your data is as fresh as when you started your current transaction. To
An effect of using REPEATABLE READ transaction isolation (InnoDB's default)
is that your data is as fresh as when you started your current transaction. To
ensure the freshest data use C<SELECT ... from ... LOCK IN SHARE MODE>
ensure the freshest data use C<SELECT ... from ... LOCK IN SHARE MODE>
or C<SELECT ... from ... LOCK FOR UPDATE> if you are going to issue
or C<SELECT ... from ... LOCK FOR UPDATE> if you are going to issue
updates.
updates.
...
@@ -496,6 +498,9 @@ sub transaction {
...
@@ -496,6 +498,9 @@ sub transaction {
my
$original_dwi
;
my
$original_dwi
;
my
$ac
;
my
$ac
;
my
$error
;
my
$result
;
#If we were already in a transaction then we do not do any management of the
#If we were already in a transaction then we do not do any management of the
#session & wait for the parent transaction(s) to finish
#session & wait for the parent transaction(s) to finish
my
$perform_transaction
=
$self
->
_perform_transaction_code
();
my
$perform_transaction
=
$self
->
_perform_transaction_code
();
...
@@ -503,19 +508,18 @@ sub transaction {
...
@@ -503,19 +508,18 @@ sub transaction {
$original_dwi
=
$dbc
->
disconnect_when_inactive
();
$original_dwi
=
$dbc
->
disconnect_when_inactive
();
$ac
=
$dbc
->
db_handle
()
->
{'
AutoCommit
'};
$ac
=
$dbc
->
db_handle
()
->
{'
AutoCommit
'};
$dbc
->
db_handle
()
->
{'
AutoCommit
'}
=
0
;
$dbc
->
db_handle
()
->
{'
AutoCommit
'}
=
0
;
#Issue a rollback as a signal for a fresh transaction if AutoCommit was off
eval
{
$dbc
->
db_handle
()
->
begin_work
()
};
$
dbc
->
db_handle
()
->
rollback
()
if
(
!
$ac
)
;
$
error
=
$@
if
$@
;
$self
->
_enable_transaction
();
$self
->
_enable_transaction
()
unless
$error
;
}
}
my
$error
;
if
(
!
$error
)
{
my
$result
;
eval
{
$result
=
$callback
->
(
$dbc
);
eval
{
$dbc
->
db_handle
()
->
commit
()
if
$perform_transaction
;
$result
=
$callback
->
(
$dbc
);
};
$dbc
->
db_handle
()
->
commit
()
if
$perform_transaction
;
$error
=
$@
;
};
}
$error
=
$@
;
if
(
$perform_transaction
)
{
if
(
$perform_transaction
)
{
if
(
$error
)
{
if
(
$error
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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