From f7faad0477d66de1e9d89a00fe9c4d8b0b80f198 Mon Sep 17 00:00:00 2001 From: binlijin Date: Wed, 31 Jan 2018 14:05:30 +0800 Subject: [PATCH] HBASE-19728 Add lock to filesCompacting in all place. --- .../org/apache/hadoop/hbase/regionserver/HStore.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java index f228d44dea5..b00758f14e2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -1451,7 +1451,9 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat this.lock.writeLock().lock(); try { this.storeEngine.getStoreFileManager().addCompactionResults(compactedFiles, result); - filesCompacting.removeAll(compactedFiles); // safe bc: lock.writeLock(); + synchronized (filesCompacting) { + filesCompacting.removeAll(compactedFiles); + } } finally { this.lock.writeLock().unlock(); } @@ -2306,7 +2308,11 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat @Override public boolean needsCompaction() { - return this.storeEngine.needsCompaction(this.filesCompacting); + List filesCompactingClone = null; + synchronized (filesCompacting) { + filesCompactingClone = Lists.newArrayList(filesCompacting); + } + return this.storeEngine.needsCompaction(filesCompactingClone); } /**