From 985cd9440231d5b6eab574ed8fc6a6f3a197d7dd Mon Sep 17 00:00:00 2001 From: Denis Khalikov Date: Thu, 27 Jun 2024 16:24:45 +0300 Subject: [PATCH] fix(join, disk-based): MCOL-5597: large side read errors (#3117) (#3225) The large side read errors mentioned there can be due to failure to close file stream properly. Some of the data may still reside in the file stream buffers, closing must flush it. The flush is an I/O operation and can fail, leading to partial write and subsequent partial read. This patch tries to provide better diagnostics. Co-authored-by: Sergey Zefirov <72864488+mariadb-SergeyZefirov@users.noreply.github.com> --- utils/joiner/joinpartition.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/joiner/joinpartition.cpp b/utils/joiner/joinpartition.cpp index 2b2b8ed4e..bccf89b38 100644 --- a/utils/joiner/joinpartition.cpp +++ b/utils/joiner/joinpartition.cpp @@ -854,7 +854,15 @@ uint64_t JoinPartition::writeByteStream(int which, ByteStream& bs) bs.advance(len); offset = fs.tellp(); + fs.close(); + + if (fs.fail()) + { + ostringstream os; + os << "Disk join file " << filename << ": close() failure, probable exhaustion of disk space." << endl; + throw IDBExcept(os.str().c_str(), ERR_DBJ_FILE_IO_ERROR); + } return ret; }