Skip to content

Commit

Permalink
add stop status
Browse files Browse the repository at this point in the history
This adds a stopped status to the potential statuses.
Replacing "failed" as the status that results from stopping
a job

Bug: T289349
Change-Id: Ic8f1ae655c8ef1c6cfc055c62cdd0b1fa145fdc0
  • Loading branch information
Michael DiPietro committed Sep 24, 2021
1 parent cb1232d commit fe605f3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion quarry/web/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def health_summary(minutes):
'running': 0,
'killed': 0,
'complete': 0,
'superseded': 0}
'superseded': 0,
'stopped': 0}

for row in statuses:
query_run_status = row[0]
Expand Down
4 changes: 3 additions & 1 deletion quarry/web/models/queryrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class QueryRun(Base):
STATUS_KILLED = 3
STATUS_COMPLETE = 4
STATUS_SUPERSEDED = 5
STATUS_STOPPED = 6

# TODO (phuedx, 2014/08/08): Make this translatable.
STATUS_MESSAGES = [
Expand All @@ -20,7 +21,8 @@ class QueryRun(Base):
'running',
'killed',
'complete',
'superseded'
'superseded',
'stopped'
]

__tablename__ = 'query_run'
Expand Down
1 change: 0 additions & 1 deletion quarry/web/static/js/query/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ $( function () {
.done( function ( data ) {
var d = JSON.parse( data );
checkStatus( d.qrun_id, false );
alert( d.stopped );
} )
.fail( function ( resp ) {
alert( resp.responseText );
Expand Down
7 changes: 7 additions & 0 deletions quarry/web/static/templates/compiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ output += "\nThis query is waiting to be executed\n";
;
}
else {
if(runtime.contextOrFrameLookup(context, frame, "status") == "stopped") {
output += "\nThis query was stopped\n";
;
}
else {
if(runtime.contextOrFrameLookup(context, frame, "status") == "running") {
output += "\nThis query is currently executing...\n";
if(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "extra")),"connection_id")) {
Expand All @@ -148,6 +153,8 @@ output += "\n";
}
;
}
;
}
output += "\n";
if(parentTemplate) {
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
Expand Down
2 changes: 2 additions & 0 deletions quarry/web/static/templates/query-status.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This query took longer than 30 minutes to execute and was killed.
{% elif status == 'queued' %}
This query is waiting to be executed
{% elif status == 'stopped' %}
This query was stopped
{% elif status == 'running' %}
This query is currently executing...
{% if extra.connection_id %}
Expand Down
8 changes: 7 additions & 1 deletion quarry/web/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ def run_query(query_run_id):
else: # Surfacing it to the user is always better than just silently failing
write_error(qrun, e.args[1])
except pymysql.DatabaseError as e:
write_error(qrun, e.args[1])
if e.args[0] == 2013: # Query stopped gives a lost connection code
qrun.status = QueryRun.STATUS_STOPPED
conn.session.add(qrun)
conn.session.commit()
celery_log.info("Stopped run for qrun:%s", qrun.id)
else:
write_error(qrun, e.args[1])
finally:
conn.close_session()
del repl.connection
Expand Down

0 comments on commit fe605f3

Please sign in to comment.