Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
30b34e6a
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,发现更多精彩内容 >>
提交
30b34e6a
编写于
7月 16, 2020
作者:
V
Vitaly Baranov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use SettingSeconds only in Settings, use std::chrono::seconds in other places.
上级
b76b23ce
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
14 deletion
+22
-14
src/Core/SettingsCollection.h
src/Core/SettingsCollection.h
+10
-1
src/Databases/DatabaseMySQL.cpp
src/Databases/DatabaseMySQL.cpp
+1
-2
src/Storages/IStorage.cpp
src/Storages/IStorage.cpp
+6
-6
src/Storages/IStorage.h
src/Storages/IStorage.h
+4
-4
src/Storages/System/StorageSystemColumns.cpp
src/Storages/System/StorageSystemColumns.cpp
+1
-1
未找到文件。
src/Core/SettingsCollection.h
浏览文件 @
30b34e6a
...
...
@@ -106,7 +106,13 @@ struct SettingTimespan
SettingTimespan
(
UInt64
x
=
0
)
:
value
(
x
*
microseconds_per_io_unit
)
{}
operator
Poco
::
Timespan
()
const
{
return
value
;
}
SettingTimespan
&
operator
=
(
const
Poco
::
Timespan
&
x
)
{
set
(
x
);
return
*
this
;
}
SettingTimespan
&
operator
=
(
const
Poco
::
Timespan
&
x
)
{
set
(
x
);
return
*
this
;
}
template
<
class
Rep
,
class
Period
=
std
::
ratio
<
1
>
>
operator
std
::
chrono
::
duration
<
Rep
,
Period
>
()
const
{
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
duration
<
Rep
,
Period
>>
(
std
::
chrono
::
microseconds
(
value
.
totalMicroseconds
()));
}
template
<
class
Rep
,
class
Period
=
std
::
ratio
<
1
>
>
SettingTimespan
&
operator
=
(
const
std
::
chrono
::
duration
<
Rep
,
Period
>
&
x
)
{
set
(
x
);
return
*
this
;
}
Poco
::
Timespan
::
TimeDiff
totalSeconds
()
const
{
return
value
.
totalSeconds
();
}
Poco
::
Timespan
::
TimeDiff
totalMilliseconds
()
const
{
return
value
.
totalMilliseconds
();
}
...
...
@@ -116,6 +122,9 @@ struct SettingTimespan
void
set
(
const
Poco
::
Timespan
&
x
);
template
<
class
Rep
,
class
Period
=
std
::
ratio
<
1
>
>
void
set
(
const
std
::
chrono
::
duration
<
Rep
,
Period
>
&
duration
)
{
set
(
static_cast
<
UInt64
>
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
duration
).
count
()));
}
void
set
(
UInt64
x
);
void
set
(
const
Field
&
x
);
void
set
(
const
String
&
x
);
...
...
src/Databases/DatabaseMySQL.cpp
浏览文件 @
30b34e6a
...
...
@@ -4,7 +4,6 @@
#if USE_MYSQL
# include <string>
# include <Core/SettingsCollection.h>
# include <DataTypes/DataTypeDateTime.h>
# include <DataTypes/DataTypeNullable.h>
# include <DataTypes/DataTypeString.h>
...
...
@@ -42,7 +41,7 @@ namespace ErrorCodes
constexpr
static
const
auto
suffix
=
".remove_flag"
;
static
constexpr
const
std
::
chrono
::
seconds
cleaner_sleep_time
{
30
};
static
const
SettingS
econds
lock_acquire_timeout
{
10
};
static
const
std
::
chrono
::
s
econds
lock_acquire_timeout
{
10
};
static
String
toQueryStringWithQuote
(
const
std
::
vector
<
String
>
&
quote_list
)
{
...
...
src/Storages/IStorage.cpp
浏览文件 @
30b34e6a
...
...
@@ -31,22 +31,22 @@ bool IStorage::isVirtualColumn(const String & column_name, const StorageMetadata
}
RWLockImpl
::
LockHolder
IStorage
::
tryLockTimed
(
const
RWLock
&
rwlock
,
RWLockImpl
::
Type
type
,
const
String
&
query_id
,
const
SettingS
econds
&
acquire_timeout
)
const
const
RWLock
&
rwlock
,
RWLockImpl
::
Type
type
,
const
String
&
query_id
,
const
std
::
chrono
::
millis
econds
&
acquire_timeout
)
const
{
auto
lock_holder
=
rwlock
->
getLock
(
type
,
query_id
,
std
::
chrono
::
milliseconds
(
acquire_timeout
.
totalMilliseconds
())
);
auto
lock_holder
=
rwlock
->
getLock
(
type
,
query_id
,
acquire_timeout
);
if
(
!
lock_holder
)
{
const
String
type_str
=
type
==
RWLockImpl
::
Type
::
Read
?
"READ"
:
"WRITE"
;
throw
Exception
(
type_str
+
" locking attempt on
\"
"
+
getStorageID
().
getFullTableName
()
+
"
\"
has timed out! ("
+
toString
(
acquire_timeout
.
totalMilliseconds
())
+
"ms) "
"
\"
has timed out! ("
+
std
::
to_string
(
acquire_timeout
.
count
())
+
"ms) "
"Possible deadlock avoided. Client should retry."
,
ErrorCodes
::
DEADLOCK_AVOIDED
);
}
return
lock_holder
;
}
TableLockHolder
IStorage
::
lockForShare
(
const
String
&
query_id
,
const
SettingS
econds
&
acquire_timeout
)
TableLockHolder
IStorage
::
lockForShare
(
const
String
&
query_id
,
const
std
::
chrono
::
millis
econds
&
acquire_timeout
)
{
TableLockHolder
result
=
tryLockTimed
(
drop_lock
,
RWLockImpl
::
Read
,
query_id
,
acquire_timeout
);
...
...
@@ -56,7 +56,7 @@ TableLockHolder IStorage::lockForShare(const String & query_id, const SettingSec
return
result
;
}
TableLockHolder
IStorage
::
lockForAlter
(
const
String
&
query_id
,
const
SettingS
econds
&
acquire_timeout
)
TableLockHolder
IStorage
::
lockForAlter
(
const
String
&
query_id
,
const
std
::
chrono
::
millis
econds
&
acquire_timeout
)
{
TableLockHolder
result
=
tryLockTimed
(
alter_lock
,
RWLockImpl
::
Write
,
query_id
,
acquire_timeout
);
...
...
@@ -67,7 +67,7 @@ TableLockHolder IStorage::lockForAlter(const String & query_id, const SettingSec
}
TableExclusiveLockHolder
IStorage
::
lockExclusively
(
const
String
&
query_id
,
const
SettingS
econds
&
acquire_timeout
)
TableExclusiveLockHolder
IStorage
::
lockExclusively
(
const
String
&
query_id
,
const
std
::
chrono
::
millis
econds
&
acquire_timeout
)
{
TableExclusiveLockHolder
result
;
result
.
alter_lock
=
tryLockTimed
(
alter_lock
,
RWLockImpl
::
Write
,
query_id
,
acquire_timeout
);
...
...
src/Storages/IStorage.h
浏览文件 @
30b34e6a
...
...
@@ -185,18 +185,18 @@ private:
MultiVersionStorageMetadataPtr
metadata
;
private:
RWLockImpl
::
LockHolder
tryLockTimed
(
const
RWLock
&
rwlock
,
RWLockImpl
::
Type
type
,
const
String
&
query_id
,
const
SettingS
econds
&
acquire_timeout
)
const
;
const
RWLock
&
rwlock
,
RWLockImpl
::
Type
type
,
const
String
&
query_id
,
const
std
::
chrono
::
millis
econds
&
acquire_timeout
)
const
;
public:
/// Lock table for share. This lock must be acuqired if you want to be sure,
/// that table will be not dropped while you holding this lock. It's used in
/// variety of cases starting from SELECT queries to background merges in
/// MergeTree.
TableLockHolder
lockForShare
(
const
String
&
query_id
,
const
SettingS
econds
&
acquire_timeout
);
TableLockHolder
lockForShare
(
const
String
&
query_id
,
const
std
::
chrono
::
millis
econds
&
acquire_timeout
);
/// Lock table for alter. This lock must be acuqired in ALTER queries to be
/// sure, that we execute only one simultaneous alter. Doesn't affect share lock.
TableLockHolder
lockForAlter
(
const
String
&
query_id
,
const
SettingS
econds
&
acquire_timeout
);
TableLockHolder
lockForAlter
(
const
String
&
query_id
,
const
std
::
chrono
::
millis
econds
&
acquire_timeout
);
/// Lock table exclusively. This lock must be acuired if you want to be
/// sure, that no other thread (SELECT, merge, ALTER, etc.) doing something
...
...
@@ -205,7 +205,7 @@ public:
///
/// NOTE: You have to be 100% sure that you need this lock. It's extremely
/// heavyweight and makes table irresponsive.
TableExclusiveLockHolder
lockExclusively
(
const
String
&
query_id
,
const
SettingS
econds
&
acquire_timeout
);
TableExclusiveLockHolder
lockExclusively
(
const
String
&
query_id
,
const
std
::
chrono
::
millis
econds
&
acquire_timeout
);
/** Returns stage to which query is going to be processed in read() function.
* (Normally, the function only reads the columns from the list, but in other cases,
...
...
src/Storages/System/StorageSystemColumns.cpp
浏览文件 @
30b34e6a
...
...
@@ -236,7 +236,7 @@ private:
size_t
total_tables
;
std
::
shared_ptr
<
const
ContextAccess
>
access
;
String
query_id
;
SettingS
econds
lock_acquire_timeout
;
std
::
chrono
::
millis
econds
lock_acquire_timeout
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录