pread return OB_SUCCESS when read offset is equal to file length.

This commit is contained in:
HaHaJeff
2023-07-25 14:42:37 +00:00
committed by ob-robot
parent ce2579a7d6
commit 7b37f56021
4 changed files with 22 additions and 6 deletions

View File

@ -182,9 +182,12 @@ int ObLogExternalStorageHandler::pread(const common::ObString &uri,
CLOG_LOG(WARN, "ObLogExternalStorageHandler invalid argument", K(uri), K(storage_info), K(offset), KP(buf), K(read_buf_size));
} else if (OB_FAIL(handle_adapter_->get_file_size(uri, storage_info, file_size))) {
CLOG_LOG(WARN, "get_file_size failed", K(uri), K(storage_info), K(offset), KP(buf), K(read_buf_size));
} else if (offset >= file_size) {
ret = OB_INVALID_ARGUMENT;
} else if (offset > file_size) {
ret = OB_FILE_LENGTH_INVALID;
CLOG_LOG(WARN, "read position lager than file size, invalid argument", K(file_size), K(offset), K(uri));
} else if (offset == file_size) {
real_read_size = 0;
CLOG_LOG(TRACE, "read position equal to file size, no need read data", K(file_size), K(offset), K(uri));
} else if (FALSE_IT(time_guard.click("after get file size"))) {
// NB: limit read size.
} else if (FALSE_IT(real_read_buf_size = std::min(file_size - offset, read_buf_size))) {

View File

@ -92,6 +92,7 @@ public:
// OB_BACKUP_PERMISSION_DENIED, permission denied.
// OB_BACKUP_FILE_NOT_EXIST, uri not exist.
// OB_OSS_ERROR, oss error.
// OB_FILE_LENGTH_INVALID, read offset is greater than file size.
// OB_NOT_INIT
// OB_NOT_RUNNING
//

View File

@ -336,7 +336,7 @@ int ObLogExternalStorageIOTaskHandleAdapter::pread(const ObString &uri,
const int64_t read_buf_size,
int64_t &real_read_size)
{
ObTimeGuard time_guard("oss pread", 100 * 1000);
ObTimeGuard time_guard("storage pread", 100 * 1000);
int ret = OB_SUCCESS;
real_read_size = 0;
ObIODevice *io_device = NULL;