Adjusted background task time

This commit is contained in:
dvanaken 2019-12-05 11:48:29 -05:00 committed by Dana Van Aken
parent 783b94cd4d
commit 02c40f5cea
3 changed files with 22 additions and 15 deletions

View File

@ -110,7 +110,7 @@ matrix:
before_install:
- mysql -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME}"
- sed -i '/psycopg2/d' $WEB/requirements.txt
- sed -i 's/^RUN_EVERY =.*$/RUN_EVERY = 60/' $WEB/website/settings/constants.py
- sed -i 's/^RUN_EVERY =.*$/RUN_EVERY = 180/' $WEB/website/settings/constants.py
script:
- cd $WEB && python manage.py runserver 0.0.0.0:8000 &
- sleep 10 && cd $DRIVER && fab integration_tests
@ -128,7 +128,7 @@ matrix:
before_install:
- psql -U postgres -c "CREATE DATABASE ${DB_NAME}"
- sed -i '/mysqlclient/d' $WEB/requirements.txt
- sed -i 's/^RUN_EVERY =.*$/RUN_EVERY = 60/' $WEB/website/settings/constants.py
- sed -i 's/^RUN_EVERY =.*$/RUN_EVERY = 180/' $WEB/website/settings/constants.py
script:
- cd $WEB && python manage.py runserver 0.0.0.0:8000 &
- sleep 10 && cd $DRIVER && fab integration_tests

View File

@ -110,6 +110,12 @@ class ConfigurationRecommendation(UpdateTask): # pylint: disable=abstract-metho
result_id = retval['result_id']
result = Result.objects.get(pk=result_id)
# Create next configuration to try
config = db.parser.create_knob_configuration(result.dbms.pk, retval['recommendation'])
retval['recommendation'] = config
result.next_configuration = JSONUtil.dumps(retval)
result.save()
# Replace result with formatted result
formatted_params = db.parser.format_dbms_knobs(result.dbms.pk, retval['recommendation'])
task_meta = TaskMeta.objects.get(task_id=task_id)
@ -117,12 +123,6 @@ class ConfigurationRecommendation(UpdateTask): # pylint: disable=abstract-metho
task_meta.result = retval
task_meta.save()
# Create next configuration to try
config = db.parser.create_knob_configuration(result.dbms.pk, retval['recommendation'])
retval['recommendation'] = config
result.next_configuration = JSONUtil.dumps(retval)
result.save()
def clean_knob_data(knob_matrix, knob_labels, session):
# Makes sure that all knobs in the dbms are included in the knob_matrix and knob_labels

View File

@ -7,6 +7,7 @@
import logging
import datetime
import re
import time
from collections import OrderedDict
from django.contrib.auth import authenticate, login, logout
@ -1079,16 +1080,22 @@ def give_result(request, upload_code): # pylint: disable=unused-argument
overall_status, num_completed = TaskUtil.get_task_status(tasks)
if overall_status == 'SUCCESS':
if not latest_result.next_configuration:
# If the task status was incomplete when we first queried latest_result
# but succeeded before the call to TaskUtil.get_task_status() finished
# then latest_result is stale and must be updated.
LOG.debug("Updating stale result (pk=%s)", latest_result.pk)
# The task status is set to SUCCESS before the next config is saved in
# the latest result so we must wait for it to be updated
max_wait_sec = 20
elapsed_sec = 0
while not latest_result.next_configuration and elapsed_sec <= max_wait_sec:
time.sleep(5)
elapsed_sec += 5
latest_result = Result.objects.get(id=latest_result.pk)
LOG.debug("Waiting for the next config for result %s to be updated... "
"(elapsed: %ss): %s", latest_result.pk, elapsed_sec,
model_to_dict(latest_result))
if not latest_result.next_configuration:
LOG.warning("Failed to get the next configuration from the latest result: %s",
model_to_dict(latest_result))
LOG.warning(
"Failed to get the next configuration from the latest result after %ss: %s",
elapsed_sec, model_to_dict(latest_result))
overall_status = 'FAILURE'
response = _failed_response(latest_result, tasks, num_completed, overall_status,
'Failed to get the next configuration.')