Skip to content

Commit ad448bc

Browse files
luoluoyuyuJackieTien97
authored andcommitted
Pipe: Prevent duplicate error logging in AsyncPipeDataTransferServiceClient (#16856)
* Fix: Prevent duplicate error logging in AsyncPipeDataTransferServiceClient - Change printLogWhenEncounterException from final to mutable field - Set printLogWhenEncounterException to false in onError() to avoid repeated error logs - This prevents flooding logs when client encounters errors * update (cherry picked from commit f4d628a)
1 parent bb55dd6 commit ad448bc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/thrift/async/handler/PipeTransferTrackableHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public void onComplete(final TPipeTransferResp response) {
6464
public void onError(final Exception exception) {
6565
if (client != null) {
6666
ThriftClient.resolveException(exception, client);
67+
client.setPrintLogWhenEncounterException(false);
6768
}
6869

6970
if (connector.isClosed()) {

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncPipeDataTransferServiceClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class AsyncPipeDataTransferServiceClient extends IClientRPCService.AsyncC
4949
private static final AtomicInteger idGenerator = new AtomicInteger(0);
5050
private final int id = idGenerator.incrementAndGet();
5151

52-
private final boolean printLogWhenEncounterException;
52+
private boolean printLogWhenEncounterException;
5353

5454
private final TEndPoint endpoint;
5555
private final ClientManager<TEndPoint, AsyncPipeDataTransferServiceClient> clientManager;
@@ -85,6 +85,7 @@ public void onComplete() {
8585
public void onError(final Exception e) {
8686
super.onError(e);
8787
ThriftClient.resolveException(e, this);
88+
setPrintLogWhenEncounterException(false);
8889
returnSelf(
8990
(i) -> i instanceof IllegalStateException && "Client has an error!".equals(i.getMessage()));
9091
}
@@ -106,6 +107,10 @@ public boolean printLogWhenEncounterException() {
106107
return printLogWhenEncounterException;
107108
}
108109

110+
public void setPrintLogWhenEncounterException(final boolean printLogWhenEncounterException) {
111+
this.printLogWhenEncounterException = printLogWhenEncounterException;
112+
}
113+
109114
/**
110115
* return self, the method doesn't need to be called by the user and will be triggered after the
111116
* RPC is finished.

0 commit comments

Comments
 (0)