[CP] Fix garbage tasks remain problem

This commit is contained in:
tino247
2024-01-18 04:43:10 +00:00
committed by ob-robot
parent e52f385a43
commit d50e4d0662
11 changed files with 55 additions and 89 deletions

View File

@ -203,6 +203,39 @@ TEST_F(TestUniqTaskQueue, test_concurrency_execute)
}
*/
// bugfix:53694448
TEST_F(TestUniqTaskQueue, test_get_queue_fail)
{
MockTaskQueue queue;
MockTaskProcesser processor(queue);
ASSERT_EQ(OB_SUCCESS, queue.init(&processor, 1 /*thread_num*/, 1024 /*queue_size*/));
// error injection
TP_SET_EVENT(common::EventTable::EN_UNIQ_TASK_QUEUE_GET_GROUP_FAIL, OB_ALLOCATE_MEMORY_FAILED, 0, 1);
// add task failed
MockTask task(0 /*group_id*/, 0 /*task_id*/);
ASSERT_EQ(OB_ALLOCATE_MEMORY_FAILED, queue.add(task));
// reset error injection
TP_SET_EVENT(common::EventTable::EN_UNIQ_TASK_QUEUE_GET_GROUP_FAIL, OB_SUCCESS, 0, 1);
// add the same task again
// before bugfix
// add task will fail and do nothing
// ASSERT_EQ(OB_EAGAIN, queue.add(task));
// usleep(1 * 1000 * 1000L); //1s
// ASSERT_EQ(0, processor.get_results().count());
// after bugfix
// add task will success and task will be scheduled
ASSERT_EQ(OB_SUCCESS, queue.add(task));
usleep(1 * 1000 * 1000L); //1s
ASSERT_EQ(1, processor.get_results().count());
ASSERT_EQ(task, processor.get_results().at(0));
}
// bugfix: workitem/49006474
TEST_F(TestUniqTaskQueue, test_queue_starvation)
{
@ -297,7 +330,7 @@ TEST_F(TestUniqTaskQueue, test_queue_starvation)
int main(int argc, char **argv)
{
system("rm -f test_uniq_task_queue.log");
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
oceanbase::common::ObLogger::get_logger().set_log_level("WDIAG");
OB_LOGGER.set_file_name("test_uniq_task_queue.log", true);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();