fix buffer alignment and improve error message for failed reads

This commit is contained in:
Saulius Valatka 2023-01-28 21:54:15 +02:00
parent 252a091702
commit 374e40447c
2 changed files with 8 additions and 4 deletions

View File

@ -270,9 +270,13 @@ void IOUringReader::monitorRing()
if (cqe->res < 0)
{
int fd = assert_cast<const LocalFileDescriptor &>(*enqueued.request.descriptor).fd;
failRequest(it, Exception(ErrorCodes::CANNOT_READ_FROM_FILE_DESCRIPTOR,
"Cannot read from file {}: {}", fd, errnoToString(-cqe->res)));
auto req = enqueued.request;
int fd = assert_cast<const LocalFileDescriptor &>(*req.descriptor).fd;
failRequest(it, Exception(
ErrorCodes::CANNOT_READ_FROM_FILE_DESCRIPTOR,
"Failed reading {} bytes at offset {} to address {} from fd {}: {}",
req.size, req.offset, static_cast<void*>(req.buf), fd, errnoToString(-cqe->res)
));
ProfileEvents::increment(ProfileEvents::IOUringCQEsFailed);
io_uring_cqe_seen(&ring, cqe);

View File

@ -90,7 +90,7 @@ std::unique_ptr<ReadBufferFromFileBase> createReadBufferFromFileBase(
throw Exception(ErrorCodes::UNSUPPORTED_METHOD, "io_uring is not supported by this system");
res = std::make_unique<AsynchronousReadBufferFromFileWithDescriptorsCache>(
*reader, settings.priority, filename, buffer_size, actual_flags, existing_memory, alignment, file_size);
*reader, settings.priority, filename, buffer_size, actual_flags, existing_memory, buffer_alignment, file_size);
#else
throw Exception(ErrorCodes::UNSUPPORTED_METHOD, "Read method io_uring is only supported in Linux");
#endif