From 889f54b5494503ece17e7e8c79c75671a18a8f74 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 13 May 2020 01:21:40 +0300 Subject: [PATCH] Fix ENOENT exception on current_batch.txt in DirectoryMonitor current_batch.txt will not exist if there was no send, this is the case when all batches that was pending has been marked as pending. --- src/Storages/Distributed/DirectoryMonitor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Storages/Distributed/DirectoryMonitor.cpp b/src/Storages/Distributed/DirectoryMonitor.cpp index d83fbd84b4b..2a5e47fdf04 100644 --- a/src/Storages/Distributed/DirectoryMonitor.cpp +++ b/src/Storages/Distributed/DirectoryMonitor.cpp @@ -666,7 +666,10 @@ void StorageDistributedDirectoryMonitor::processFilesWithBatching(const std::map batch.send(); } - Poco::File{current_batch_file_path}.remove(); + /// current_batch.txt will not exist if there was no send + /// (this is the case when all batches that was pending has been marked as pending) + if (Poco::File{current_batch_file_path}.exists()) + Poco::File{current_batch_file_path}.remove(); } bool StorageDistributedDirectoryMonitor::isFileBrokenErrorCode(int code)