Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
4bfe8a78
Commit
4bfe8a78
authored
Feb 26, 2015
by
Leo Gordon
Browse files
bugfix: two instances of REPLACE INTO substituted by DELETE+INSERT
parents
5e3d2cd2
07a02deb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
+9
-7
modules/Bio/EnsEMBL/Hive/Queen.pm
modules/Bio/EnsEMBL/Hive/Queen.pm
+11
-4
No files found.
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
View file @
4bfe8a78
...
...
@@ -320,14 +320,16 @@ sub check_in_job {
sub
store_out_files
{
my
(
$self
,
$job
)
=
@_
;
# FIXME: An UPSERT would be better here, but it is only promised in PostgreSQL starting from 9.5, which is not officially out yet.
my
$delete_sql
=
'
DELETE from job_file WHERE role_id=
'
.
$job
->
role_id
.
'
AND job_id=
'
.
$job
->
dbID
.
'
AND retry=
'
.
$job
->
retry_count
;
$self
->
dbc
->
do
(
$delete_sql
);
if
(
$job
->
stdout_file
or
$job
->
stderr_file
)
{
my
$insert_sql
=
'
REPLACE INTO job_file (job_id, retry, role_id, stdout_file, stderr_file) VALUES (?,?,?,?,?)
';
my
$sth
=
$self
->
dbc
()
->
prepare
(
$insert_sql
);
$sth
->
execute
(
$job
->
dbID
(),
$job
->
retry_count
(),
$job
->
role_id
(),
$job
->
stdout_file
(),
$job
->
stderr_file
());
$sth
->
finish
();
}
else
{
my
$sql
=
'
DELETE from job_file WHERE role_id=
'
.
$job
->
role_id
.
'
AND job_id=
'
.
$job
->
dbID
;
$self
->
dbc
->
do
(
$sql
);
my
$insert_sql
=
'
INSERT INTO job_file (job_id, retry, role_id, stdout_file, stderr_file) VALUES (?,?,?,?,?)
';
my
$insert_sth
=
$self
->
dbc
->
prepare
(
$insert_sql
);
$insert_sth
->
execute
(
$job
->
dbID
,
$job
->
retry_count
,
$job
->
role_id
,
$job
->
stdout_file
,
$job
->
stderr_file
);
$insert_sth
->
finish
();
}
}
...
...
modules/Bio/EnsEMBL/Hive/Queen.pm
View file @
4bfe8a78
...
...
@@ -719,21 +719,28 @@ sub interval_workers_with_unknown_usage {
sub
store_resource_usage
{
my
(
$self
,
$report_entries
,
$processid_2_workerid
)
=
@_
;
my
$sql_replace
=
'
REPLACE INTO worker_resource_usage (worker_id, exit_status, mem_megs, swap_megs, pending_sec, cpu_sec, lifespan_sec, exception_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
';
my
$sth_replace
=
$self
->
prepare
(
$sql_replace
);
# FIXME: An UPSERT would be better here, but it is only promised in PostgreSQL starting from 9.5, which is not officially out yet.
my
$sql_delete
=
'
DELETE FROM worker_resource_usage WHERE worker_id=?
';
my
$sth_delete
=
$self
->
prepare
(
$sql_delete
);
my
$sql_insert
=
'
INSERT INTO worker_resource_usage (worker_id, exit_status, mem_megs, swap_megs, pending_sec, cpu_sec, lifespan_sec, exception_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
';
my
$sth_insert
=
$self
->
prepare
(
$sql_insert
);
my
@not_ours
=
();
while
(
my
(
$process_id
,
$report_entry
)
=
each
%$report_entries
)
{
if
(
my
$worker_id
=
$processid_2_workerid
->
{
$process_id
}
)
{
$sth_replace
->
execute
(
$worker_id
,
@$report_entry
{'
exit_status
',
'
mem_megs
',
'
swap_megs
',
'
pending_sec
',
'
cpu_sec
',
'
lifespan_sec
',
'
exception_status
'}
);
# slicing hashref
$sth_delete
->
execute
(
$worker_id
);
$sth_insert
->
execute
(
$worker_id
,
@$report_entry
{'
exit_status
',
'
mem_megs
',
'
swap_megs
',
'
pending_sec
',
'
cpu_sec
',
'
lifespan_sec
',
'
exception_status
'}
);
# slicing hashref
}
else
{
push
@not_ours
,
$process_id
;
#warn "\tDiscarding process_id=$process_id as probably not ours because it could not be mapped to a Worker\n";
}
}
$sth_replace
->
finish
();
$sth_delete
->
finish
();
$sth_insert
->
finish
();
}
...
...
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