HDFS-17024. Potential data race introduced by HDFS-15865 (#6223)
This commit is contained in:
parent
652908519e
commit
93a3c6e2cd
@ -476,6 +476,7 @@ boolean doWaitForRestart() {
|
||||
private DataOutputStream blockStream;
|
||||
private DataInputStream blockReplyStream;
|
||||
private ResponseProcessor response = null;
|
||||
private final Object nodesLock = new Object();
|
||||
private volatile DatanodeInfo[] nodes = null; // list of targets for current block
|
||||
private volatile StorageType[] storageTypes = null;
|
||||
private volatile String[] storageIDs = null;
|
||||
@ -619,7 +620,9 @@ private void setPipeline(LocatedBlock lb) {
|
||||
|
||||
private void setPipeline(DatanodeInfo[] nodes, StorageType[] storageTypes,
|
||||
String[] storageIDs) {
|
||||
this.nodes = nodes;
|
||||
synchronized (nodesLock) {
|
||||
this.nodes = nodes;
|
||||
}
|
||||
this.storageTypes = storageTypes;
|
||||
this.storageIDs = storageIDs;
|
||||
}
|
||||
@ -916,7 +919,10 @@ void waitForAckedSeqno(long seqno) throws IOException {
|
||||
try (TraceScope ignored = dfsClient.getTracer().
|
||||
newScope("waitForAckedSeqno")) {
|
||||
LOG.debug("{} waiting for ack for: {}", this, seqno);
|
||||
int dnodes = nodes != null ? nodes.length : 3;
|
||||
int dnodes;
|
||||
synchronized (nodesLock) {
|
||||
dnodes = nodes != null ? nodes.length : 3;
|
||||
}
|
||||
int writeTimeout = dfsClient.getDatanodeWriteTimeout(dnodes);
|
||||
long begin = Time.monotonicNow();
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user