You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2019/04/12 14:54:13 UTC

[accumulo] branch master updated: fixes #1037 unsynchronzied tablet close state methods (#1085)

This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 903119d  fixes #1037 unsynchronzied tablet close state methods (#1085)
903119d is described below

commit 903119dac631b36009b389193d9d0bc04ed7fb37
Author: Keith Turner <kt...@apache.org>
AuthorDate: Fri Apr 12 10:54:07 2019 -0400

    fixes #1037 unsynchronzied tablet close state methods (#1085)
---
 .../java/org/apache/accumulo/tserver/tablet/Tablet.java  | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index e10b5ff..0e4260a 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -1979,9 +1979,7 @@ public class Tablet {
           CompactionEnv cenv = new CompactionEnv() {
             @Override
             public boolean isCompactionEnabled() {
-              // avoid calling isClosing() because its synchronized and this is called frequently in
-              // compaction
-              return closeState != CloseState.CLOSING;
+              return !isClosing();
             }
 
             @Override
@@ -2199,15 +2197,19 @@ public class Tablet {
     return numEntriesInMemory;
   }
 
-  public synchronized boolean isClosing() {
+  // Do not synchronize this method, it is called frequently by compactions
+  public boolean isClosing() {
     return closeState == CloseState.CLOSING;
   }
 
-  public synchronized boolean isClosed() {
-    return closeState == CloseState.CLOSED || closeState == CloseState.COMPLETE;
+  public boolean isClosed() {
+    // Assign to a local var to avoid race conditions since closeState is volatile and two
+    // comparisons are done.
+    CloseState localCS = closeState;
+    return localCS == CloseState.CLOSED || localCS == CloseState.COMPLETE;
   }
 
-  public synchronized boolean isCloseComplete() {
+  public boolean isCloseComplete() {
     return closeState == CloseState.COMPLETE;
   }