diff --git a/velox/common/caching/SsdFile.cpp b/velox/common/caching/SsdFile.cpp index 4d15463898202..4cfa7bb1fd8f4 100644 --- a/velox/common/caching/SsdFile.cpp +++ b/velox/common/caching/SsdFile.cpp @@ -492,6 +492,20 @@ bool SsdFile::write( << ", size: " << iovecs.size() << ", offset: " << offset << ", error code: " << errno << ", error string: " << folly::errnoStr(errno); + // 1. The file descriptor fd is not valid. + // 2. The array of buffers iov is null or has a null pointer in it. + // 3. The number of buffers iovcnt is less than 1 or greater than UIO_MAXIOV. + // 4. The offset offset is negative or greater than the size of the file. + auto fd = writeDataFile_->fd(); + VELOX_SSD_CACHE_LOG(ERROR) << " fd " << fd; + int flags = fcntl(fd, F_GETFD); + VELOX_SSD_CACHE_LOG(ERROR) << "fd flags: " << flags << " err: " << folly::errnoStr(errno); + VELOX_SSD_CACHE_LOG(ERROR) << " iovecs "; + for (const auto iovec :iovecs) { + VELOX_SSD_CACHE_LOG(ERROR) << "iov_base == nullptr: " << (iovec.iov_base == nullptr) << " len " << iovec.iov_len; + } + VELOX_SSD_CACHE_LOG(ERROR) << " iovcnt " << iovecs.size(); + VELOX_SSD_CACHE_LOG(ERROR) << " offset " << offset; ++stats_.writeSsdErrors; return false; } diff --git a/velox/common/file/File.h b/velox/common/file/File.h index 294961a32c55e..51a2ccceca72d 100644 --- a/velox/common/file/File.h +++ b/velox/common/file/File.h @@ -191,6 +191,10 @@ class WriteFile { /// be needed to get the exact size written, and this should be able to be /// called after the file close. virtual uint64_t size() const = 0; + + virtual int32_t fd() { + VELOX_NYI("{} is not implemented", __FUNCTION__); + } }; // We currently do a simple implementation for the in-memory files @@ -349,6 +353,11 @@ class LocalWriteFile final : public WriteFile { return size_; } + int32_t fd() { + return fd_; + } + + private: // File descriptor. int32_t fd_{-1};