From ebcf43a5172910b02c3c82129c1962bbb0a061c9 Mon Sep 17 00:00:00 2001 From: Sergey Zefirov <72864488+mariadb-SergeyZefirov@users.noreply.github.com> Date: Fri, 9 Feb 2024 22:25:43 +0300 Subject: [PATCH] fix(join, disk-based): MCOL-5597: large side read errors (#3117) 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. --- utils/joiner/joinpartition.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/joiner/joinpartition.cpp b/utils/joiner/joinpartition.cpp index 6db3ade42..6db0810cf 100644 --- a/utils/joiner/joinpartition.cpp +++ b/utils/joiner/joinpartition.cpp @@ -849,7 +849,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; }