This commit is contained in:
kssenii 2022-03-10 19:16:26 +01:00
parent d54b0779e9
commit ddcb020d26
2 changed files with 17 additions and 4 deletions

View File

@ -27,12 +27,12 @@ namespace ErrorCodes
extern const int PATH_ACCESS_DENIED;;
extern const int FILE_DOESNT_EXIST;
extern const int BAD_FILE_TYPE;
extern const int MEMORY_LIMIT_EXCEEDED;
}
IDiskRemote::Metadata IDiskRemote::Metadata::readMetadata(const String & remote_fs_root_path_, DiskPtr metadata_disk_, const String & metadata_file_path_)
{
Metadata result(remote_fs_root_path_, metadata_disk_, metadata_file_path_);
result.load();
return result;
@ -140,6 +140,9 @@ void IDiskRemote::Metadata::load()
if (e.code() == ErrorCodes::UNKNOWN_FORMAT)
throw;
if (e.code() == ErrorCodes::MEMORY_LIMIT_EXCEEDED)
throw;
throw Exception("Failed to read metadata file", e, ErrorCodes::UNKNOWN_FORMAT);
}
}

View File

@ -485,6 +485,9 @@ bool CachedReadBufferFromRemoteFS::updateImplementationBufferIfNeeded()
bool CachedReadBufferFromRemoteFS::nextImpl()
{
if (IFileCache::shouldBypassCache())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Using cache when not allowed");
if (!initialized)
initialize(file_offset_of_buffer_end, getTotalSizeToRead());
@ -500,9 +503,16 @@ bool CachedReadBufferFromRemoteFS::nextImpl()
bool download_current_segment = read_type == ReadType::REMOTE_FS_READ_AND_PUT_IN_CACHE;
if (download_current_segment)
{
bool file_segment_already_completed = !file_segment->isDownloader();
if (!file_segment_already_completed)
file_segment->completeBatchAndResetDownloader();
try
{
bool file_segment_already_completed = !file_segment->isDownloader();
if (!file_segment_already_completed)
file_segment->completeBatchAndResetDownloader();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
}
assert(!file_segment->isDownloader());