Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
fa865636
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa865636
编写于
5月 10, 2018
作者:
Z
zhang2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ISSUES-2259 add comment & move delete database metadata implementation
上级
c8f655c1
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
43 addition
and
17 deletion
+43
-17
dbms/src/Common/ZooKeeper/Types.h
dbms/src/Common/ZooKeeper/Types.h
+3
-1
dbms/src/Databases/DatabaseDictionary.cpp
dbms/src/Databases/DatabaseDictionary.cpp
+5
-0
dbms/src/Databases/DatabaseDictionary.h
dbms/src/Databases/DatabaseDictionary.h
+2
-0
dbms/src/Databases/DatabaseMemory.cpp
dbms/src/Databases/DatabaseMemory.cpp
+5
-0
dbms/src/Databases/DatabaseMemory.h
dbms/src/Databases/DatabaseMemory.h
+2
-0
dbms/src/Databases/DatabaseOrdinary.cpp
dbms/src/Databases/DatabaseOrdinary.cpp
+5
-0
dbms/src/Databases/DatabaseOrdinary.h
dbms/src/Databases/DatabaseOrdinary.h
+1
-0
dbms/src/Databases/IDatabase.h
dbms/src/Databases/IDatabase.h
+13
-4
dbms/src/Interpreters/InterpreterDropQuery.cpp
dbms/src/Interpreters/InterpreterDropQuery.cpp
+1
-6
dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
...c/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
+2
-2
dbms/src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp
dbms/src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp
+2
-2
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+2
-2
未找到文件。
dbms/src/Common/ZooKeeper/Types.h
浏览文件 @
fa865636
...
...
@@ -54,8 +54,10 @@ using SetResponse = ZooKeeperImpl::ZooKeeper::SetResponse;
using
ListResponse
=
ZooKeeperImpl
::
ZooKeeper
::
ListResponse
;
using
CheckResponse
=
ZooKeeperImpl
::
ZooKeeper
::
CheckResponse
;
/// Gets multiple asynchronous results
/// Each pair, the first is path, the second is response eg. CreateResponse, RemoveResponse
template
<
typename
R
>
using
MultiAsyncResponse
=
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
future
<
R
>>>
;
using
AsyncResponses
=
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
future
<
R
>>>
;
RequestPtr
makeCreateRequest
(
const
std
::
string
&
path
,
const
std
::
string
&
data
,
int
create_mode
);
RequestPtr
makeRemoveRequest
(
const
std
::
string
&
path
,
int
version
);
...
...
dbms/src/Databases/DatabaseDictionary.cpp
浏览文件 @
fa865636
...
...
@@ -213,4 +213,9 @@ void DatabaseDictionary::shutdown()
{
}
String
DatabaseDictionary
::
getDatabaseName
()
const
{
return
name
;
}
}
dbms/src/Databases/DatabaseDictionary.h
浏览文件 @
fa865636
...
...
@@ -25,6 +25,8 @@ class DatabaseDictionary : public IDatabase
public:
DatabaseDictionary
(
const
String
&
name_
,
const
Context
&
context
);
String
getDatabaseName
()
const
override
;
String
getEngineName
()
const
override
{
return
"Dictionary"
;
...
...
dbms/src/Databases/DatabaseMemory.cpp
浏览文件 @
fa865636
...
...
@@ -78,4 +78,9 @@ ASTPtr DatabaseMemory::getCreateDatabaseQuery(
throw
Exception
(
"There is no CREATE DATABASE query for DatabaseMemory"
,
ErrorCodes
::
CANNOT_GET_CREATE_TABLE_QUERY
);
}
String
DatabaseMemory
::
getDatabaseName
()
const
{
return
name
;
}
}
dbms/src/Databases/DatabaseMemory.h
浏览文件 @
fa865636
...
...
@@ -19,6 +19,8 @@ class DatabaseMemory : public DatabaseWithOwnTablesBase
public:
DatabaseMemory
(
String
name_
);
String
getDatabaseName
()
const
override
;
String
getEngineName
()
const
override
{
return
"Memory"
;
}
void
loadTables
(
...
...
dbms/src/Databases/DatabaseOrdinary.cpp
浏览文件 @
fa865636
...
...
@@ -570,6 +570,11 @@ String DatabaseOrdinary::getMetadataPath() const
return
metadata_path
;
}
String
DatabaseOrdinary
::
getDatabaseName
()
const
{
return
name
;
}
String
DatabaseOrdinary
::
getTableMetadataPath
(
const
String
&
table_name
)
const
{
return
detail
::
getTableMetadataPath
(
metadata_path
,
table_name
);
...
...
dbms/src/Databases/DatabaseOrdinary.h
浏览文件 @
fa865636
...
...
@@ -59,6 +59,7 @@ public:
ASTPtr
getCreateDatabaseQuery
(
const
Context
&
context
)
const
override
;
String
getDataPath
()
const
override
;
String
getDatabaseName
()
const
override
;
String
getMetadataPath
()
const
override
;
String
getTableMetadataPath
(
const
String
&
table_name
)
const
override
;
...
...
dbms/src/Databases/IDatabase.h
浏览文件 @
fa865636
...
...
@@ -7,6 +7,8 @@
#include <memory>
#include <functional>
#include <Poco/File.h>
#include <Common/escapeForFileName.h>
#include <Interpreters/Context.h>
class
ThreadPool
;
...
...
@@ -133,6 +135,7 @@ public:
/// Get the CREATE DATABASE query for current database.
virtual
ASTPtr
getCreateDatabaseQuery
(
const
Context
&
context
)
const
=
0
;
virtual
String
getDatabaseName
()
const
{
return
{};
}
/// Returns path for persistent data storage if the database supports it, empty string otherwise
virtual
String
getDataPath
()
const
{
return
{};
}
/// Returns metadata path if the database supports it, empty string otherwise
...
...
@@ -144,11 +147,17 @@ public:
virtual
void
shutdown
()
=
0
;
/// Delete metadata, the deletion of which differs from the recursive deletion of the directory, if any.
virtual
void
drop
()
virtual
void
drop
(
Context
&
context
)
{
String
metadata_path
=
getMetadataPath
();
if
(
!
metadata_path
.
empty
())
Poco
::
File
(
metadata_path
).
remove
(
false
);
String
database_name
=
getDatabaseName
();
String
database_name_escaped
=
escapeForFileName
(
database_name
);
Poco
::
File
(
context
.
getPath
()
+
"metadata/"
+
database_name_escaped
+
"/"
).
remove
(
false
);
/// Old ClickHouse versions did not store database.sql files
Poco
::
File
database_metadata_file
(
context
.
getPath
()
+
"metadata/"
+
database_name_escaped
+
".sql"
);
if
(
database_metadata_file
.
exists
())
database_metadata_file
.
remove
(
false
);
};
virtual
~
IDatabase
()
{}
...
...
dbms/src/Interpreters/InterpreterDropQuery.cpp
浏览文件 @
fa865636
...
...
@@ -168,17 +168,12 @@ BlockIO InterpreterDropQuery::executeToDatabase(String & database_name, ASTDropQ
database
->
shutdown
();
/// Delete the database.
database
->
drop
();
database
->
drop
(
context
);
/// Remove data directory if it is not virtual database. TODO: should IDatabase::drop() do that?
String
database_data_path
=
database
->
getDataPath
();
if
(
!
database_data_path
.
empty
())
Poco
::
File
(
database_data_path
).
remove
(
false
);
/// Old ClickHouse versions did not store database.sql files
Poco
::
File
database_metadata_file
(
context
.
getPath
()
+
"metadata/"
+
escapeForFileName
(
database_name
)
+
".sql"
);
if
(
database_metadata_file
.
exists
())
database_metadata_file
.
remove
(
false
);
}
}
...
...
dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
浏览文件 @
fa865636
...
...
@@ -157,7 +157,7 @@ void ReplicatedMergeTreeCleanupThread::clearOldBlocks()
auto
first_outdated_block_time_threshold
=
std
::
upper_bound
(
timed_blocks
.
begin
(),
timed_blocks
.
end
(),
block_threshold
,
NodeWithStat
::
greaterByTime
);
auto
first_outdated_block
=
std
::
min
(
first_outdated_block_fixed_threshold
,
first_outdated_block_time_threshold
);
zkutil
::
MultiAsyncResponse
<
zkutil
::
RemoveResponse
>
try_remove_futures
;
zkutil
::
AsyncResponses
<
zkutil
::
RemoveResponse
>
try_remove_futures
;
for
(
auto
it
=
first_outdated_block
;
it
!=
timed_blocks
.
end
();
++
it
)
{
String
path
=
storage
.
zookeeper_path
+
"/blocks/"
+
it
->
node
;
...
...
@@ -212,7 +212,7 @@ void ReplicatedMergeTreeCleanupThread::getBlocksSortedByTime(zkutil::ZooKeeper &
<<
" to clear old ones from ZooKeeper."
);
}
zkutil
::
MultiAsyncResponse
<
zkutil
::
ExistsResponse
>
exists_futures
;
zkutil
::
AsyncResponses
<
zkutil
::
ExistsResponse
>
exists_futures
;
for
(
const
String
&
block
:
blocks
)
{
auto
it
=
cached_block_stats
.
find
(
block
);
...
...
dbms/src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp
浏览文件 @
fa865636
...
...
@@ -53,7 +53,7 @@ bool ReplicatedMergeTreeQueue::load(zkutil::ZooKeeperPtr zookeeper)
std
::
sort
(
children
.
begin
(),
children
.
end
());
zkutil
::
MultiAsyncResponse
<
zkutil
::
GetResponse
>
futures
;
zkutil
::
AsyncResponses
<
zkutil
::
GetResponse
>
futures
;
futures
.
reserve
(
children
.
size
());
for
(
const
String
&
child
:
children
)
...
...
@@ -315,7 +315,7 @@ bool ReplicatedMergeTreeQueue::pullLogsToQueue(zkutil::ZooKeeperPtr zookeeper, B
LOG_DEBUG
(
log
,
"Pulling "
<<
(
end
-
begin
)
<<
" entries to queue: "
<<
*
begin
<<
" - "
<<
*
last
);
zkutil
::
MultiAsyncResponse
<
zkutil
::
GetResponse
>
futures
;
zkutil
::
AsyncResponses
<
zkutil
::
GetResponse
>
futures
;
futures
.
reserve
(
end
-
begin
);
for
(
auto
it
=
begin
;
it
!=
end
;
++
it
)
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
fa865636
...
...
@@ -3736,7 +3736,7 @@ void StorageReplicatedMergeTree::clearBlocksInPartition(
throw
Exception
(
zookeeper_path
+
"/blocks doesn't exist"
,
ErrorCodes
::
NOT_FOUND_NODE
);
String
partition_prefix
=
partition_id
+
"_"
;
zkutil
::
MultiAsyncResponse
<
zkutil
::
GetResponse
>
get_futures
;
zkutil
::
AsyncResponses
<
zkutil
::
GetResponse
>
get_futures
;
for
(
const
String
&
block_id
:
blocks
)
{
if
(
startsWith
(
block_id
,
partition_prefix
))
...
...
@@ -3746,7 +3746,7 @@ void StorageReplicatedMergeTree::clearBlocksInPartition(
}
}
zkutil
::
MultiAsyncResponse
<
zkutil
::
RemoveResponse
>
to_delete_futures
;
zkutil
::
AsyncResponses
<
zkutil
::
RemoveResponse
>
to_delete_futures
;
for
(
auto
&
pair
:
get_futures
)
{
const
String
&
path
=
pair
.
first
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录