You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "Jackie-Jiang (via GitHub)" <gi...@apache.org> on 2023/09/27 05:13:17 UTC

[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #11692: Fix the potential access to upsert metadata manager after it is closed

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


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java:
##########
@@ -702,29 +674,50 @@ public void removeExpiredPrimaryKeys() {
    */
   protected abstract void doRemoveExpiredPrimaryKeys();
 
+  protected synchronized boolean startOperation() {
+    if (_stopped || _numPendingOperations == 0) {
+      return false;
+    }
+    _numPendingOperations++;
+    return true;
+  }
+
+  protected synchronized void finishOperation() {
+    _numPendingOperations--;
+    if (_numPendingOperations == 0) {
+      notifyAll();
+    }
+  }
+
   @Override
-  public void stop() {
+  public synchronized void stop() {
+    if (_stopped) {
+      _logger.warn("Metadata manager is already stopped");
+      return;
+    }
     _stopped = true;
-    int numPendingOperations = _numPendingOperations.decrementAndGet();
+    _numPendingOperations--;

Review Comment:
   There is a `Preconditions.checkState` in `close()` to ensure `stop()` is already called



-- 
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-unsubscribe@pinot.apache.org

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


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