This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new a47dcf39c5 avoid some exception in middle retry (#6433)
a47dcf39c5 is described below
commit a47dcf39c5adb6f2aca897001ada08423da99960
Author: Jialin Qiao <[email protected]>
AuthorDate: Sat Jun 25 12:37:00 2022 +0800
avoid some exception in middle retry (#6433)
---
.../client/SyncConfigNodeClientPool.java | 38 ++++++++++++++--------
.../apache/iotdb/commons/client/ClientManager.java | 2 +-
2 files changed, 25 insertions(+), 15 deletions(-)
diff --git
a/confignode/src/main/java/org/apache/iotdb/confignode/client/SyncConfigNodeClientPool.java
b/confignode/src/main/java/org/apache/iotdb/confignode/client/SyncConfigNodeClientPool.java
index 94890eeee4..1ac87a6764 100644
---
a/confignode/src/main/java/org/apache/iotdb/confignode/client/SyncConfigNodeClientPool.java
+++
b/confignode/src/main/java/org/apache/iotdb/confignode/client/SyncConfigNodeClientPool.java
@@ -66,38 +66,43 @@ public class SyncConfigNodeClientPool {
public TConfigNodeRegisterResp registerConfigNode(
TEndPoint endPoint, TConfigNodeRegisterReq req) {
// TODO: Unified retry logic
+ Throwable lastException = null;
for (int retry = 0; retry < retryNum; retry++) {
try (SyncConfigNodeIServiceClient client =
clientManager.borrowClient(endPoint)) {
return client.registerConfigNode(req);
} catch (Exception e) {
- LOGGER.warn("Register ConfigNode failed, retrying {}...", retry, e);
+ lastException = e;
+ LOGGER.warn("Register ConfigNode failed because {}, retrying {}...",
e.getMessage(), retry);
doRetryWait(retry);
}
}
- LOGGER.error("Register ConfigNode failed");
+ LOGGER.error("Register ConfigNode failed", lastException);
return new TConfigNodeRegisterResp()
.setStatus(
new TSStatus(TSStatusCode.ALL_RETRY_FAILED.getStatusCode())
- .setMessage("All retry failed."));
+ .setMessage("All retry failed due to " +
lastException.getMessage()));
}
public TSStatus addConsensusGroup(
TEndPoint endPoint, List<TConfigNodeLocation> configNodeLocation) {
// TODO: Unified retry logic
+ Throwable lastException = null;
for (int retry = 0; retry < retryNum; retry++) {
try (SyncConfigNodeIServiceClient client =
clientManager.borrowClient(endPoint)) {
TConfigNodeRegisterResp registerResp = new TConfigNodeRegisterResp();
registerResp.setConfigNodeList(configNodeLocation);
registerResp.setStatus(StatusUtils.OK);
return client.addConsensusGroup(registerResp);
- } catch (Exception e) {
- LOGGER.warn("Add Consensus Group failed, retrying {} ...", retry, e);
+ } catch (Throwable e) {
+ lastException = e;
+ LOGGER.warn(
+ "Add Consensus Group failed because {}, retrying {} ...",
e.getMessage(), retry);
doRetryWait(retry);
}
}
- LOGGER.error("Add ConsensusGroup failed");
+ LOGGER.error("Add ConsensusGroup failed", lastException);
return new TSStatus(TSStatusCode.ALL_RETRY_FAILED.getStatusCode())
- .setMessage("All retry failed.");
+ .setMessage("All retry failed due to " + lastException.getMessage());
}
/**
@@ -110,6 +115,7 @@ public class SyncConfigNodeClientPool {
public TSStatus removeConfigNode(
List<TConfigNodeLocation> configNodeLocations, TConfigNodeLocation
configNodeLocation) {
// TODO: Unified retry logic
+ Throwable lastException = null;
for (TConfigNodeLocation nodeLocation : configNodeLocations) {
for (int retry = 0; retry < retryNum; retry++) {
try (SyncConfigNodeIServiceClient client =
@@ -124,33 +130,37 @@ public class SyncConfigNodeClientPool {
}
}
return status;
- } catch (Exception e) {
- LOGGER.warn("Remove ConfigNode failed, retrying...", e);
+ } catch (Throwable e) {
+ lastException = e;
+ LOGGER.warn(
+ "Remove ConfigNode failed because {}, retrying {} ...",
e.getMessage(), retry);
doRetryWait(retry);
}
}
}
- LOGGER.error("Remove ConfigNode failed");
+ LOGGER.error("Remove ConfigNode failed", lastException);
return new TSStatus(TSStatusCode.ALL_RETRY_FAILED.getStatusCode())
- .setMessage("All retry failed.");
+ .setMessage("All retry failed due to " + lastException.getMessage());
}
/** Only use stopConfigNode when the ConfigNode is removed. */
public TSStatus stopConfigNode(TConfigNodeLocation configNodeLocation) {
// TODO: Unified retry logic
+ Throwable lastException = null;
for (int retry = 0; retry < retryNum; retry++) {
try (SyncConfigNodeIServiceClient client =
clientManager.borrowClient(configNodeLocation.getInternalEndPoint())) {
return client.stopConfigNode(configNodeLocation);
} catch (Exception e) {
- LOGGER.warn("Stop ConfigNode failed, retrying...", e);
+ lastException = e;
+ LOGGER.warn("Stop ConfigNode failed because {}, retrying {}...",
e.getMessage(), retry);
doRetryWait(retry);
}
}
- LOGGER.error("Stop ConfigNode failed");
+ LOGGER.error("Stop ConfigNode failed", lastException);
return new TSStatus(TSStatusCode.ALL_RETRY_FAILED.getStatusCode())
- .setMessage("All retry failed.");
+ .setMessage("All retry failed due to" + lastException.getMessage());
}
private void doRetryWait(int retryNum) {
diff --git
a/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java
b/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java
index 70bd2edb29..6d12f0cb56 100644
---
a/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java
+++
b/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java
@@ -57,7 +57,7 @@ public class ClientManager<K, V> implements IClientManager<K,
V> {
} catch (Exception e) {
// external doesn't care of other exceptions
String errorMessage = String.format("Borrow client from pool for node %s
failed.", node);
- logger.error(errorMessage, e);
+ logger.warn(errorMessage, e);
throw new IOException(errorMessage, e);
}
return client;