diff --git a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderator.java b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderator.java index 9597ae0b54cb..8a7b3b535f57 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderator.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderator.java @@ -528,6 +528,9 @@ private Sink getOrCreateSink(final SegmentIdWithShardSpec identifier) ); bytesCurrentlyInMemory.addAndGet(calculateSinkMemoryInUsed(retVal)); + // Add sink prior to announcing it, to ensure it is immediately queryable. + addSink(identifier, retVal); + try { segmentAnnouncer.announceSegment(retVal.getSegment()); } @@ -536,8 +539,6 @@ private Sink getOrCreateSink(final SegmentIdWithShardSpec identifier) .addData("interval", retVal.getInterval()) .emit(); } - - addSink(identifier, retVal); } return retVal;