From 49ee24e824b078b1178fa01c4c5cef7ff3f044de Mon Sep 17 00:00:00 2001 From: BoloniniD Date: Tue, 20 Jul 2021 19:22:41 +0300 Subject: [PATCH] What if we replace unique_lock with shared? --- src/Storages/StorageFile.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Storages/StorageFile.cpp b/src/Storages/StorageFile.cpp index c0ddf8b691f..a00ba3d899d 100644 --- a/src/Storages/StorageFile.cpp +++ b/src/Storages/StorageFile.cpp @@ -302,6 +302,9 @@ public: { if (storage->use_table_fd) { + shared_lock = std::shared_lock(storage->rwlock, getLockTimeout(context)); + if (!shared_lock) + throw Exception("Lock timeout exceeded", ErrorCodes::TIMEOUT_EXCEEDED); storage->table_fd_was_used = true; } else @@ -510,9 +513,10 @@ Pipe StorageFile::read( { throw Exception("File descriptor isn't seekable, inside " + this_ptr->getName(), ErrorCodes::CANNOT_SEEK_THROUGH_FILE); } - ReadBufferFromFileDescriptorPRead table_fd_seek(this_ptr->table_fd); - off_t new_pos = table_fd_seek.seek(this_ptr->table_fd_init_offset, SEEK_SET); - lseek(this_ptr->table_fd, this_ptr->table_fd_init_offset, new_pos); + if (lseek(this_ptr->table_fd, this_ptr->table_fd_init_offset, SEEK_SET) < 0) + { + throw Exception("File descriptor isn't seekable, inside " + this_ptr->getName(), ErrorCodes::CANNOT_SEEK_THROUGH_FILE); + } } else {