clintropolis commented on a change in pull request #10660: URL: https://github.com/apache/druid/pull/10660#discussion_r540481700
########## File path: sql/src/main/java/org/apache/druid/sql/calcite/schema/DruidSchema.java ########## @@ -448,25 +449,27 @@ void removeServerSegment(final DruidServerMetadata server, final DataSegment seg { synchronized (lock) { log.debug("Segment[%s] is gone from server[%s]", segment.getId(), server.getName()); - if (server.getType().equals(ServerType.BROKER)) { - // a segment on a broker means a broadcast datasource, skip metadata because we'll also see this segment on the - // historical, however mark the datasource for refresh because it might no longer be broadcast or something - dataSourcesNeedingRebuild.add(segment.getDataSource()); - } else { - final Map<SegmentId, AvailableSegmentMetadata> knownSegments = segmentMetadataInfo.get(segment.getDataSource()); - final AvailableSegmentMetadata segmentMetadata = knownSegments.get(segment.getId()); - final Set<DruidServerMetadata> segmentServers = segmentMetadata.getReplicas(); - final ImmutableSet<DruidServerMetadata> servers = FluentIterable - .from(segmentServers) - .filter(Predicates.not(Predicates.equalTo(server))) - .toSet(); - - final AvailableSegmentMetadata metadataWithNumReplicas = AvailableSegmentMetadata - .from(segmentMetadata) - .withReplicas(servers) - .withRealtime(recomputeIsRealtime(servers)) - .build(); - knownSegments.put(segment.getId(), metadataWithNumReplicas); + final Map<SegmentId, AvailableSegmentMetadata> knownSegments = segmentMetadataInfo.get(segment.getDataSource()); + if (knownSegments != null && !knownSegments.isEmpty()) { Review comment: Hmm, I couldn't work out in my mind that it definitively would be there so added this check as a precaution. Note that segments on brokers are _not_ added to `segmentMetadataInfo` (or currently stored in the broker server view timeline), so my fear was cases where the segment is dropped from all historicals before the broker. That said, I don't really like this `if` statement either, let me see if i can determine for sure if this can happen. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org