deepthi912 opened a new pull request, #19744:
URL: https://github.com/apache/pinot/pull/19744

   ## Problem
   
   `BasePartitionUpsertMetadataManager` tracks in-flight operations in 
`_numPendingOperations`, and `close()` is the only place that waits for them to 
drain:
   
   ```java
   while (_numPendingOperations != 0) {
     wait();
   }
   ```
   
   `startOperation()` and `finishOperation()` are `protected`, so a subclass 
can hook the lifecycle — but the count itself is `private`, so there is no 
condition a subclass can wait on.
   
   That matters when a subclass needs to drain earlier than `close()`. A 
realtime table's segments are released between `stop()` and `close()`, so 
anything that has to read a consuming segment during shutdown must do it at 
`stop()` time — after new operations have stopped, but before the ones already 
running have finished. `close()`'s wait comes too late.
   
   Without a reachable condition, the only option is to mirror the count by 
overriding both hooks and maintaining a parallel field, which duplicates state 
that already exists and puts an extra reentrant monitor acquire on the 
per-record `addRecord` path.
   
   ## Change
   
   Make the field `protected`. One modifier plus a comment; no behaviour 
change, no new methods, nothing else touched.
   
   A subclass can then write the guarded wait against the real count:
   
   ```java
   private synchronized void awaitPendingOperations() throws 
InterruptedException {
     while (_numPendingOperations > 0) {
       wait();
     }
   }
   ```
   
   This is safe because the monitor is the same object: `finishOperation()` 
already does `notifyAll()` on `this` when the count reaches zero, and `wait()` 
relinquishes all claims on `this`, including reentrant ones. After `stop()` the 
count only decreases — `startOperation()` returns `false` once `_stopped` — so 
once it reaches zero it stays there.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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]

Reply via email to