HBASE-19728 Add lock to filesCompacting in all place.

This commit is contained in:
binlijin 2018-01-31 14:05:30 +08:00
parent 08bcd64c25
commit f7faad0477
1 changed files with 8 additions and 2 deletions

View File

@ -1451,7 +1451,9 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
this.lock.writeLock().lock(); this.lock.writeLock().lock();
try { try {
this.storeEngine.getStoreFileManager().addCompactionResults(compactedFiles, result); this.storeEngine.getStoreFileManager().addCompactionResults(compactedFiles, result);
filesCompacting.removeAll(compactedFiles); // safe bc: lock.writeLock(); synchronized (filesCompacting) {
filesCompacting.removeAll(compactedFiles);
}
} finally { } finally {
this.lock.writeLock().unlock(); this.lock.writeLock().unlock();
} }
@ -2306,7 +2308,11 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
@Override @Override
public boolean needsCompaction() { public boolean needsCompaction() {
return this.storeEngine.needsCompaction(this.filesCompacting); List<HStoreFile> filesCompactingClone = null;
synchronized (filesCompacting) {
filesCompactingClone = Lists.newArrayList(filesCompacting);
}
return this.storeEngine.needsCompaction(filesCompactingClone);
} }
/** /**