HDFS-14751. Synchronize on diffs in DirectoryScanner. Contributed by Lisheng Sun.
This commit is contained in:
parent
313b76f8e9
commit
ecd461f940
@ -349,7 +349,9 @@ public class DirectoryScanner implements Runnable {
|
||||
* Clear the current cache of diffs and statistics.
|
||||
*/
|
||||
private void clear() {
|
||||
synchronized (diffs) {
|
||||
diffs.clear();
|
||||
}
|
||||
stats.clear();
|
||||
}
|
||||
|
||||
@ -430,6 +432,7 @@ public class DirectoryScanner implements Runnable {
|
||||
// HDFS-14476: run checkAndUpadte with batch to avoid holding the lock too
|
||||
// long
|
||||
int loopCount = 0;
|
||||
synchronized (diffs) {
|
||||
for (final Map.Entry<String, ScanInfo> entry : diffs.getEntries()) {
|
||||
dataset.checkAndUpdate(entry.getKey(), entry.getValue());
|
||||
|
||||
@ -442,6 +445,7 @@ public class DirectoryScanner implements Runnable {
|
||||
}
|
||||
loopCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!retainDiffs) {
|
||||
clear();
|
||||
@ -545,7 +549,9 @@ public class DirectoryScanner implements Runnable {
|
||||
}
|
||||
d++;
|
||||
}
|
||||
synchronized (diffs) {
|
||||
diffs.addAll(bpid, diffRecord);
|
||||
}
|
||||
LOG.info("Scan Results: {}", statsRecord);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user