Skip to content

Commit 97e0a03

Browse files
committed
Slightly better
1 parent 32686e1 commit 97e0a03

6 files changed

+16
-10
lines changed

src/Disks/DiskWebServer.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void DiskWebServer::Metadata::initialize(const String & uri_with_path, const Str
5151
assertChar('\t', metadata_buf);
5252
readIntText(file_size, metadata_buf);
5353
assertChar('\n', metadata_buf);
54-
LOG_DEBUG(&Poco::Logger::get("DiskWeb"), "Read file: {}, size: {}", remote_file_name, file_size);
54+
LOG_TRACE(&Poco::Logger::get("DiskWeb"), "Read file: {}, size: {}", remote_file_name, file_size);
5555

5656
/*
5757
* URI/ {uri}/{uuid}/all_x_x_x/{file}
@@ -227,7 +227,7 @@ bool DiskWebServer::findFileInMetadata(const String & path, File & file_info) co
227227

228228
bool DiskWebServer::exists(const String & path) const
229229
{
230-
LOG_DEBUG(log, "Checking existence of file: {}", path);
230+
LOG_TRACE(log, "Checking existence of file: {}", path);
231231

232232
File file;
233233
return findFileInMetadata(path, file);
@@ -243,7 +243,7 @@ std::unique_ptr<ReadBufferFromFileBase> DiskWebServer::readFile(const String & p
243243

244244
auto file_name = escapeForFileName(fs::path(path).stem()) + fs::path(path).extension().string();
245245
auto remote_path = fs::path(path).parent_path() / file_name;
246-
LOG_DEBUG(log, "Read from file by path: {}", remote_path.string());
246+
LOG_TRACE(log, "Read from file by path: {}", remote_path.string());
247247

248248
RemoteMetadata meta(uri, remote_path);
249249
meta.remote_fs_objects.emplace_back(std::make_pair(getFileName(remote_path), file.size));
@@ -255,7 +255,7 @@ std::unique_ptr<ReadBufferFromFileBase> DiskWebServer::readFile(const String & p
255255

256256
DiskDirectoryIteratorPtr DiskWebServer::iterateDirectory(const String & path)
257257
{
258-
LOG_DEBUG(log, "Iterate directory: {}", path);
258+
LOG_TRACE(log, "Iterate directory: {}", path);
259259
String uuid;
260260

261261
if (RE2::FullMatch(path, ".*/store/"))

src/Interpreters/InterpreterAlterQuery.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ BlockIO InterpreterAlterQuery::execute()
6363
}
6464

6565
StoragePtr table = DatabaseCatalog::instance().getTable(table_id, getContext());
66-
if (table->isReadOnly())
66+
if (table->isStaticStorage())
6767
throw Exception(ErrorCodes::TABLE_IS_READ_ONLY, "Table is read-only");
6868
auto alter_lock = table->lockForAlter(getContext()->getCurrentQueryId(), getContext()->getSettingsRef().lock_acquire_timeout);
6969
auto metadata_snapshot = table->getInMemoryMetadataPtr();

src/Interpreters/InterpreterDropQuery.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ BlockIO InterpreterDropQuery::executeToTableImpl(ASTDropQuery & query, DatabaseP
163163
if (query.kind == ASTDropQuery::Kind::Detach)
164164
{
165165
getContext()->checkAccess(drop_storage, table_id);
166-
if (table->isReadOnly())
166+
if (table->isStaticStorage())
167167
throw Exception(ErrorCodes::TABLE_IS_READ_ONLY, "Table is read-only");
168168

169169
if (table->isDictionary())
@@ -198,7 +198,7 @@ BlockIO InterpreterDropQuery::executeToTableImpl(ASTDropQuery & query, DatabaseP
198198
throw Exception("Cannot TRUNCATE dictionary", ErrorCodes::SYNTAX_ERROR);
199199

200200
getContext()->checkAccess(AccessType::TRUNCATE, table_id);
201-
if (table->isReadOnly())
201+
if (table->isStaticStorage())
202202
throw Exception(ErrorCodes::TABLE_IS_READ_ONLY, "Table is read-only");
203203

204204
table->checkTableCanBeDropped();

src/Storages/IStorage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ NameDependencies IStorage::getDependentViewsByColumn(ContextPtr context) const
201201
return name_deps;
202202
}
203203

204-
bool IStorage::isReadOnly() const
204+
bool IStorage::isStaticStorage() const
205205
{
206206
auto storage_policy = getStoragePolicy();
207207
if (storage_policy)

src/Storages/IStorage.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ class IStorage : public std::enable_shared_from_this<IStorage>, public TypePromo
540540
virtual StoragePolicyPtr getStoragePolicy() const { return {}; }
541541

542542
/// Returns true if all disks of storage are read-only.
543-
virtual bool isReadOnly() const;
543+
virtual bool isStaticStorage() const;
544544

545545
/// If it is possible to quickly determine exact number of rows in the table at this moment of time, then return it.
546546
/// Used for:

src/Storages/StorageMergeTree.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ void StorageMergeTree::startup()
113113
time_after_previous_cleanup_parts.restart();
114114
time_after_previous_cleanup_temporary_directories.restart();
115115

116+
/// Do not schedule any background jobs if current storage has static data files.
117+
if (isStaticStorage())
118+
return;
119+
116120
try
117121
{
118122
background_executor.start();
@@ -243,7 +247,7 @@ void StorageMergeTree::drop()
243247
{
244248
shutdown();
245249
/// In case there is read-only disk we cannot allow to call dropAllData(), but dropping tables is allowed.
246-
if (isReadOnly())
250+
if (isStaticStorage())
247251
return;
248252
dropAllData();
249253
}
@@ -1049,6 +1053,8 @@ bool StorageMergeTree::scheduleDataProcessingJob(IBackgroundJobExecutor & execut
10491053
if (shutdown_called)
10501054
return false;
10511055

1056+
assert(!isStaticStorage());
1057+
10521058
auto metadata_snapshot = getInMemoryMetadataPtr();
10531059
std::shared_ptr<MergeMutateSelectedEntry> merge_entry, mutate_entry;
10541060

0 commit comments

Comments
 (0)