public boolean shouldAddAgain(String fileName, long lastModifyTime) {
        InstanceProfile profileFromStore = instanceStore.getInstance(taskId, fileName);
        if (profileFromStore == null) {
            LOGGER.debug("not in instance store should add {}", fileName);
            return true;
        } else {
            InstanceStateEnum state = profileFromStore.getState();
            if (state == InstanceStateEnum.FINISHED && lastModifyTime > profileFromStore.getModifyTime()) {
                LOGGER.debug("finished but file update again {}", fileName);
                return true;
            }
            if (state == InstanceStateEnum.DELETE) {
                LOGGER.debug("delete and add again {}", fileName);
                return true;
            }
            return false;
        }
    }
add instance to memory, if there is a record refer to the instance id exist we need to destroy it first.
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/instance/InstanceManager.java