Real time Node merge index throws NPE after adding Metrics

Druid version 0.8.2
Segment Granularity: HOUR

My problem is very similar with this closed issue #145,

Around 40 minutes after an hour, I added a longSum metric and restarted the node.

when merging index,will throw NPE

java.lang.NullPointerException

at io.druid.query.aggregation.LongSumAggregator.combineValues(LongSumAggregator.java:39) ~[druid-processing-0.8.2.jar:0.8.2]

at io.druid.query.aggregation.LongSumAggregatorFactory.combine(LongSumAggregatorFactory.java:78) ~[druid-processing-0.8.2.jar:0.8.2]

at io.druid.segment.IndexMerger$RowboatMergeFunction.apply(IndexMerger.java:1260) ~[druid-processing-0.8.2.jar:0.8.2]

at io.druid.segment.IndexMerger$RowboatMergeFunction.apply(IndexMerger.java:1236) ~[druid-processing-0.8.2.jar:0.8.2]

at io.druid.collections.CombiningIterator.next(CombiningIterator.java:78) ~[druid-common-0.8.2.jar:0.8.2]

at io.druid.segment.IndexMerger.makeIndexFiles(IndexMerger.java:747) ~[druid-processing-0.8.2.jar:0.8.2]

at io.druid.segment.IndexMerger.merge(IndexMerger.java:351) ~[druid-processing-0.8.2.jar:0.8.2]

at io.druid.segment.IndexMerger.mergeQueryableIndex(IndexMerger.java:227) ~[druid-processing-0.8.2.jar:0.8.2]

at io.druid.segment.IndexMerger.mergeQueryableIndex(IndexMerger.java:216) ~[druid-processing-0.8.2.jar:0.8.2]

``

So I think this issue hasn’t been resolved.

look into the following code of IndexMerger line number from 657 to 688.

boats.add(

new MMappedIndexRowIterable(

Iterables.transform(

indexes.get(i).getRows(),

new Function<Rowboat, Rowboat>()

{

@Override

public Rowboat apply(@Nullable Rowboat input)

{

int newDims = new int[mergedDimensions.size()];

int j = 0;

for (int dim : input.getDims()) {

newDims[dimLookup[j]] = dim;

j++;

}

Object newMetrics = new Object[mergedMetrics.size()];

j = 0;

for (Object met : input.getMetrics()) {

newMetrics[metricLookup[j]] = met;

j++;

}

return new Rowboat(

input.getTimestamp(),

newDims,

newMetrics,

input.getRowNum()

);

}

}

)

``

Build newMetrics base on the metric of input row. the previous indexes don’t have new addition metric, So in the newMetrics,the value of new addition metric is null

for (Object met : input.getMetrics()) {

newMetrics[metricLookup[j]] = met;

j++;

}

``

modify the code of LongSumAggregator ,first check for not null,it work well.

static long combineValues(Object lhs, Object rhs) {

if(lhs == null){

lhs = 0L;

}

if(rhs == null){

rhs = 0L;

}

return ((Number) lhs).longValue() + ((Number) rhs).longValue();

}

``

I also open an issue https://github.com/druid-io/druid/issues/2744

在 2016年3月24日星期四 UTC+8下午5:37:37,Hailei Zhang写道: