fix bugs in the parser and in copying result

This commit is contained in:
yangdsh 2020-02-28 02:44:01 +00:00 committed by Dana Van Aken
parent 21971e673f
commit b86e39b15f
2 changed files with 16 additions and 10 deletions

View File

@ -104,9 +104,14 @@ class BaseParser:
tunable_knob_catalog = KnobCatalog.objects.filter(dbms__id=self.dbms_id, tunable=True) tunable_knob_catalog = KnobCatalog.objects.filter(dbms__id=self.dbms_id, tunable=True)
for metadata in tunable_knob_catalog: for metadata in tunable_knob_catalog:
name = metadata.name name = metadata.name
if name not in knobs:
if name.startswith('global.'):
name = name[name.find('.') + 1:]
if name not in knobs: if name not in knobs:
continue continue
value = knobs[name] value = knobs[name]
if isinstance(value, str):
value = value.replace('\'', '')
conv_value = None conv_value = None
if metadata.vartype == VarType.BOOL: if metadata.vartype == VarType.BOOL:

View File

@ -518,15 +518,15 @@ def handle_result_files(session, files, execution_times=None):
past_metric.data = JSONUtil.dumps(past_metric_data) past_metric.data = JSONUtil.dumps(past_metric_data)
past_metric.save() past_metric.save()
result = Result.objects.filter(metric_data=worst_metric).first() worst_result = Result.objects.filter(metric_data=worst_metric).first()
latest_result = Result.objects.filter(session=session).order_by("-id").first() last_result = Result.objects.filter(session=session).order_by("-id").first()
backup_data = BackupData.objects.filter(result=result).first() backup_data = BackupData.objects.filter(result=worst_result).first()
last_conf = JSONUtil.loads(result.next_configuration) last_conf = JSONUtil.loads(last_result.next_configuration)
last_conf = last_conf["recommendation"] last_conf = last_conf["recommendation"]
last_conf = parser.convert_dbms_knobs(result.dbms.pk, last_conf) last_conf = parser.convert_dbms_knobs(last_result.dbms.pk, last_conf)
# Copy worst data and modify # Copy worst data and modify
knob_data = result.knob_data knob_data = worst_result.knob_data
knob_data.pk = None knob_data.pk = None
all_knobs = JSONUtil.loads(knob_data.knobs) all_knobs = JSONUtil.loads(knob_data.knobs)
for knob in all_knobs.keys(): for knob in all_knobs.keys():
@ -542,16 +542,16 @@ def handle_result_files(session, files, execution_times=None):
data_knobs[knob] = last_conf[tunable_knob] data_knobs[knob] = last_conf[tunable_knob]
knob_data.data = JSONUtil.dumps(data_knobs) knob_data.data = JSONUtil.dumps(data_knobs)
knob_name_parts = latest_result.knob_data.name.split('*')[0].split('#') knob_name_parts = last_result.knob_data.name.split('*')[0].split('#')
knob_name_parts[-1] = str(int(knob_name_parts[-1]) + 1) + '*' knob_name_parts[-1] = str(int(knob_name_parts[-1]) + 1) + '*'
knob_data.name = '#'.join(knob_name_parts) knob_data.name = '#'.join(knob_name_parts)
knob_data.creation_time = now() knob_data.creation_time = now()
knob_data.save() knob_data.save()
knob_data = KnobData.objects.filter(session=session).order_by("-id").first() knob_data = KnobData.objects.filter(session=session).order_by("-id").first()
metric_data = result.metric_data metric_data = worst_result.metric_data
metric_data.pk = None metric_data.pk = None
metric_name_parts = latest_result.metric_data.name.split('*')[0].split('#') metric_name_parts = last_result.metric_data.name.split('*')[0].split('#')
metric_name_parts[-1] = str(int(metric_name_parts[-1]) + 1) + '*' metric_name_parts[-1] = str(int(metric_name_parts[-1]) + 1) + '*'
metric_data.name = '#'.join(metric_name_parts) metric_data.name = '#'.join(metric_name_parts)
metric_cpy = JSONUtil.loads(metric_data.data) metric_cpy = JSONUtil.loads(metric_data.data)
@ -561,6 +561,7 @@ def handle_result_files(session, files, execution_times=None):
metric_data.save() metric_data.save()
metric_data = MetricData.objects.filter(session=session).order_by("-id").first() metric_data = MetricData.objects.filter(session=session).order_by("-id").first()
result = worst_result
result.pk = None result.pk = None
result.knob_data = knob_data result.knob_data = knob_data
result.metric_data = metric_data result.metric_data = metric_data