[CP] alter _parallel_ddl_control
This commit is contained in:
		@ -25683,6 +25683,8 @@ int ObDDLService::inner_create_tenant_(
 | 
				
			|||||||
               arg, schema_guard, user_tenant_schema,
 | 
					               arg, schema_guard, user_tenant_schema,
 | 
				
			||||||
               meta_tenant_schema, init_configs))) {
 | 
					               meta_tenant_schema, init_configs))) {
 | 
				
			||||||
      LOG_WARN("fail to create tenant schema", KR(ret), K(arg));
 | 
					      LOG_WARN("fail to create tenant schema", KR(ret), K(arg));
 | 
				
			||||||
 | 
					    } else if (OB_FAIL(add_extra_tenant_init_config_(user_tenant_id, init_configs))) {
 | 
				
			||||||
 | 
					      LOG_WARN("fail to add_extra_tenant_init_config", KR(ret), K(user_tenant_id));
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      DEBUG_SYNC(BEFORE_CREATE_META_TENANT);
 | 
					      DEBUG_SYNC(BEFORE_CREATE_META_TENANT);
 | 
				
			||||||
      // create ls/tablet/schema in tenant space
 | 
					      // create ls/tablet/schema in tenant space
 | 
				
			||||||
@ -40393,5 +40395,35 @@ bool ObDDLService::need_modify_dep_obj_status(const obrpc::ObAlterTableArg &alte
 | 
				
			|||||||
          || (alter_table_arg.is_alter_options_
 | 
					          || (alter_table_arg.is_alter_options_
 | 
				
			||||||
              && alter_table_schema.alter_option_bitset_.has_member(ObAlterTableArg::TABLE_NAME)));
 | 
					              && alter_table_schema.alter_option_bitset_.has_member(ObAlterTableArg::TABLE_NAME)));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int ObDDLService::add_extra_tenant_init_config_(
 | 
				
			||||||
 | 
					                  const uint64_t tenant_id,
 | 
				
			||||||
 | 
					                  common::ObIArray<common::ObConfigPairs> &init_configs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
 | 
					  bool find = false;
 | 
				
			||||||
 | 
					  ObString config_name("_parallel_ddl_control");
 | 
				
			||||||
 | 
					  ObSqlString config_value;
 | 
				
			||||||
 | 
					  if (OB_FAIL(ObParallelDDLControlMode::generate_parallel_ddl_control_config_for_create_tenant(config_value))) {
 | 
				
			||||||
 | 
					    LOG_WARN("fail to generate parallel ddl control config value", KR(ret));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  for (int index = 0 ; !find && OB_SUCC(ret) && index < init_configs.count(); ++index) {
 | 
				
			||||||
 | 
					    if (tenant_id == init_configs.at(index).get_tenant_id()) {
 | 
				
			||||||
 | 
					      find = true;
 | 
				
			||||||
 | 
					      common::ObConfigPairs ¶llel_table_config = init_configs.at(index);
 | 
				
			||||||
 | 
					      if (OB_FAIL(parallel_table_config.add_config(config_name, config_value.string()))) {
 | 
				
			||||||
 | 
					        LOG_WARN("fail to add config", KR(ret), K(config_name), K(config_value));
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  // ---- Add new tenant init config above this line -----
 | 
				
			||||||
 | 
					  // At the same time, to verify modification, you need modify test case tenant_init_config(_oracle).test
 | 
				
			||||||
 | 
					  if (OB_SUCC(ret) && !find) {
 | 
				
			||||||
 | 
					    ret = OB_INVALID_ARGUMENT;
 | 
				
			||||||
 | 
					    LOG_WARN("no matched tenant config", KR(ret), K(tenant_id), K(init_configs));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // end namespace rootserver
 | 
					} // end namespace rootserver
 | 
				
			||||||
} // end namespace oceanbase
 | 
					} // end namespace oceanbase
 | 
				
			||||||
 | 
				
			|||||||
@ -2753,6 +2753,13 @@ private:
 | 
				
			|||||||
      const share::schema::ObTenantSchema &orig_tenant_schema,
 | 
					      const share::schema::ObTenantSchema &orig_tenant_schema,
 | 
				
			||||||
      const share::schema::ObTenantSchema &new_tenant_schema);
 | 
					      const share::schema::ObTenantSchema &new_tenant_schema);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // this function is used for add extra tenant config init during create excepet data version
 | 
				
			||||||
 | 
					  // The addition of new configuration items requires the addition or modification of related test cases to ensure their effectiveness.
 | 
				
			||||||
 | 
					  int add_extra_tenant_init_config_(
 | 
				
			||||||
 | 
					      const uint64_t tenant_id,
 | 
				
			||||||
 | 
					      common::ObIArray<common::ObConfigPairs> &init_configs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
  int check_locality_compatible_(ObTenantSchema &schema);
 | 
					  int check_locality_compatible_(ObTenantSchema &schema);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int pre_rename_mysql_columns_online(const ObTableSchema &origin_table_schema,
 | 
					  int pre_rename_mysql_columns_online(const ObTableSchema &origin_table_schema,
 | 
				
			||||||
 | 
				
			|||||||
@ -1317,7 +1317,7 @@ bool ObParallelDDLControlParser::parse(const char *str, uint8_t *arr, int64_t le
 | 
				
			|||||||
      OB_LOG_RET(WARN, tmp_ret, "fail to get kv list", K(str));
 | 
					      OB_LOG_RET(WARN, tmp_ret, "fail to get kv list", K(str));
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      for (int64_t i = 0; bret && i < kv_list.count(); ++i) {
 | 
					      for (int64_t i = 0; bret && i < kv_list.count(); ++i) {
 | 
				
			||||||
        uint8_t mode = MODE_ON;
 | 
					        uint8_t mode = MODE_DEFAULT;
 | 
				
			||||||
        if (kv_list.at(i).second.case_compare("on") == 0) {
 | 
					        if (kv_list.at(i).second.case_compare("on") == 0) {
 | 
				
			||||||
          mode = MODE_ON;
 | 
					          mode = MODE_ON;
 | 
				
			||||||
        } else if (kv_list.at(i).second.case_compare("off") == 0) {
 | 
					        } else if (kv_list.at(i).second.case_compare("off") == 0) {
 | 
				
			||||||
 | 
				
			|||||||
@ -849,8 +849,9 @@ public:
 | 
				
			|||||||
  virtual ~ObParallelDDLControlParser() {}
 | 
					  virtual ~ObParallelDDLControlParser() {}
 | 
				
			||||||
  virtual bool parse(const char *str, uint8_t *arr, int64_t len) override;
 | 
					  virtual bool parse(const char *str, uint8_t *arr, int64_t len) override;
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  static const uint8_t MODE_ON = 0b00;
 | 
					  static const uint8_t MODE_DEFAULT = 0b00;
 | 
				
			||||||
  static const uint8_t MODE_OFF = 0b01;
 | 
					  static const uint8_t MODE_OFF = 0b01;
 | 
				
			||||||
 | 
					  static const uint8_t MODE_ON = 0b10;
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  DISALLOW_COPY_AND_ASSIGN(ObParallelDDLControlParser);
 | 
					  DISALLOW_COPY_AND_ASSIGN(ObParallelDDLControlParser);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -1348,6 +1348,12 @@ int ObParallelDDLControlMode::is_parallel_ddl(const ObParallelDDLType type, bool
 | 
				
			|||||||
      is_parallel = false;
 | 
					      is_parallel = false;
 | 
				
			||||||
    } else if (value == ObParallelDDLControlParser::MODE_ON) {
 | 
					    } else if (value == ObParallelDDLControlParser::MODE_ON) {
 | 
				
			||||||
      is_parallel = true;
 | 
					      is_parallel = true;
 | 
				
			||||||
 | 
					    } else if (value == ObParallelDDLControlParser::MODE_DEFAULT) {
 | 
				
			||||||
 | 
					      if (TRUNCATE_TABLE == type) {
 | 
				
			||||||
 | 
					        is_parallel = true;
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        is_parallel = false;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      ret = OB_ERR_UNEXPECTED;
 | 
					      ret = OB_ERR_UNEXPECTED;
 | 
				
			||||||
      OB_LOG(WARN, "invalid value unexpected", KR(ret), K(value));
 | 
					      OB_LOG(WARN, "invalid value unexpected", KR(ret), K(value));
 | 
				
			||||||
@ -1387,6 +1393,22 @@ bool ObSchemaUtils::can_add_column_group(const ObTableSchema &table_schema)
 | 
				
			|||||||
  return can_add_cg;
 | 
					  return can_add_cg;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int ObParallelDDLControlMode::generate_parallel_ddl_control_config_for_create_tenant(ObSqlString &config_value)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
 | 
					  int ddl_type_size = ARRAYSIZEOF(DDLType);
 | 
				
			||||||
 | 
					  for (int i = 0; OB_SUCC(ret) && i < (ddl_type_size - 1); ++i) {
 | 
				
			||||||
 | 
					    if (OB_FAIL(config_value.append_fmt("%s:ON, ", DDLType[i]))) {
 | 
				
			||||||
 | 
					      LOG_WARN("fail to append fmt", KR(ret), K(i));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if ((ddl_type_size > 0)
 | 
				
			||||||
 | 
					      && FAILEDx(config_value.append_fmt("%s:ON", DDLType[ddl_type_size - 1]))) {
 | 
				
			||||||
 | 
					    LOG_WARN("fail to append fmt", KR(ret), K(ddl_type_size));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // end schema
 | 
					} // end schema
 | 
				
			||||||
} // end share
 | 
					} // end share
 | 
				
			||||||
} // end oceanbase
 | 
					} // end oceanbase
 | 
				
			||||||
 | 
				
			|||||||
@ -390,6 +390,7 @@ public:
 | 
				
			|||||||
  int is_parallel_ddl(const ObParallelDDLType type, bool &is_parallel);
 | 
					  int is_parallel_ddl(const ObParallelDDLType type, bool &is_parallel);
 | 
				
			||||||
  static int is_parallel_ddl_enable(const ObParallelDDLType ddl_type, const uint64_t tenant_id, bool &is_parallel);
 | 
					  static int is_parallel_ddl_enable(const ObParallelDDLType ddl_type, const uint64_t tenant_id, bool &is_parallel);
 | 
				
			||||||
  static int string_to_ddl_type(const ObString &ddl_string, ObParallelDDLType &ddl_type);
 | 
					  static int string_to_ddl_type(const ObString &ddl_string, ObParallelDDLType &ddl_type);
 | 
				
			||||||
 | 
					  static int generate_parallel_ddl_control_config_for_create_tenant(ObSqlString &config_value);
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  bool check_mode_valid_(uint8_t mode) { return mode > MASK ? false : true; }
 | 
					  bool check_mode_valid_(uint8_t mode) { return mode > MASK ? false : true; }
 | 
				
			||||||
  uint64_t value_;
 | 
					  uint64_t value_;
 | 
				
			||||||
 | 
				
			|||||||
@ -49,6 +49,33 @@ TEST_F(TestObParallelDDLControl, test_parse)
 | 
				
			|||||||
  ASSERT_EQ(true, parser.parse("truncate_table:off", arr, 32));
 | 
					  ASSERT_EQ(true, parser.parse("truncate_table:off", arr, 32));
 | 
				
			||||||
  ASSERT_EQ(arr[0], 0b00000001);
 | 
					  ASSERT_EQ(arr[0], 0b00000001);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MEMSET(arr, 0, 32);
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, parser.parse("set_comment:off", arr, 32));
 | 
				
			||||||
 | 
					  ASSERT_EQ(arr[0], 0b00000100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MEMSET(arr, 0, 32);
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, parser.parse("create_index:off", arr, 32));
 | 
				
			||||||
 | 
					  ASSERT_EQ(arr[0], 0b00010000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MEMSET(arr, 0,32);
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, parser.parse("set_comment:on, set_comment:off, create_index:off", arr, 32));
 | 
				
			||||||
 | 
					  ASSERT_EQ(arr[0], 0b00010100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MEMSET(arr, 0,32);
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, parser.parse("set_comment:off, set_comment:on, create_index: off", arr, 32));
 | 
				
			||||||
 | 
					  ASSERT_EQ(arr[0], 0b00011000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MEMSET(arr, 0,32);
 | 
				
			||||||
 | 
					  ASSERT_EQ(false, parser.parse("set_comment=on", arr,32));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MEMSET(arr, 0,32);
 | 
				
			||||||
 | 
					  ASSERT_EQ(false, parser.parse("set_commentt:on", arr,32));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MEMSET(arr, 0,32);
 | 
				
			||||||
 | 
					  ASSERT_EQ(false, parser.parse("set_comment:oon", arr,32));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  MEMSET(arr, 0,32);
 | 
				
			||||||
 | 
					  ASSERT_EQ(false, parser.parse("set_comment:on, create_index:oof", arr,32));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST_F(TestObParallelDDLControl, testObParallelDDLControlMode)
 | 
					TEST_F(TestObParallelDDLControl, testObParallelDDLControlMode)
 | 
				
			||||||
@ -58,13 +85,39 @@ TEST_F(TestObParallelDDLControl, testObParallelDDLControlMode)
 | 
				
			|||||||
  bool is_parallel = false;
 | 
					  bool is_parallel = false;
 | 
				
			||||||
  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::TRUNCATE_TABLE, is_parallel));
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::TRUNCATE_TABLE, is_parallel));
 | 
				
			||||||
  ASSERT_EQ(true, is_parallel);
 | 
					  ASSERT_EQ(true, is_parallel);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::SET_COMMENT, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(false, is_parallel);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::CREATE_INDEX, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(false, is_parallel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ASSERT_EQ(OB_INVALID_ARGUMENT, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::MAX_TYPE, is_parallel));
 | 
					  ASSERT_EQ(OB_INVALID_ARGUMENT, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::MAX_TYPE, is_parallel));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ASSERT_EQ(true, _parallel_ddl_control.set_value("truncate_table:off"));
 | 
					  ASSERT_EQ(true, _parallel_ddl_control.set_value("truncate_table:on"));
 | 
				
			||||||
  _parallel_ddl_control.init_mode(ddl_mode);
 | 
					  _parallel_ddl_control.init_mode(ddl_mode);
 | 
				
			||||||
  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::TRUNCATE_TABLE, is_parallel));
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::TRUNCATE_TABLE, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, is_parallel);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::SET_COMMENT, is_parallel));
 | 
				
			||||||
  ASSERT_EQ(false, is_parallel);
 | 
					  ASSERT_EQ(false, is_parallel);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::CREATE_INDEX, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(false, is_parallel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, _parallel_ddl_control.set_value("set_comment:on"));
 | 
				
			||||||
 | 
					  _parallel_ddl_control.init_mode(ddl_mode);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::TRUNCATE_TABLE, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, is_parallel);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::SET_COMMENT, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, is_parallel);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::CREATE_INDEX, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(false, is_parallel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, _parallel_ddl_control.set_value("create_index:on, set_comment:on"));
 | 
				
			||||||
 | 
					  _parallel_ddl_control.init_mode(ddl_mode);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::TRUNCATE_TABLE, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, is_parallel);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::SET_COMMENT, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, is_parallel);
 | 
				
			||||||
 | 
					  ASSERT_EQ(OB_SUCCESS, ddl_mode.is_parallel_ddl(ObParallelDDLControlMode::CREATE_INDEX, is_parallel));
 | 
				
			||||||
 | 
					  ASSERT_EQ(true, is_parallel);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // common
 | 
					} // common
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user