diff --git a/debian/mariadb-plugin-columnstore.install b/debian/mariadb-plugin-columnstore.install index b32fdd3f4..0efba1cf8 100644 --- a/debian/mariadb-plugin-columnstore.install +++ b/debian/mariadb-plugin-columnstore.install @@ -38,6 +38,7 @@ usr/bin/mcs-stop-controllernode.sh usr/bin/mcs-load-brm-from-file usr/bin/mcs-load-em usr/bin/mcs-shmem-locks +usr/bin/mcs-oid-client usr/bin/mcsGetConfig usr/bin/mcsSetConfig usr/bin/mycnfUpgrade diff --git a/versioning/BRM/CMakeLists.txt b/versioning/BRM/CMakeLists.txt index 3f5d032da..9eaf8fbe9 100644 --- a/versioning/BRM/CMakeLists.txt +++ b/versioning/BRM/CMakeLists.txt @@ -182,3 +182,16 @@ install( DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine ) + +add_executable(mcs-oid-client oid-client.cpp) +target_link_libraries( + mcs-oid-client + ${ENGINE_LDFLAGS} + ${ENGINE_WRITE_LIBS} + boost_program_options +) + +install(TARGETS mcs-oid-client + DESTINATION ${ENGINE_BINDIR} + COMPONENT columnstore-engine +) diff --git a/versioning/BRM/oid-client.cpp b/versioning/BRM/oid-client.cpp new file mode 100644 index 000000000..35d93d68c --- /dev/null +++ b/versioning/BRM/oid-client.cpp @@ -0,0 +1,66 @@ +/* Copyright (C) 2016-2025 MariaDB Corporation + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; version 2 of + the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. */ +#include + +#include "dbrm.h" + +#include +namespace po = boost::program_options; + +template +void check_value(const boost::program_options::variables_map& vm, const std::string& opt1, T lower_bound, + T upper_bound) +{ + auto value = vm[opt1].as(); + if (value < lower_bound || value >= upper_bound) + { + throw std::logic_error(std::string("Option '") + opt1 + "' is out of range.: " + std::to_string(value)); + } +} + +int main(int argc, char** argv) +{ + po::options_description desc( + "A tool to reclaim OID space. It needs controllernode to be online to operate "); + + uint32_t lowerOid; + uint32_t upperOid; + desc.add_options()("help", "produce help message") + ("lower-oid,l", po::value(&lowerOid)->required(), "lower oid that can not be lower 3000") + ("upper-oid,u", po::value(&upperOid)->required(), "lower oid that can not be bigger 16 * 1024 ^ 2"); + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + + if (argc == 1 || vm.count("help")) + { + cout << desc << "\n"; + return 1; + } + + uint32_t bitMapSize = 8 * 2 * 1024 * 1024; + check_value(vm, "lower-oid", 3000, bitMapSize-1); + check_value(vm, "upper-oid", lowerOid, bitMapSize); + + po::notify(vm); + + BRM::DBRM brm; + std::cout << "OID space size before reclaim: " << brm.oidm_size() << std::endl; + brm.returnOIDs(lowerOid, upperOid); + std::cout << "OID space size after reclaim:" << brm.oidm_size() << std::endl; + return 0; +} \ No newline at end of file