From 07129418257496c2ceb4b716c40c68717d28036b Mon Sep 17 00:00:00 2001 From: cheddar Date: Tue, 2 Jul 2013 11:53:53 -0700 Subject: [PATCH] 1) Add check whether a Hydrant has already been persisted before persisting. Persisting happens synchronously on the same thread, but multiple persist requests can be queued up on that thread which means that subsequent ones would fail with an NPE. Fixes #178 --- .../druid/realtime/plumber/RealtimePlumberSchool.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/realtime/src/main/java/com/metamx/druid/realtime/plumber/RealtimePlumberSchool.java b/realtime/src/main/java/com/metamx/druid/realtime/plumber/RealtimePlumberSchool.java index 5ba229ea56a..a429fbef9d5 100644 --- a/realtime/src/main/java/com/metamx/druid/realtime/plumber/RealtimePlumberSchool.java +++ b/realtime/src/main/java/com/metamx/druid/realtime/plumber/RealtimePlumberSchool.java @@ -662,6 +662,14 @@ public class RealtimePlumberSchool implements PlumberSchool */ private int persistHydrant(FireHydrant indexToPersist, Schema schema, Interval interval) { + if (indexToPersist.hasSwapped()) { + log.info( + "DataSource[%s], Interval[%s], Hydrant[%s] already swapped. Ignoring request to persist.", + schema.getDataSource(), interval, indexToPersist + ); + return 0; + } + log.info("DataSource[%s], Interval[%s], persisting Hydrant[%s]", schema.getDataSource(), interval, indexToPersist); try { int numRows = indexToPersist.getIndex().size();