Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
4be8a0fb
Commit
4be8a0fb
authored
Jan 19, 2015
by
Leo Gordon
Browse files
log deadlocks and retries in log_message
parent
bbd03412
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
5 deletions
+34
-5
modules/Bio/EnsEMBL/Hive/DBSQL/DBConnection.pm
modules/Bio/EnsEMBL/Hive/DBSQL/DBConnection.pm
+17
-4
modules/Bio/EnsEMBL/Hive/DBSQL/LogMessageAdaptor.pm
modules/Bio/EnsEMBL/Hive/DBSQL/LogMessageAdaptor.pm
+17
-1
No files found.
modules/Bio/EnsEMBL/Hive/DBSQL/DBConnection.pm
View file @
4be8a0fb
...
...
@@ -116,11 +116,13 @@ sub protected_prepare_execute { # try to resolve certain mysql "Deadlocks" b
my
$self
=
shift
@_
;
my
$sql
=
shift
@_
;
my
$retries
=
3
;
my
$attempts
=
4
;
my
$sleep_secs
=
1
;
my
$log_message_adaptor
;
my
$retval
;
foreach
(
0
..
$retrie
s
)
{
foreach
my
$attempt
(
1
..
$attempt
s
)
{
eval
{
my
$sth
=
$self
->
prepare
(
$sql
);
$retval
=
$sth
->
execute
(
@
_
);
...
...
@@ -128,14 +130,25 @@ sub protected_prepare_execute { # try to resolve certain mysql "Deadlocks" b
1
;
}
or
do
{
if
(
$@
=~
/Deadlock found when trying to get lock; try restarting transaction/
)
{
# ignore this particular error
sleep
1
;
unless
(
$log_message_adaptor
)
{
require
Bio::EnsEMBL::Hive::DBSQL::
DBAdaptor
;
my
$slave_dba
=
Bio::EnsEMBL::Hive::DBSQL::
DBAdaptor
->
new
(
-
dbconn
=>
$self
,
-
no_sql_schema_version_check
=>
1
,
);
$log_message_adaptor
=
$slave_dba
->
get_LogMessageAdaptor
();
}
$log_message_adaptor
->
store_hive_message
(
"
Caught a DEADLOCK when trying to execute '
$sql
' (attempt #
$attempt
), retrying in
$sleep_secs
sec
",
0
);
sleep
$sleep_secs
;
next
;
}
die
$@
;
# but definitely report other errors
};
last
;
}
die
"
After
$
retries
retrie
s the query '
$sql
' is still in a deadlock: $@
"
if
(
$@
);
die
"
After
$
attempts
attempt
s the query '
$sql
' is still in a deadlock: $@
"
if
(
$@
);
return
$retval
;
}
...
...
modules/Bio/EnsEMBL/Hive/DBSQL/LogMessageAdaptor.pm
View file @
4be8a0fb
...
...
@@ -90,5 +90,21 @@ sub store_worker_message {
$sth
->
finish
();
}
1
;
sub
store_hive_message
{
my
(
$self
,
$msg
,
$is_error
)
=
@_
;
chomp
$msg
;
# we don't want that last "\n" in the database
my
$table_name
=
$self
->
table_name
();
# Note: the timestamp 'time' column will be set automatically
my
$sql
=
qq{
INSERT INTO $table_name (status, msg, is_error) VALUES ('UNKNOWN', ?, ?)
}
;
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
(
$msg
,
$is_error
?
1
:
0
);
$sth
->
finish
();
}
1
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment