Return NotFound from TableFactory configuration errors during options loading (#7615)

Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/7615

Reviewed By: riversand963

Differential Revision: D24637054

Pulled By: ajkr

fbshipit-source-id: 7da20d44289eaa2387af4edf8c3c48057425cc1c
main
mrambacher 4 years ago committed by Facebook GitHub Bot
parent 6773901f76
commit 30beecef8c
  1. 8
      options/options_parser.cc
  2. 28
      utilities/options/options_util_test.cc

@ -460,7 +460,13 @@ Status RocksDBOptionsParser::EndSection(
opt_section_titles[kOptionSectionTableOptions].size()), opt_section_titles[kOptionSectionTableOptions].size()),
&(cf_opt->table_factory)); &(cf_opt->table_factory));
if (s.ok()) { if (s.ok()) {
return cf_opt->table_factory->ConfigureFromMap(config_options, opt_map); s = cf_opt->table_factory->ConfigureFromMap(config_options, opt_map);
// Translate any errors (NotFound, NotSupported, to InvalidArgument
if (s.ok() || s.IsInvalidArgument()) {
return s;
} else {
return Status::InvalidArgument(s.getState());
}
} else { } else {
// Return OK for not supported table factories as TableFactory // Return OK for not supported table factories as TableFactory
// Deserialization is optional. // Deserialization is optional.

@ -500,7 +500,8 @@ TEST_F(OptionsUtilTest, LoadLatestOptions) {
static void WriteOptionsFile(Env* env, const std::string& path, static void WriteOptionsFile(Env* env, const std::string& path,
const std::string& options_file, int major, const std::string& options_file, int major,
int minor, const std::string& db_opts, int minor, const std::string& db_opts,
const std::string& cf_opts) { const std::string& cf_opts,
const std::string& bbt_opts = "") {
std::string options_file_header = std::string options_file_header =
"\n" "\n"
"[Version]\n" "[Version]\n"
@ -516,6 +517,8 @@ static void WriteOptionsFile(Env* env, const std::string& path,
ASSERT_OK(wf->Append( ASSERT_OK(wf->Append(
"[CFOptions \"default\"] # column family must be specified\n" + "[CFOptions \"default\"] # column family must be specified\n" +
cf_opts + "\n")); cf_opts + "\n"));
ASSERT_OK(wf->Append("[TableOptions/BlockBasedTable \"default\"]\n" +
bbt_opts + "\n"));
ASSERT_OK(wf->Close()); ASSERT_OK(wf->Close());
std::string latest_options_file; std::string latest_options_file;
@ -567,9 +570,20 @@ TEST_F(OptionsUtilTest, BadLatestOptions) {
s = LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs); s = LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs);
ASSERT_NOK(s); ASSERT_NOK(s);
ASSERT_TRUE(s.IsInvalidArgument()); ASSERT_TRUE(s.IsInvalidArgument());
// Write an options file for a previous minor release with an unknown BBT
// Option
WriteOptionsFile(options.env, dbname_, "OPTIONS-0003", ROCKSDB_MAJOR,
ROCKSDB_MINOR - 1, "", "", "unknown_bbt_opt=true");
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs);
ASSERT_NOK(s);
ASSERT_TRUE(s.IsInvalidArgument());
// Even though ignore_unknown_options=true, we still return an error...
s = LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs);
ASSERT_NOK(s);
ASSERT_TRUE(s.IsInvalidArgument());
// Write an options file for the current release with an unknown DB Option // Write an options file for the current release with an unknown DB Option
WriteOptionsFile(options.env, dbname_, "OPTIONS-0003", ROCKSDB_MAJOR, WriteOptionsFile(options.env, dbname_, "OPTIONS-0004", ROCKSDB_MAJOR,
ROCKSDB_MINOR, "unknown_db_opt=true", ""); ROCKSDB_MINOR, "unknown_db_opt=true", "");
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs);
ASSERT_NOK(s); ASSERT_NOK(s);
@ -580,7 +594,7 @@ TEST_F(OptionsUtilTest, BadLatestOptions) {
ASSERT_TRUE(s.IsInvalidArgument()); ASSERT_TRUE(s.IsInvalidArgument());
// Write an options file for the current release with an unknown CF Option // Write an options file for the current release with an unknown CF Option
WriteOptionsFile(options.env, dbname_, "OPTIONS-0004", ROCKSDB_MAJOR, WriteOptionsFile(options.env, dbname_, "OPTIONS-0005", ROCKSDB_MAJOR,
ROCKSDB_MINOR, "", "unknown_cf_opt=true"); ROCKSDB_MINOR, "", "unknown_cf_opt=true");
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs);
ASSERT_NOK(s); ASSERT_NOK(s);
@ -591,7 +605,7 @@ TEST_F(OptionsUtilTest, BadLatestOptions) {
ASSERT_TRUE(s.IsInvalidArgument()); ASSERT_TRUE(s.IsInvalidArgument());
// Write an options file for the current release with an invalid DB Option // Write an options file for the current release with an invalid DB Option
WriteOptionsFile(options.env, dbname_, "OPTIONS-0005", ROCKSDB_MAJOR, WriteOptionsFile(options.env, dbname_, "OPTIONS-0006", ROCKSDB_MAJOR,
ROCKSDB_MINOR, "create_if_missing=hello", ""); ROCKSDB_MINOR, "create_if_missing=hello", "");
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs);
ASSERT_NOK(s); ASSERT_NOK(s);
@ -602,20 +616,20 @@ TEST_F(OptionsUtilTest, BadLatestOptions) {
ASSERT_TRUE(s.IsInvalidArgument()); ASSERT_TRUE(s.IsInvalidArgument());
// Write an options file for the next release with an invalid DB Option // Write an options file for the next release with an invalid DB Option
WriteOptionsFile(options.env, dbname_, "OPTIONS-0006", ROCKSDB_MAJOR, WriteOptionsFile(options.env, dbname_, "OPTIONS-0007", ROCKSDB_MAJOR,
ROCKSDB_MINOR + 1, "create_if_missing=hello", ""); ROCKSDB_MINOR + 1, "create_if_missing=hello", "");
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs));
ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
// Write an options file for the next release with an unknown DB Option // Write an options file for the next release with an unknown DB Option
WriteOptionsFile(options.env, dbname_, "OPTIONS-0007", ROCKSDB_MAJOR, WriteOptionsFile(options.env, dbname_, "OPTIONS-0008", ROCKSDB_MAJOR,
ROCKSDB_MINOR + 1, "unknown_db_opt=true", ""); ROCKSDB_MINOR + 1, "unknown_db_opt=true", "");
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs));
// Ignore the errors for future releases when ignore_unknown_options=true // Ignore the errors for future releases when ignore_unknown_options=true
ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
// Write an options file for the next major release with an unknown CF Option // Write an options file for the next major release with an unknown CF Option
WriteOptionsFile(options.env, dbname_, "OPTIONS-0008", ROCKSDB_MAJOR + 1, WriteOptionsFile(options.env, dbname_, "OPTIONS-0009", ROCKSDB_MAJOR + 1,
ROCKSDB_MINOR, "", "unknown_cf_opt=true"); ROCKSDB_MINOR, "", "unknown_cf_opt=true");
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs));
// Ignore the errors for future releases when ignore_unknown_options=true // Ignore the errors for future releases when ignore_unknown_options=true

Loading…
Cancel
Save