From ea3d7c31f574e21cb6bf979d5db526bfa70d09f7 Mon Sep 17 00:00:00 2001 From: augurier <14434658+augurier@user.noreply.gitee.com> Date: Sat, 28 Dec 2024 09:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=B4=A9=E6=BA=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=BB=BC=E5=90=88=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/recover_test.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/recover_test.cc b/test/recover_test.cc index 47cc731..36480b7 100644 --- a/test/recover_test.cc +++ b/test/recover_test.cc @@ -36,7 +36,7 @@ TEST(TestNormalRecover, Recover) { findKeysByAgeIndex(db, true); } -TEST(TestParalPutRecover, Recover) { +TEST(TestParalRecover, Recover) { //第一次运行 // fielddb::DestroyDB("testdb3.2",Options()); // FieldDB *db = new FieldDB(); @@ -47,24 +47,28 @@ TEST(TestParalPutRecover, Recover) { // } // db->CreateIndexOnField("address"); // db->CreateIndexOnField("age"); - // shanghaiKeys.clear(); - // age20Keys.clear(); - // int thread_num_ = 2; + // int thread_num_ = 4; // std::vector threads(thread_num_); // threads[0] = std::thread([db](){ // InsertFieldData(db); // }); // threads[1] = std::thread([db](){ + // WriteFieldData(db); + // }); + // threads[2] = std::thread([db](){ + // DeleteFieldData(db); + // }); + // threads[3] = std::thread([db](){ // InsertOneField(db); // delete db; // }); - // for (auto& t : threads) { + // for (auto& t : threads) { // if (t.joinable()) { // t.join(); // } // } - //线程1导致了线程0错误,测试会终止(模拟数据库崩溃) - //这会导致线程0在写入的各种奇怪的时间点崩溃 + //线程3导致了其他线程错误,测试会终止(模拟数据库崩溃) + //这会导致各线程在各种奇怪的时间点崩溃 //第二次运行注释掉上面的代码,运行下面的代码测试恢复