Jackie-Jiang commented on code in PR #12886:
URL: https://github.com/apache/pinot/pull/12886#discussion_r1577266557


##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java:
##########
@@ -752,14 +752,20 @@ public void run() {
                   _state = State.DISCARDED;
                   break;
                 case DEFAULT:
-                  success = buildSegmentAndReplace();
-                  if (success) {
-                    _state = State.RETAINED;
-                  } else {
-                    // Could not build segment for some reason. We can only 
download it.
-                    _state = State.ERROR;
-                    _segmentLogger.error("Could not build segment for {}", 
_segmentNameStr);
+                  // Lock the segment to avoid multiple threads touching the 
same segment.
+                  Lock segmentLock = 
_realtimeTableDataManager.getSegmentLock(_segmentNameStr);
+                  segmentLock.lock();
+                  try {
+                    if (buildSegmentAndReplace()) {

Review Comment:
   It is intentional to lock here. This is the control flow from the consuming 
segment. `buildSegmentAndReplace()` can be invoked from Helix thread as well, 
where it is already locked.



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to