You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/05/29 16:56:13 UTC
[GitHub] [druid] xvrl commented on a change in pull request #9943: fix unsafe concurrent access in StreamAppenderatorDriver
xvrl commented on a change in pull request #9943:
URL: https://github.com/apache/druid/pull/9943#discussion_r432613735
##########
File path: server/src/main/java/org/apache/druid/segment/realtime/appenderator/BaseAppenderatorDriver.java
##########
@@ -427,30 +428,36 @@ protected AppenderatorDriverAddResult append(
/**
* Returns a stream of {@link SegmentWithState} for the given sequenceNames.
+ *
+ * Note: it is not enough to synchronize on segments to access to this method,
+ * any operation on the resulting stream must also be synchronized on segments.
*/
+ @GuardedBy("segments")
Stream<SegmentWithState> getSegmentWithStates(Collection<String> sequenceNames)
{
- synchronized (segments) {
- return sequenceNames
- .stream()
- .map(segments::get)
- .filter(Objects::nonNull)
- .flatMap(segmentsForSequence -> segmentsForSequence.intervalToSegmentStates.values().stream())
- .flatMap(segmentsOfInterval -> segmentsOfInterval.getAllSegments().stream());
- }
+ return sequenceNames
Review comment:
we can definitely change the methods to do the full reduction. It seemed we had plans to use this for other things, but I can certainly simplify it
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org