New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HWKMETRICS-692] Remove unnecessary calls to findMetric #840
Conversation
I started a soak test on this PR like #818. Results: Beginning of Soak Test
First Error appears (~2 minutes after test started)2017-07-05 19:39:54,338, an nullPoint exception error manifests:
Temporary Tables starts (~3 minutes after test started)
TempDataCompressor starts and results in error (~83 minutes or 1 hour and 23 minutes after the test started)
|
@gbaufake Those lines make no sense. You're using a very old build? Line 651 in MetricsServiceImpl has been a comment line from a commit done on 19th of June. |
Rebased against current master. |
@burmanm : |
retest this please |
(this should have no effect on the write performance as this doesn't touch the write path) |
retest this please |
1 similar comment
retest this please |
Rebased from master |
@jsanda Can you review and merge? |
@@ -149,7 +149,8 @@ public void getMetrics( | |||
|
|||
Observable<Metric<Double>> metricObservable = null; | |||
if (tags != null) { | |||
metricObservable = metricsService.findMetricsWithFilters(getTenant(), GAUGE, tags); | |||
metricObservable = metricsService.findMetricIdentifiersWithFilters(getTenant(), GAUGE, tags) | |||
.flatMap(metricsService::findMetric); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these findMetric
calls are against the same partition. We ought to consider collecting all of the ids and doing a single query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, or at least make that request happen in a single unlogged batch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.doOnError(Throwable::printStackTrace) | ||
.filter(row -> tenantId.equals(row.getString(0))) | ||
.distinct() | ||
.compose(new MetricFromFullDataRowTransformer(defaultTTL)) | ||
.compose(new MetricIdentifierFromFullDataRowTransformer(defaultTTL)) | ||
.flatMap(this::findMetric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you do this findMetric
call here? I am not sure why it is needed since findMetricsInMetricsIndex
gets called below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you define which gets selected in the distinct
operator? Say they both return:
Metric(Gauge, "t1", "m1")
, but the one from metricsIndex returns with Tags: a=b
and the one from data doesn't. We do a distinct and drop one. I'd definitely want to drop the one from findAllMetricIdentifiersInData
but how does one select correct one? Ideas? This should be fixed in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand what you are saying. I think the distinct
call at line 528 is not needed. See HWKMETRICS-715. I think it should come after line 529.
We do not store metric tags in the data tables. If the metric id is found in the data tables, it is not necessarily in metrics_idx. Line 530 is doing the same thing as the call to findMetricsInMetricsIndex
at line 539, except it is getting executed for every metric id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we were referring to different distinct operators. I was thinking about the one in the line 545 which is linked to why line 530 does this::findMetric
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without that "this::findMetric", we could inadvertently remove the tags from the end result (as we compare MetricId equality, but one object does not have tags)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, no.. because of concatWith + distinct we should first let the metricsIndex survive and then check the data against duplicates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, because of the concatWtih + distinct the metrics emitted from the metricsIndex observable will survive. So can we remove the findMetric call on the setFromData observable?
Rebased from master at the same time (due to changes related to this PR). |
a6b2990
to
38ce1b6
Compare
Rebase from the master |
@burmanm what is the status of this PR? We need this bug fix, and it probably needs to be back ported as well. |
I thought we had discussed and agreed that the findMetric call at line 536 in MetricsServiceImpl is not needed because line 551 is setFromMetricsIndex.concatWith(setFromData).distinct(Metric::getMetricId) If the order of the concatenation is reversed, then it would break. I tested this locally to verify for myself as well. |
Although it would seem so, a large amount of our tests break with that change. |
I think some of the tests might need to be refactored. I see some failures happening in |
That should fix it |
retest this please |
This PR requires PR #818 to be merged first. This removes the calls to
metricsService.findMetric()
in cases where it's not needed. This reduces the amount of Cassandra calls in read requests that use tags (other than fetching full metric definition).