BUGFIX: make sure safe destroy handler stop if create tenant failed.

This commit is contained in:
obdev 2023-07-20 07:48:40 +00:00 committed by ob-robot
parent 0e559980f4
commit 917a6ae258
3 changed files with 71 additions and 5 deletions

View File

@ -203,14 +203,20 @@ int ObSafeDestroyHandler::stop()
void ObSafeDestroyHandler::wait()
{
int ret = OB_SUCCESS;
static const int64_t SLEEP_TS = 100 * 1000; // 100_ms
int64_t start_ts = ObTimeUtility::current_time();
while (!queue_.stop_finished()) {
if (REACH_TIME_INTERVAL(60 * 1000 * 1000)) { // every minute
LOG_WARN_RET(OB_ERR_TOO_MUCH_TIME, "the safe destroy thread wait cost too much time",
K(ObTimeUtility::current_time() - start_ts));
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("safe destroy thread not inited", K(ret));
} else {
while (!queue_.stop_finished()) {
if (REACH_TIME_INTERVAL(60 * 1000 * 1000)) { // every minute
LOG_WARN_RET(OB_ERR_TOO_MUCH_TIME, "the safe destroy thread wait cost too much time",
K(ObTimeUtility::current_time() - start_ts));
}
ob_usleep(SLEEP_TS);
}
ob_usleep(SLEEP_TS);
}
}

View File

@ -79,6 +79,7 @@ storage_unittest(test_backup_index_merger backup/test_backup_index_merger.cpp)
storage_unittest(test_backup_extern_info_mgr backup/test_backup_extern_info_mgr.cpp)
#storage_unittest(test_create_tablet_clog tx_storage/test_create_tablet_clog.cpp)
storage_unittest(test_safe_destroy_handler tx_storage/test_safe_destroy_handler.cpp)
storage_unittest(test_simple_rows_merger)
storage_unittest(test_partition_incremental_range_spliter)
storage_unittest(test_partition_major_sstable_range_spliter)

View File

@ -0,0 +1,59 @@
/**
* Copyright (c) 2023 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include <gtest/gtest.h>
#include <sys/stat.h>
#include <sys/types.h>
#define USING_LOG_PREFIX STORAGETEST
#define protected public
#define private public
#include "storage/tx_storage/ob_safe_destroy_handler.h"
namespace oceanbase
{
using namespace common;
namespace storage
{
class TestSafeDestroyHandler : public ::testing::Test
{
public:
TestSafeDestroyHandler() = default;
virtual ~TestSafeDestroyHandler() = default;
};
TEST_F(TestSafeDestroyHandler, destroy_before_init)
{
int ret = OB_SUCCESS;
ObSafeDestroyHandler handler;
ret = handler.stop();
ASSERT_EQ(OB_NOT_INIT, ret);
handler.wait();
handler.destroy();
}
} // namespace storage
} // namespace oceanbase
int main(int argc, char **argv)
{
system("rm -f ./test_safe_destroy_handler.log*");
OB_LOGGER.set_file_name("test_safe_destroy_handler.log", true);
OB_LOGGER.set_log_level("INFO");
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}