Hopefully better

This commit is contained in:
Alexey Milovidov 2024-04-27 18:47:03 +02:00
parent 5610260399
commit 39118ef461
4 changed files with 17 additions and 14 deletions

View File

@ -249,15 +249,14 @@ void LocalServer::tryInitPath()
LOG_DEBUG(log, "Working directory created: {}", path);
}
fs::create_directories(config().getString("user_defined_path", fs::path(path) / "user_defined/"));
fs::create_directories(fs::path(path) / "data/");
fs::create_directories(fs::path(path) / "metadata/");
fs::create_directories(fs::path(path) / "metadata_dropped/");
fs::create_directories(config().getString("user_defined_path", fs::path(path) / "user_defined" / ""));
fs::create_directories(fs::path(path) / "data" / "");
fs::create_directories(fs::path(path) / "metadata" / "");
global_context->setPath(fs::path(path) / "");
global_context->setTemporaryStoragePath(fs::path(path) / "tmp/", 0);
global_context->setFlagsPath(fs::path(path) / "flags");
global_context->setTemporaryStoragePath(fs::path(path) / "tmp" / "", 0);
global_context->setFlagsPath(fs::path(path) / "flags" / "");
global_context->setUserFilesPath(""); /// user's files are everywhere

View File

@ -1205,11 +1205,11 @@ try
}
{
fs::create_directories(path / "data/");
fs::create_directories(path / "metadata/");
fs::create_directories(path / "data");
fs::create_directories(path / "metadata");
/// Directory with metadata of tables, which was marked as dropped by Atomic database
fs::create_directories(path / "metadata_dropped/");
fs::create_directories(path / "metadata_dropped");
}
if (config().has("interserver_http_port") && config().has("interserver_https_port"))

View File

@ -137,6 +137,9 @@ void DatabaseAtomic::dropTableImpl(ContextPtr local_context, const String & tabl
std::lock_guard lock(mutex);
table = getTableUnlocked(table_name);
table_metadata_path_drop = DatabaseCatalog::instance().getPathForDroppedMetadata(table->getStorageID());
fs::create_directory(fs::path(table_metadata_path_drop).parent_path());
auto txn = local_context->getZooKeeperMetadataTransaction();
if (txn && !local_context->isInternalSubquery())
txn->commit(); /// Commit point (a sort of) for Replicated database

View File

@ -988,7 +988,7 @@ void DatabaseCatalog::loadMarkedAsDroppedTables()
/// we should load them and enqueue cleanup to remove data from store/ and metadata from ZooKeeper
std::map<String, StorageID> dropped_metadata;
String path = getContext()->getPath() + "metadata_dropped/";
String path = std::filesystem::path(getContext()->getPath()) / "metadata_dropped" / "";
if (!std::filesystem::exists(path))
{
@ -1043,10 +1043,11 @@ void DatabaseCatalog::loadMarkedAsDroppedTables()
String DatabaseCatalog::getPathForDroppedMetadata(const StorageID & table_id) const
{
return getContext()->getPath() + "metadata_dropped/" +
escapeForFileName(table_id.getDatabaseName()) + "." +
escapeForFileName(table_id.getTableName()) + "." +
toString(table_id.uuid) + ".sql";
return std::filesystem::path(getContext()->getPath()) / "metadata_dropped" /
fmt::format("{}.{}.{}.sql",
escapeForFileName(table_id.getDatabaseName()),
escapeForFileName(table_id.getTableName()),
toString(table_id.uuid));
}
String DatabaseCatalog::getPathForMetadata(const StorageID & table_id) const