Skip to content

Commit ddeb23b

Browse files
authored
[To dev/1.3] Pipe Log: Reduce repeatable logs (#17700) (#17793)
Backport the non-i18n log reduction part of b616502.
1 parent 5d4277a commit ddeb23b

7 files changed

Lines changed: 61 additions & 38 deletions

File tree

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/client/IoTDBDataNodeAsyncClientManager.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,12 @@ public AsyncPipeDataTransferServiceClient borrowClient(final TEndPoint endPoint)
193193
return client;
194194
}
195195
} catch (final Exception e) {
196-
LOGGER.warn(
197-
"failed to borrow client {}:{} for cached leader.",
196+
PipeLogger.log(
197+
LOGGER::warn,
198+
e,
199+
"Failed to borrow client %s:%s for cached leader.",
198200
endPoint.getIp(),
199-
endPoint.getPort(),
200-
e);
201+
endPoint.getPort());
201202
}
202203

203204
return borrowClient();
@@ -342,11 +343,12 @@ public void onError(final Exception e) {
342343
client.close();
343344
client.invalidateAll();
344345
} catch (final Exception e) {
345-
LOGGER.warn(
346-
"Failed to close client {}:{} after handshake failure when the manager is closed.",
346+
PipeLogger.log(
347+
LOGGER::warn,
348+
e,
349+
"Failed to close client %s:%s after handshake failure when the manager is closed.",
347350
targetNodeUrl.getIp(),
348-
targetNodeUrl.getPort(),
349-
e);
351+
targetNodeUrl.getPort());
350352
}
351353
}
352354
client.setShouldReturnSelf(true);

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/pipeconsensus/handler/PipeConsensusTabletBatchEventHandler.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2323
import org.apache.iotdb.commons.client.async.AsyncPipeConsensusServiceClient;
2424
import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
25+
import org.apache.iotdb.commons.pipe.resource.log.PipeLogger;
2526
import org.apache.iotdb.consensus.pipe.thrift.TPipeConsensusBatchTransferReq;
2627
import org.apache.iotdb.consensus.pipe.thrift.TPipeConsensusBatchTransferResp;
2728
import org.apache.iotdb.consensus.pipe.thrift.TPipeConsensusTransferResp;
@@ -116,17 +117,20 @@ public void onComplete(final TPipeConsensusBatchTransferResp response) {
116117

117118
@Override
118119
public void onError(final Exception exception) {
119-
LOGGER.warn(
120-
"PipeConsensus: Failed to transfer TabletInsertionEvent batch. Total failed events: {}, related pipe names: {}",
121-
events.size(),
120+
final Object pipeNames =
122121
events.stream()
123122
.map(
124123
event ->
125124
event instanceof EnrichedEvent
126125
? ((EnrichedEvent) event).getPipeName()
127126
: "UNKNOWN")
128-
.collect(Collectors.toSet()),
129-
exception);
127+
.collect(Collectors.toSet());
128+
PipeLogger.log(
129+
LOGGER::warn,
130+
exception,
131+
"PipeConsensus: Failed to transfer TabletInsertionEvent batch. Total failed events: %s, related pipe names: %s",
132+
events.size(),
133+
pipeNames);
130134

131135
connector.addFailureEventsToRetryQueue(events);
132136
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/pipeconsensus/handler/PipeConsensusTabletInsertionEventHandler.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2323
import org.apache.iotdb.commons.client.async.AsyncPipeConsensusServiceClient;
2424
import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
25+
import org.apache.iotdb.commons.pipe.resource.log.PipeLogger;
2526
import org.apache.iotdb.consensus.pipe.thrift.TPipeConsensusTransferReq;
2627
import org.apache.iotdb.consensus.pipe.thrift.TPipeConsensusTransferResp;
2728
import org.apache.iotdb.db.pipe.consensus.PipeConsensusSinkMetrics;
@@ -106,14 +107,21 @@ public void onComplete(TPipeConsensusTransferResp response) {
106107

107108
@Override
108109
public void onError(Exception exception) {
109-
LOGGER.warn(
110-
"Failed to transfer TabletInsertionEvent {} (committer key={}, commit id={}).",
110+
final Object eventReportMessage =
111111
event instanceof EnrichedEvent
112112
? ((EnrichedEvent) event).coreReportMessage()
113-
: event.toString(),
114-
event instanceof EnrichedEvent ? ((EnrichedEvent) event).getCommitterKey() : null,
115-
event instanceof EnrichedEvent ? ((EnrichedEvent) event).getCommitId() : null,
116-
exception);
113+
: event.toString();
114+
final Object committerKey =
115+
event instanceof EnrichedEvent ? ((EnrichedEvent) event).getCommitterKey() : null;
116+
final Object commitId =
117+
event instanceof EnrichedEvent ? ((EnrichedEvent) event).getCommitId() : null;
118+
PipeLogger.log(
119+
LOGGER::warn,
120+
exception,
121+
"Failed to transfer TabletInsertionEvent %s (committer key=%s, commit id=%s).",
122+
eventReportMessage,
123+
committerKey,
124+
commitId);
117125

118126
connector.addFailureEventToRetryQueue(event);
119127
metric.recordRetryCounter();

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/pipeconsensus/handler/PipeConsensusTsFileInsertionEventHandler.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2424
import org.apache.iotdb.commons.client.async.AsyncPipeConsensusServiceClient;
2525
import org.apache.iotdb.commons.pipe.config.PipeConfig;
26+
import org.apache.iotdb.commons.pipe.resource.log.PipeLogger;
2627
import org.apache.iotdb.commons.pipe.sink.payload.pipeconsensus.response.PipeConsensusTransferFilePieceResp;
2728
import org.apache.iotdb.consensus.pipe.thrift.TCommitId;
2829
import org.apache.iotdb.consensus.pipe.thrift.TPipeConsensusTransferResp;
@@ -273,12 +274,13 @@ public void onComplete(final TPipeConsensusTransferResp response) {
273274

274275
@Override
275276
public void onError(final Exception exception) {
276-
LOGGER.warn(
277-
"Failed to transfer TsFileInsertionEvent {} (committer key {}, commit id {}).",
277+
PipeLogger.log(
278+
LOGGER::warn,
279+
exception,
280+
"Failed to transfer TsFileInsertionEvent %s (committer key %s, commit id %s).",
278281
tsFile,
279282
event.getCommitterKey(),
280-
event.getCommitId(),
281-
exception);
283+
event.getCommitId());
282284

283285
try {
284286
if (reader != null) {

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private void transferInBatchWithoutCheck(
258258
false));
259259
}
260260
} catch (final Exception e) {
261-
LOGGER.warn("Failed to transfer tsfile batch ({}).", sealedFiles, e);
261+
PipeLogger.log(LOGGER::warn, e, "Failed to transfer tsfile batch (%s).", sealedFiles);
262262
if (eventsHadBeenAddedToRetryQueue.compareAndSet(false, true)) {
263263
addFailureEventsToRetryQueue(events, e);
264264
}
@@ -437,17 +437,19 @@ private void transfer(final PipeTransferTsFileHandler pipeTransferTsFileHandler)
437437
} catch (final Exception e) {
438438
if (e instanceof InterruptedException) {
439439
Thread.currentThread().interrupt();
440-
LOGGER.warn(
441-
"Transfer tsfile event {} asynchronously was interrupted.",
442-
pipeTransferTsFileHandler.getTsFile(),
443-
e);
440+
PipeLogger.log(
441+
LOGGER::warn,
442+
e,
443+
"Transfer tsfile event %s asynchronously was interrupted.",
444+
pipeTransferTsFileHandler.getTsFile());
444445
}
445446

446447
pipeTransferTsFileHandler.onError(e);
447-
LOGGER.warn(
448-
"Failed to transfer tsfile event {} asynchronously.",
449-
pipeTransferTsFileHandler.getTsFile(),
450-
e);
448+
PipeLogger.log(
449+
LOGGER::warn,
450+
e,
451+
"Failed to transfer tsfile event %s asynchronously.",
452+
pipeTransferTsFileHandler.getTsFile());
451453
}
452454
}
453455
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.iotdb.commons.client.ThriftClient;
2323
import org.apache.iotdb.commons.client.async.AsyncPipeDataTransferServiceClient;
24+
import org.apache.iotdb.commons.pipe.resource.log.PipeLogger;
2425
import org.apache.iotdb.commons.pipe.sink.payload.thrift.common.PipeTransferSliceReqBuilder;
2526
import org.apache.iotdb.db.pipe.sink.protocol.thrift.async.IoTDBDataRegionAsyncSink;
2627
import org.apache.iotdb.pipe.api.exception.PipeConnectionException;
@@ -105,7 +106,8 @@ protected boolean tryTransfer(
105106
client.returnSelf(
106107
(e) -> {
107108
if (e instanceof IllegalStateException) {
108-
LOGGER.info(
109+
PipeLogger.log(
110+
LOGGER::info,
109111
"Illegal state when return the client to object pool, maybe the pool is already cleared. Will ignore.");
110112
return true;
111113
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ public void transfer(
157157
this.client = client;
158158

159159
if (client == null) {
160-
LOGGER.warn(
161-
"Client has been returned to the pool. Current handler status is {}. Will not transfer {}.",
160+
PipeLogger.log(
161+
LOGGER::warn,
162+
"Client has been returned to the pool. Current handler status is %s. Will not transfer %s.",
162163
sink.isClosed() ? "CLOSED" : "NOT CLOSED",
163164
tsFile);
164165
return;
@@ -420,7 +421,8 @@ private void returnClientIfNecessary() {
420421
client.returnSelf(
421422
(e) -> {
422423
if (e instanceof IllegalStateException) {
423-
LOGGER.info(
424+
PipeLogger.log(
425+
LOGGER::info,
424426
"Illegal state when return the client to object pool, maybe the pool is already cleared. Will ignore.");
425427
return true;
426428
}
@@ -434,8 +436,9 @@ protected void doTransfer(
434436
final AsyncPipeDataTransferServiceClient client, final TPipeTransferReq req)
435437
throws TException {
436438
if (client == null) {
437-
LOGGER.warn(
438-
"Client has been returned to the pool. Current handler status is {}. Will not transfer {}.",
439+
PipeLogger.log(
440+
LOGGER::warn,
441+
"Client has been returned to the pool. Current handler status is %s. Will not transfer %s.",
439442
sink.isClosed() ? "CLOSED" : "NOT CLOSED",
440443
tsFile);
441444
return;

0 commit comments

Comments
 (0)