Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
a83343d4
Incubator Pegasus
项目概览
apache
/
Incubator Pegasus
通知
9
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Incubator Pegasus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a83343d4
编写于
9月 07, 2020
作者:
Z
Zhang Yifan
提交者:
heyuchen
9月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: Use default options to open db when latest option file has incompatible db options (#593)
上级
839826d2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
20 deletion
+61
-20
src/server/pegasus_server_impl.cpp
src/server/pegasus_server_impl.cpp
+58
-20
src/server/pegasus_server_impl.h
src/server/pegasus_server_impl.h
+3
-0
未找到文件。
src/server/pegasus_server_impl.cpp
浏览文件 @
a83343d4
...
@@ -1330,9 +1330,18 @@ void pegasus_server_impl::on_clear_scanner(const int64_t &args) { _context_cache
...
@@ -1330,9 +1330,18 @@ void pegasus_server_impl::on_clear_scanner(const int64_t &args) { _context_cache
// Here we create a `tmp_data_cf_opts` because we don't want to modify `_data_cf_opts`, which
// Here we create a `tmp_data_cf_opts` because we don't want to modify `_data_cf_opts`, which
// will be used elsewhere.
// will be used elsewhere.
rocksdb
::
ColumnFamilyOptions
tmp_data_cf_opts
=
_data_cf_opts
;
rocksdb
::
ColumnFamilyOptions
tmp_data_cf_opts
=
_data_cf_opts
;
bool
has_incompatible_db_options
=
false
;
if
(
db_exist
)
{
if
(
db_exist
)
{
// When DB exists, meta CF and data CF must be present.
bool
missing_meta_cf
=
true
;
bool
missing_meta_cf
=
true
;
bool
missing_data_cf
=
true
;
bool
missing_data_cf
=
true
;
if
(
check_column_families
(
path
,
&
missing_meta_cf
,
&
missing_data_cf
)
!=
::
dsn
::
ERR_OK
)
{
derror_replica
(
"check column families failed"
);
return
::
dsn
::
ERR_LOCAL_APP_FAILURE
;
}
dassert_replica
(
!
missing_meta_cf
,
"You must upgrade Pegasus server from 2.0"
);
dassert_replica
(
!
missing_data_cf
,
"Missing data column family"
);
// Load latest options from option file stored in the db directory.
// Load latest options from option file stored in the db directory.
rocksdb
::
DBOptions
loaded_db_opt
;
rocksdb
::
DBOptions
loaded_db_opt
;
std
::
vector
<
rocksdb
::
ColumnFamilyDescriptor
>
loaded_cf_descs
;
std
::
vector
<
rocksdb
::
ColumnFamilyDescriptor
>
loaded_cf_descs
;
...
@@ -1344,28 +1353,31 @@ void pegasus_server_impl::on_clear_scanner(const int64_t &args) { _context_cache
...
@@ -1344,28 +1353,31 @@ void pegasus_server_impl::on_clear_scanner(const int64_t &args) { _context_cache
&
loaded_cf_descs
,
&
loaded_cf_descs
,
/*ignore_unknown_options=*/
true
);
/*ignore_unknown_options=*/
true
);
if
(
!
status
.
ok
())
{
if
(
!
status
.
ok
())
{
derror_replica
(
"load latest option file failed."
);
// Here we ignore an invalid argument error related to `pegasus_data_version` and
return
::
dsn
::
ERR_LOCAL_APP_FAILURE
;
// `pegasus_data` options, which were used in old version rocksdbs (before 2.1.0).
}
if
(
status
.
code
()
!=
rocksdb
::
Status
::
kInvalidArgument
||
for
(
int
i
=
0
;
i
<
loaded_cf_descs
.
size
();
++
i
)
{
status
.
ToString
().
find
(
"pegasus_data"
)
==
std
::
string
::
npos
)
{
if
(
loaded_cf_descs
[
i
].
name
==
META_COLUMN_FAMILY_NAME
)
{
derror_replica
(
"load latest option file failed: {}."
,
status
.
ToString
());
missing_meta_cf
=
false
;
}
else
if
(
loaded_cf_descs
[
i
].
name
==
DATA_COLUMN_FAMILY_NAME
)
{
missing_data_cf
=
false
;
loaded_data_cf_opts
=
loaded_cf_descs
[
i
].
options
;
}
else
{
derror_replica
(
"unknown column family name."
);
return
::
dsn
::
ERR_LOCAL_APP_FAILURE
;
return
::
dsn
::
ERR_LOCAL_APP_FAILURE
;
}
}
has_incompatible_db_options
=
true
;
dwarn_replica
(
"The latest option file has incompatible db options: {}, use default "
"options to open db."
,
status
.
ToString
());
}
if
(
!
has_incompatible_db_options
)
{
for
(
int
i
=
0
;
i
<
loaded_cf_descs
.
size
();
++
i
)
{
if
(
loaded_cf_descs
[
i
].
name
==
DATA_COLUMN_FAMILY_NAME
)
{
loaded_data_cf_opts
=
loaded_cf_descs
[
i
].
options
;
}
}
// Reset usage scenario related options according to loaded_data_cf_opts.
// We don't use `loaded_data_cf_opts` directly because pointer-typed options will
// only be initialized with default values when calling 'LoadLatestOptions', see
// 'rocksdb/utilities/options_util.h'.
reset_usage_scenario_options
(
loaded_data_cf_opts
,
&
tmp_data_cf_opts
);
}
}
// When DB exists, meta CF and data CF must be present.
dassert_replica
(
!
missing_meta_cf
,
"You must upgrade Pegasus server from 2.0"
);
dassert_replica
(
!
missing_data_cf
,
"Missing data column family"
);
// Reset usage scenario related options according to loaded_data_cf_opts.
// We don't use `loaded_data_cf_opts` directly because pointer-typed options will only be
// initialized with default values when calling 'LoadLatestOptions', see
// 'rocksdb/utilities/options_util.h'.
reset_usage_scenario_options
(
loaded_data_cf_opts
,
&
tmp_data_cf_opts
);
}
else
{
}
else
{
// When create new DB, we have to create a new column family to store meta data (meta column
// When create new DB, we have to create a new column family to store meta data (meta column
// family).
// family).
...
@@ -1376,7 +1388,7 @@ void pegasus_server_impl::on_clear_scanner(const int64_t &args) { _context_cache
...
@@ -1376,7 +1388,7 @@ void pegasus_server_impl::on_clear_scanner(const int64_t &args) { _context_cache
{{
DATA_COLUMN_FAMILY_NAME
,
tmp_data_cf_opts
},
{
META_COLUMN_FAMILY_NAME
,
_meta_cf_opts
}});
{{
DATA_COLUMN_FAMILY_NAME
,
tmp_data_cf_opts
},
{
META_COLUMN_FAMILY_NAME
,
_meta_cf_opts
}});
auto
s
=
rocksdb
::
CheckOptionsCompatibility
(
auto
s
=
rocksdb
::
CheckOptionsCompatibility
(
path
,
rocksdb
::
Env
::
Default
(),
_db_opts
,
column_families
,
/*ignore_unknown_options=*/
true
);
path
,
rocksdb
::
Env
::
Default
(),
_db_opts
,
column_families
,
/*ignore_unknown_options=*/
true
);
if
(
!
s
.
ok
()
&&
!
s
.
IsNotFound
())
{
if
(
!
s
.
ok
()
&&
!
s
.
IsNotFound
()
&&
!
has_incompatible_db_options
)
{
derror_replica
(
"rocksdb::CheckOptionsCompatibility failed, error = {}"
,
s
.
ToString
());
derror_replica
(
"rocksdb::CheckOptionsCompatibility failed, error = {}"
,
s
.
ToString
());
return
::
dsn
::
ERR_LOCAL_APP_FAILURE
;
return
::
dsn
::
ERR_LOCAL_APP_FAILURE
;
}
}
...
@@ -2574,6 +2586,32 @@ bool pegasus_server_impl::set_options(
...
@@ -2574,6 +2586,32 @@ bool pegasus_server_impl::set_options(
}
}
}
}
::
dsn
::
error_code
pegasus_server_impl
::
check_column_families
(
const
std
::
string
&
path
,
bool
*
missing_meta_cf
,
bool
*
missing_data_cf
)
{
*
missing_meta_cf
=
true
;
*
missing_data_cf
=
true
;
std
::
vector
<
std
::
string
>
column_families
;
auto
s
=
rocksdb
::
DB
::
ListColumnFamilies
(
rocksdb
::
DBOptions
(),
path
,
&
column_families
);
if
(
!
s
.
ok
())
{
derror_replica
(
"rocksdb::DB::ListColumnFamilies failed, error = {}"
,
s
.
ToString
());
return
::
dsn
::
ERR_LOCAL_APP_FAILURE
;
}
for
(
const
auto
&
column_family
:
column_families
)
{
if
(
column_family
==
META_COLUMN_FAMILY_NAME
)
{
*
missing_meta_cf
=
false
;
}
else
if
(
column_family
==
DATA_COLUMN_FAMILY_NAME
)
{
*
missing_data_cf
=
false
;
}
else
{
derror_replica
(
"unknown column family name: {}"
,
column_family
);
return
::
dsn
::
ERR_LOCAL_APP_FAILURE
;
}
}
return
::
dsn
::
ERR_OK
;
}
uint64_t
pegasus_server_impl
::
do_manual_compact
(
const
rocksdb
::
CompactRangeOptions
&
options
)
uint64_t
pegasus_server_impl
::
do_manual_compact
(
const
rocksdb
::
CompactRangeOptions
&
options
)
{
{
// wait flush before compact to make all data compacted.
// wait flush before compact to make all data compacted.
...
...
src/server/pegasus_server_impl.h
浏览文件 @
a83343d4
...
@@ -310,6 +310,9 @@ private:
...
@@ -310,6 +310,9 @@ private:
return
false
;
return
false
;
}
}
::
dsn
::
error_code
check_column_families
(
const
std
::
string
&
path
,
bool
*
missing_meta_cf
,
bool
*
miss_data_cf
);
void
release_db
();
void
release_db
();
void
release_db
(
rocksdb
::
DB
*
db
,
const
std
::
vector
<
rocksdb
::
ColumnFamilyHandle
*>
&
handles
);
void
release_db
(
rocksdb
::
DB
*
db
,
const
std
::
vector
<
rocksdb
::
ColumnFamilyHandle
*>
&
handles
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录