From 33df4f5470cf260f675c356379b82180c40e5877 Mon Sep 17 00:00:00 2001 From: justinwwhuang Date: Wed, 8 Nov 2023 11:30:22 +0800 Subject: [PATCH] [INLONG-9233][Agent] Fix bug: source, proxy, sender get stuck (#9234) --- .../inlong/agent/plugin/sinks/filecollect/ProxySink.java | 2 +- .../agent/plugin/sinks/filecollect/SenderManager.java | 6 ++++-- .../apache/inlong/agent/plugin/sources/LogFileSource.java | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sinks/filecollect/ProxySink.java b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sinks/filecollect/ProxySink.java index 30bbf2d9569..806612e661d 100755 --- a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sinks/filecollect/ProxySink.java +++ b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sinks/filecollect/ProxySink.java @@ -71,7 +71,7 @@ public void write(Message message) { return; } boolean suc = false; - while (!suc) { + while (running && !suc) { suc = putInCache(message); if (!suc) { AgentUtils.silenceSleepInMs(WRITE_FAILED_WAIT_TIME_MS); diff --git a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sinks/filecollect/SenderManager.java b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sinks/filecollect/SenderManager.java index a0e4d46c7fe..5112471d777 100755 --- a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sinks/filecollect/SenderManager.java +++ b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sinks/filecollect/SenderManager.java @@ -246,11 +246,13 @@ private void createMessageSender(String tagName) throws Exception { } public void sendBatch(SenderMessage message) { - while (!resendQueue.isEmpty()) { + while (!shutdown && !resendQueue.isEmpty()) { AgentUtils.silenceSleepInMs(retrySleepTime); } addAckInfo(message.getAckInfo()); - sendBatchWithRetryCount(message, 0); + if (!shutdown) { + sendBatchWithRetryCount(message, 0); + } } private void addAckInfo(PackageAckInfo info) { diff --git a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/LogFileSource.java b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/LogFileSource.java index c056b3aae1b..5cbec1efda9 100755 --- a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/LogFileSource.java +++ b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/LogFileSource.java @@ -378,7 +378,7 @@ private boolean waitForPermit(String permitName, int permitLen) { suc = MemoryManager.getInstance().tryAcquire(permitName, permitLen); if (!suc) { MemoryManager.getInstance().printDetail(permitName, "log file source"); - if (!isRunnable()) { + if (!isInodeChanged() || !isRunnable()) { return false; } AgentUtils.silenceSleepInSeconds(1);