New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make local object storage work consistently with s3 object storage, fix problem with append, make it configurable as independent storage #48791
Make local object storage work consistently with s3 object storage, fix problem with append, make it configurable as independent storage #48791
Conversation
9934483
to
9374666
Compare
@@ -1,14 +0,0 @@ | |||
cached_azure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this test because it is impossible to make it not flaky with custom nested (cached) disk configuration which I used in test tests/queries/0_stateless/02714_local_object_storage.sql
CurrentThread::isInitialized() && CurrentThread::get().getQueryContext() ? std::string(CurrentThread::getQueryId()) : "", | ||
file_size.value(), | ||
/* allow_seeks */true, | ||
/* use_external_buffer */false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this code because it is not needed when local object storage works the same way as s3 object storage (and in this PR is starts to), as cache is added on the different layer.
@@ -54,53 +51,6 @@ std::mutex DiskLocal::reservation_mutex; | |||
|
|||
using DiskLocalPtr = std::shared_ptr<DiskLocal>; | |||
|
|||
static void loadDiskLocalConfig(const String & name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is just moved to a separate file, see src/Disks/loadLocalDiskConfig.cpp
…o better-local-object-storage
…o better-local-object-storage
This is an automated comment for commit 35f437a with description of existing statuses. It's updated for the latest CI running
|
@@ -367,7 +367,13 @@ class IDisk : public Space | |||
/// Actually it's a part of IDiskRemote implementation but we have so | |||
/// complex hierarchy of disks (with decorators), so we cannot even | |||
/// dynamic_cast some pointer to IDisk to pointer to IDiskRemote. | |||
virtual MetadataStoragePtr getMetadataStorage() = 0; | |||
virtual MetadataStoragePtr getMetadataStorage() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have implementation now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because no need to require implementation of this method from all disks, only from DiskObjectStorage, so it is ok to throw NOT_IMPLEMENTED here.
@@ -59,7 +59,7 @@ ReadSettings CachedObjectStorage::patchSettings(const ReadSettings & read_settin | |||
if (!canUseReadThroughCache()) | |||
modified_settings.read_from_filesystem_cache_if_exists_otherwise_bypass_cache = true; | |||
|
|||
return IObjectStorage::patchSettings(modified_settings); | |||
return object_storage->patchSettings(modified_settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it was a bug before this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, it did not affect anything, when readObjects is passed to inner object storage (s3) it will apply it's own patch settings for its read.
@@ -18,31 +18,14 @@ struct StoredObject | |||
|
|||
uint64_t bytes_size = 0; | |||
|
|||
std::string getPathKeyForCache() const; | |||
|
|||
const std::string & getMappedPath() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have getter for mapped path and don't have getter for absolute path? Maybe it should be const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have getter for mapped path and don't have getter for absolute path?
fixed
Maybe it should be const
copy assignment operator does not work then
fs::copy(from, to, fs::copy_options::recursive | fs::copy_options::overwrite_existing); | ||
auto in = readObject(object_from); | ||
auto out = writeObject(object_to, WriteMode::Rewrite); | ||
copyData(*in, *out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to read/write? Why we cannot copy blob from object_from
to object_to
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the point is to not use std::filesystem::copy (for #42337)
LOG_TEST(log, "Write object: {}", path); | ||
return std::make_unique<WriteBufferFromFile>(path, buf_size, flags); | ||
if (mode != WriteMode::Rewrite) | ||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "LocalObjectStorage doesn't support append to files"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be really surprizing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as in S3ObjectStorage, they are consistent now.
@@ -47,30 +50,39 @@ std::unique_ptr<ReadBufferFromFileBase> LocalObjectStorage::readObjects( /// NOL | |||
std::optional<size_t> read_hint, | |||
std::optional<size_t> file_size) const | |||
{ | |||
if (objects.size() != 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should still have this check since we banned append in write?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, append is not banned, it is now implemented same as in s3, which means that here objects.size() != 1
in case append was made.
@@ -7,9 +7,6 @@ | |||
#include <Common/logger_useful.h> | |||
#include <Common/setThreadName.h> | |||
#include <Core/ServerUUID.h> | |||
#include <Disks/ObjectStorages/MetadataStorageFromDisk.h> | |||
#include <Disks/ObjectStorages/FakeMetadataStorageFromDisk.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can remove whole FakeMetadataStorageFromDisk
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed!
@@ -660,7 +660,6 @@ class IColumn; | |||
M(Bool, enable_filesystem_cache_on_write_operations, false, "Write into cache on write operations. To actually work this setting requires be added to disk config too", 0) \ | |||
M(Bool, enable_filesystem_cache_log, false, "Allows to record the filesystem caching log for each query", 0) \ | |||
M(Bool, read_from_filesystem_cache_if_exists_otherwise_bypass_cache, false, "Allow to use the filesystem cache in passive mode - benefit from the existing cache entries, but don't put more entries into the cache. If you set this setting for heavy ad-hoc queries and leave it disabled for short real-time queries, this will allows to avoid cache threshing by too heavy queries and to improve the overall system efficiency.", 0) \ | |||
M(Bool, enable_filesystem_cache_on_lower_level, true, "If read buffer supports caching inside threadpool, allow it to do it, otherwise cache outside ot threadpool. Do not use this setting, it is needed for testing", 0) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like it.
@@ -35,6 +36,8 @@ inline String toString(DataSourceType data_source_type) | |||
return "web"; | |||
case DataSourceType::AzureBlobStorage: | |||
return "azure_blob_storage"; | |||
case DataSourceType::LocalBlobStorage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like now it's impossible to create cache on top of <type>local</type>
. Not a popular feature, but need to mention in changelog.
std::string generateBlobNameForPath(const std::string & path) override { return path; } | ||
|
||
std::string getUniqueId(const std::string & path) const override; | ||
std::string generateBlobNameForPath(const std::string & path) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this function can be 100% the same for all object storages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For local no, because it will require to create subdirectories.
343d44f
to
35f437a
Compare
Need to address stress test failure, rest is LGTM |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Make local object storage work consistently with s3 object storage, fix problem with append (closes #48465), make it configurable as independent storage. The change is backward incompatible because cache on top of local object storage is not incompatible to previous versions.