kfaraz commented on code in PR #18291:
URL: https://github.com/apache/druid/pull/18291#discussion_r2217118020
##########
server/src/main/java/org/apache/druid/server/coordination/SegmentLoadDropHandler.java:
##########
@@ -216,21 +208,30 @@ void removeSegment(
SegmentChangeStatus result = null;
try {
announcer.unannounceSegment(segment);
- segmentsToDelete.add(segment);
+
+ final SegmentDropLatch dropLatch = new SegmentDropLatch();
+ final SegmentDropLatch priorLatch =
segmentDropLatches.putIfAbsent(segment, dropLatch);
+
+ if (priorLatch != null) {
+ log.warn("Cannot drop segment[%s] that already has a drop pending.
Ignoring.", segment.getId());
+ return;
+ }
Runnable runnable = () -> {
try {
- synchronized (segmentDeleteLock) {
- if (segmentsToDelete.remove(segment)) {
- segmentManager.dropSegment(segment);
- }
+ if (dropLatch.startDropping()) {
+ segmentManager.dropSegment(segment);
}
}
catch (Exception e) {
log.makeAlert(e, "Failed to remove segment! Possible resource leak!")
.addData("segment", segment)
.emit();
}
+ finally {
+ dropLatch.doneDropping();
+ segmentDropLatches.remove(segment, dropLatch);
Review Comment:
Based on the changes made to `addSegment` and `removeSegment`, I think we
can get away with calling `Map.remove(key)` here instead of `Map.remove(key,
value)`.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]