Skip to content

Commit

Permalink
Fix: unittest.
Browse files Browse the repository at this point in the history
  • Loading branch information
small-turtle-1 committed May 9, 2024
1 parent 621990b commit 569d825
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/unit_test/storage/buffer/buffer_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,34 @@ class BufferObjTest : public BaseTest {

void WaitCleanup(Storage *storage, TxnTimeStamp last_commit_ts) {
Catalog *catalog = storage->catalog();
TxnManager *txn_mgr = storage->txn_manager();
BufferManager *buffer_mgr = storage->buffer_manager();

LOG_INFO("Waiting cleanup");
auto visible_ts = WaitFlushDeltaOp(storage, last_commit_ts);

auto cleanup_task = MakeShared<CleanupTask>(catalog, visible_ts, buffer_mgr);
cleanup_task->Execute();
}

TxnTimeStamp WaitFlushDeltaOp(Storage *storage, TxnTimeStamp last_commit_ts) {
TxnManager *txn_mgr = storage->txn_manager();

TxnTimeStamp visible_ts = 0;
time_t start = time(nullptr);
while (true) {
visible_ts = txn_mgr->GetCleanupScanTS();
// wait for at most 10s
time_t end = time(nullptr);
if (visible_ts >= last_commit_ts) {
LOG_INFO(fmt::format("Cleanup finished after {}", end - start));
LOG_INFO(fmt::format("FlushDeltaOp finished after {}", end - start));
break;
}
// wait for at most 10s
if (end - start > 10) {
UnrecoverableError("WaitCleanup timeout");
UnrecoverableError("WaitFlushDeltaOp timeout");
}
LOG_INFO(fmt::format("Before usleep. Wait cleanup for {} seconds", end - start));
LOG_INFO(fmt::format("Before usleep. Wait flush delta op for {} seconds", end - start));
usleep(1000 * 1000);
}

auto cleanup_task = MakeShared<CleanupTask>(catalog, visible_ts, buffer_mgr);
cleanup_task->Execute();
return visible_ts;
}
};

Expand Down Expand Up @@ -654,8 +659,9 @@ TEST_F(BufferObjTest, test_hnsw_index_buffer_obj_shutdown) {
}
}
}
txn_mgr->CommitTxn(txn);
last_commit_ts = txn_mgr->CommitTxn(txn);
}
WaitFlushDeltaOp(storage, last_commit_ts);
// Drop Table
{
auto *txn = txn_mgr->BeginTxn();
Expand Down

0 comments on commit 569d825

Please sign in to comment.