joshelser commented on a change in pull request #2191:
URL: https://github.com/apache/hbase/pull/2191#discussion_r468152005



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
##########
@@ -600,6 +600,10 @@ public void terminate(String reason, Exception cause, 
boolean clearMetrics, bool
         if (worker.entryReader.isAlive()) {
           worker.entryReader.interrupt();
         }
+      } else {
+        //If worker is already stopped but there was still entries batched,
+        //wee need to clear buffer used for non processed entries

Review comment:
       nit: `we`

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceWALReader.java
##########
@@ -309,6 +310,16 @@ public WALEntryBatch poll(long timeout) throws 
InterruptedException {
     return entryBatchQueue.poll(timeout, TimeUnit.MILLISECONDS);
   }
 
+  public void clearWALEntryBatch() {

Review comment:
       Should this be atomic? Is there anything to prevent two racing threads: 
one calling this `clearWALEntryBatch()` method and another trying to normally 
consume the next `WALEntryBatch`?
   
   I think this could lead to a double-decrement.

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceWALReader.java
##########
@@ -309,6 +310,16 @@ public WALEntryBatch poll(long timeout) throws 
InterruptedException {
     return entryBatchQueue.poll(timeout, TimeUnit.MILLISECONDS);
   }
 
+  public void clearWALEntryBatch() {
+    entryBatchQueue.forEach(w -> {
+      entryBatchQueue.remove(w);
+      w.getWalEntries().forEach(e -> {

Review comment:
       What about summing the total size to decrement and then making the one 
call to `totalBufferUsed`? Guessing that might be micro-optimized faster.




----------------------------------------------------------------
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:
[email protected]


Reply via email to