From 57f7c1c616905cf4ef79e99553af02a52bfc898a Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Wed, 26 May 2021 13:45:49 -0400 Subject: SERVER-56424 Sorter detects and converts out of disk space system error rather than throwing default unnamed error code (cherry picked from commit 044ada4e8958efb1c8e045bb5a6e0702bb0686cf) --- src/mongo/db/sorter/sorter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/mongo/db/sorter/sorter.cpp b/src/mongo/db/sorter/sorter.cpp index 330b3b6cc1f..9b6a49d4752 100644 --- a/src/mongo/db/sorter/sorter.cpp +++ b/src/mongo/db/sorter/sorter.cpp @@ -1132,6 +1132,14 @@ void SortedFileWriter::spill() { try { _file.write(reinterpret_cast(&size), sizeof(size)); _file.write(outBuffer, std::abs(size)); + } catch (const std::system_error& ex) { + if (ex.code() == std::errc::no_space_on_device) { + msgasserted(ErrorCodes::OutOfDiskSpace, + str::stream() << ex.what() << ": " << _fileFullPath); + } + msgasserted(5642403, + str::stream() << "error writing to file \"" << _fileFullPath + << "\": " << sorter::myErrnoWithDescription()); } catch (const std::exception&) { msgasserted(16821, str::stream() << "error writing to file \"" << _fileFullPath -- cgit v1.2.1