mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-02 04:08:31 +08:00
Fix memory leak in worker due to message retry map (#12878)
This commit is contained in:
parent
feb077035e
commit
403c6a6bb6
@ -28,6 +28,7 @@ import org.apache.commons.collections.MapUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -108,11 +109,19 @@ public class MessageRetryRunner extends BaseDaemonThread {
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
for (Map.Entry<Integer, Map<CommandType, BaseCommand>> taskEntry : needToRetryMessages.entrySet()) {
|
||||
Iterator<Map.Entry<Integer, Map<CommandType, BaseCommand>>> iterator =
|
||||
needToRetryMessages.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Integer, Map<CommandType, BaseCommand>> taskEntry = iterator.next();
|
||||
Integer taskInstanceId = taskEntry.getKey();
|
||||
Map<CommandType, BaseCommand> retryMessageMap = taskEntry.getValue();
|
||||
if (retryMessageMap.isEmpty()) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
LoggerUtils.setTaskInstanceIdMDC(taskInstanceId);
|
||||
try {
|
||||
for (Map.Entry<CommandType, BaseCommand> messageEntry : taskEntry.getValue().entrySet()) {
|
||||
for (Map.Entry<CommandType, BaseCommand> messageEntry : retryMessageMap.entrySet()) {
|
||||
CommandType messageType = messageEntry.getKey();
|
||||
BaseCommand message = messageEntry.getValue();
|
||||
if (now - message.getMessageSendTime() > MESSAGE_RETRY_WINDOW) {
|
||||
|
Loading…
Reference in New Issue
Block a user