HDFS-18324. Fix race condition in closing IPC connections. (#5371)

This commit is contained in:
Owen O'Malley 2023-02-10 09:51:03 -08:00 committed by GitHub
parent 151b71d7af
commit 26fba8701c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -1181,7 +1181,14 @@ public void sendRpcRequest(final Call call)
final ResponseBuffer buf = new ResponseBuffer();
header.writeDelimitedTo(buf);
RpcWritable.wrap(call.rpcRequest).writeTo(buf);
rpcRequestQueue.put(Pair.of(call, buf));
// Wait for the message to be sent. We offer with timeout to
// prevent a race condition between checking the shouldCloseConnection
// and the stopping of the polling thread
while (!shouldCloseConnection.get()) {
if (rpcRequestQueue.offer(Pair.of(call, buf), 1, TimeUnit.SECONDS)) {
break;
}
}
}
/* Receive a response.

View File

@ -1336,7 +1336,7 @@ interface DummyProtocol {
/**
* Test the retry count while used in a retry proxy.
*/
@Test(timeout=60000)
@Test(timeout=100000)
public void testRetryProxy() throws IOException {
final Client client = new Client(LongWritable.class, conf);