Fix race where results from an IncrementalIndexSegment could be cached. (#2983)

This commit is contained in:
Gian Merlino 2016-05-18 01:27:50 -07:00 committed by Nishant
parent 15ccf451f9
commit 970614875b
2 changed files with 12 additions and 4 deletions

View File

@ -409,7 +409,11 @@ public class AppenderatorImpl implements Appenderator
@Override
public QueryRunner<T> apply(final FireHydrant hydrant)
{
if (skipIncrementalSegment && !hydrant.hasSwapped()) {
// Hydrant might swap at any point, but if it's swapped at the start
// then we know it's *definitely* swapped.
final boolean hydrantDefinitelySwapped = hydrant.hasSwapped();
if (skipIncrementalSegment && !hydrantDefinitelySwapped) {
return new NoopQueryRunner<>();
}
@ -421,7 +425,7 @@ public class AppenderatorImpl implements Appenderator
segment.rhs
);
if (hydrant.hasSwapped() // only use caching if data is immutable
if (hydrantDefinitelySwapped // only use caching if data is immutable
&& cache.isLocal() // hydrants may not be in sync between replicas, make sure cache is local
) {
return new CachingQueryRunner<>(

View File

@ -334,7 +334,11 @@ public class RealtimePlumber implements Plumber
@Override
public QueryRunner<T> apply(FireHydrant input)
{
if (skipIncrementalSegment && !input.hasSwapped()) {
// Hydrant might swap at any point, but if it's swapped at the start
// then we know it's *definitely* swapped.
final boolean hydrantDefinitelySwapped = input.hasSwapped();
if (skipIncrementalSegment && !hydrantDefinitelySwapped) {
return new NoopQueryRunner<T>();
}
@ -346,7 +350,7 @@ public class RealtimePlumber implements Plumber
segment.rhs
);
if (input.hasSwapped() // only use caching if data is immutable
if (hydrantDefinitelySwapped // only use caching if data is immutable
&& cache.isLocal() // hydrants may not be in sync between replicas, make sure cache is local
) {
return new CachingQueryRunner<>(