From 3427f970aa7c27977ba49e9e4a80259cb7fd4170 Mon Sep 17 00:00:00 2001 From: LINxiansheng Date: Tue, 15 Mar 2022 12:02:56 +0800 Subject: [PATCH] Fix bug 39784090: Its no effect when decrease the datafile_size --- .gitignore | 4 ++++ .../resolver/cmd/ob_alter_system_resolver.cpp | 6 +++++ src/storage/blocksstable/ob_store_file.cpp | 24 +++++++++++++++++++ src/storage/blocksstable/ob_store_file.h | 1 + 4 files changed, 35 insertions(+) diff --git a/.gitignore b/.gitignore index b83079d021..5c888b814c 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,7 @@ cmake-build-release ###### OSX dir files .DS_Store + +###### Debug bin and configuration +tools/deploy/bin +tools/deploy/config2.py diff --git a/src/sql/resolver/cmd/ob_alter_system_resolver.cpp b/src/sql/resolver/cmd/ob_alter_system_resolver.cpp index e9b07452f1..29994cb4d7 100644 --- a/src/sql/resolver/cmd/ob_alter_system_resolver.cpp +++ b/src/sql/resolver/cmd/ob_alter_system_resolver.cpp @@ -2299,6 +2299,12 @@ int ObSetConfigResolver::check_param_valid(int64_t tenant_id, const ObString& na } #endif } + else if (0 == name.case_compare("datafile_size")) { + if(OB_FAIL(OB_STORE_FILE.validate_datafile_size(value.ptr()))){ + ret = OB_INVALID_CONFIG; + LOG_WARN("datafile_size is not valid", K(ret)); + } + } } return ret; } diff --git a/src/storage/blocksstable/ob_store_file.cpp b/src/storage/blocksstable/ob_store_file.cpp index d2f38e08c3..c5615cf11b 100644 --- a/src/storage/blocksstable/ob_store_file.cpp +++ b/src/storage/blocksstable/ob_store_file.cpp @@ -1349,6 +1349,30 @@ int ObStoreFile::resize_file(const int64_t new_data_file_size, const int64_t new return ret; } +int ObStoreFile::validate_datafile_size(const char* config_data_file_size) +{ + int ret = OB_SUCCESS; + if (OB_ISNULL(store_file_system_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("The OB store file instance is not exist", K(ret)); + } else { + bool valid = false; + int64_t new_data_file_size = ObConfigCapacityParser::get(config_data_file_size, valid); + if(!valid){ + ret = OB_ERR_PARSE_SQL; + LOG_USER_ERROR(OB_INVALID_CONFIG, "datafile_size can not be parsed"); + } else { + const int64_t original_file_size = store_file_system_->get_total_data_size(); + if (new_data_file_size < original_file_size) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("datafile_size is smaller than the original configuration", K(ret)); + LOG_USER_ERROR(OB_INVALID_CONFIG, "datafile_size can not be smaller than the original configuration"); + } + } + } + return ret; +} + int ObStoreFile::alloc_memory(const int64_t total_macro_block_cnt, uint32_t*& free_block_array, uint64_t*& macro_block_bitmap, ObSegmentArray& macro_block_info_array) { diff --git a/src/storage/blocksstable/ob_store_file.h b/src/storage/blocksstable/ob_store_file.h index 8d500d0cb1..a03de3f269 100644 --- a/src/storage/blocksstable/ob_store_file.h +++ b/src/storage/blocksstable/ob_store_file.h @@ -361,6 +361,7 @@ public: int drop_disk(const common::ObString& diskgroup_name, const common::ObString& alias_name); int is_free_block(const int64_t block_index, bool& is_free); int resize_file(const int64_t new_data_file_size, const int64_t new_data_file_disk_percentage); + int validate_datafile_size(const char* config_data_file_size); private: friend class ObStoreFileGCTask; -- GitLab