Skip to content

Commit 82098e9

Browse files
committed
Fix stress test
1 parent 9ecbff2 commit 82098e9

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

src/Storages/MergeTree/DataPartStorageOnDiskFull.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,20 @@ UInt32 DataPartStorageOnDiskFull::getRefCount(const String & file_name) const
9595
return volume->getDisk()->getRefCount(fs::path(root_path) / part_dir / file_name);
9696
}
9797

98-
std::string DataPartStorageOnDiskFull::getRemotePath(const std::string & file_name) const
98+
std::string DataPartStorageOnDiskFull::getRemotePath(const std::string & file_name, bool if_exists) const
9999
{
100-
auto objects = volume->getDisk()->getStorageObjects(fs::path(root_path) / part_dir / file_name);
100+
const std::string path = fs::path(root_path) / part_dir / file_name;
101+
auto objects = volume->getDisk()->getStorageObjects(path);
102+
103+
if (objects.empty() && if_exists)
104+
return "";
105+
101106
if (objects.size() != 1)
102-
throw Exception(ErrorCodes::LOGICAL_ERROR, "One file must be mapped to one object on blob storage in MergeTree tables");
107+
{
108+
throw Exception(ErrorCodes::LOGICAL_ERROR,
109+
"One file must be mapped to one object on blob storage by path {} in MergeTree tables, have {}.",
110+
path, objects.size());
111+
}
103112

104113
return objects[0].remote_path;
105114
}

src/Storages/MergeTree/DataPartStorageOnDiskFull.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DataPartStorageOnDiskFull final : public DataPartStorageOnDiskBase
2323
Poco::Timestamp getFileLastModified(const String & file_name) const override;
2424
size_t getFileSize(const std::string & file_name) const override;
2525
UInt32 getRefCount(const std::string & file_name) const override;
26-
std::string getRemotePath(const std::string & file_name) const override;
26+
std::string getRemotePath(const std::string & file_name, bool is_exists) const override;
2727
String getUniqueId() const override;
2828

2929
std::unique_ptr<ReadBufferFromFileBase> readFile(

src/Storages/MergeTree/IDataPartStorage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class IDataPartStorage : public boost::noncopyable
126126
virtual UInt32 getRefCount(const std::string & file_name) const = 0;
127127

128128
/// Get path on remote filesystem from file name on local filesystem.
129-
virtual std::string getRemotePath(const std::string & file_name) const = 0;
129+
virtual std::string getRemotePath(const std::string & file_name, bool if_exists) const = 0;
130130

131131
virtual UInt64 calculateTotalSizeOnDisk() const = 0;
132132

src/Storages/MergeTree/checkDataPart.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,16 @@ IMergeTreeDataPart::Checksums checkDataPart(
377377
auto file_name = it->name();
378378
if (!data_part_storage.isDirectory(file_name))
379379
{
380-
auto remote_path = data_part_storage.getRemotePath(file_name);
380+
const bool is_projection_part = data_part->isProjectionPart();
381+
auto remote_path = data_part_storage.getRemotePath(file_name, /* if_exists */is_projection_part);
382+
if (remote_path.empty())
383+
{
384+
chassert(is_projection_part);
385+
throw Exception(
386+
ErrorCodes::BROKEN_PROJECTION,
387+
"Remote path for {} does not exist for projection path. Projection {} is broken",
388+
file_name, data_part->name);
389+
}
381390
cache.removePathIfExists(remote_path, FileCache::getCommonUser().user_id);
382391
}
383392
}

0 commit comments

Comments
 (0)