mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 19:45:11 +00:00
Fix
This commit is contained in:
parent
b5eddf3c47
commit
22487de34a
@ -56,6 +56,7 @@ FileSegment::FileSegment(
|
|||||||
/// someone will _potentially_ want to download it (after calling getOrSetDownloader()).
|
/// someone will _potentially_ want to download it (after calling getOrSetDownloader()).
|
||||||
case (State::EMPTY):
|
case (State::EMPTY):
|
||||||
{
|
{
|
||||||
|
chassert(key_metadata.lock());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/// DOWNLOADED is used either on initial cache metadata load into memory on server startup
|
/// DOWNLOADED is used either on initial cache metadata load into memory on server startup
|
||||||
@ -65,6 +66,7 @@ FileSegment::FileSegment(
|
|||||||
reserved_size = downloaded_size = size_;
|
reserved_size = downloaded_size = size_;
|
||||||
chassert(fs::file_size(getPathInLocalCache()) == size_);
|
chassert(fs::file_size(getPathInLocalCache()) == size_);
|
||||||
chassert(queue_iterator);
|
chassert(queue_iterator);
|
||||||
|
chassert(key_metadata.lock());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (State::DETACHED):
|
case (State::DETACHED):
|
||||||
@ -91,8 +93,16 @@ String FileSegment::getPathInLocalCache() const
|
|||||||
return getKeyMetadata()->getFileSegmentPath(*this);
|
return getKeyMetadata()->getFileSegmentPath(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSegment::setDownloadState(State state, const FileSegmentGuard::Lock &)
|
void FileSegment::setDownloadState(State state, const FileSegmentGuard::Lock & lock)
|
||||||
{
|
{
|
||||||
|
if (isCompleted(false))
|
||||||
|
{
|
||||||
|
throw Exception(
|
||||||
|
ErrorCodes::LOGICAL_ERROR,
|
||||||
|
"Updating state of file segment is not allowed, because it is already completed ({})",
|
||||||
|
getInfoForLogUnlocked(lock));
|
||||||
|
}
|
||||||
|
|
||||||
LOG_TEST(log, "Updated state from {} to {}", stateToString(download_state), stateToString(state));
|
LOG_TEST(log, "Updated state from {} to {}", stateToString(download_state), stateToString(state));
|
||||||
download_state = state;
|
download_state = state;
|
||||||
}
|
}
|
||||||
@ -182,12 +192,13 @@ String FileSegment::getOrSetDownloader()
|
|||||||
if (current_downloader.empty())
|
if (current_downloader.empty())
|
||||||
{
|
{
|
||||||
const auto caller_id = getCallerId();
|
const auto caller_id = getCallerId();
|
||||||
bool allow_new_downloader = download_state == State::EMPTY || download_state == State::PARTIALLY_DOWNLOADED || !caller_id.starts_with("None");
|
bool allow_new_downloader = download_state == State::EMPTY || download_state == State::PARTIALLY_DOWNLOADED;
|
||||||
if (!allow_new_downloader)
|
if (!allow_new_downloader)
|
||||||
return "notAllowed:" + stateToString(download_state);
|
return "notAllowed:" + stateToString(download_state);
|
||||||
|
|
||||||
current_downloader = downloader_id = caller_id;
|
current_downloader = downloader_id = caller_id;
|
||||||
setDownloadState(State::DOWNLOADING, lock);
|
setDownloadState(State::DOWNLOADING, lock);
|
||||||
|
chassert(key_metadata.lock());
|
||||||
}
|
}
|
||||||
|
|
||||||
return current_downloader;
|
return current_downloader;
|
||||||
|
Loading…
Reference in New Issue
Block a user