Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
Added IsRunning member to MonoQueuePool so TileGroupCompactor can che…
Browse files Browse the repository at this point in the history
…ck if system is shutting down to avoid a race and stop trying to compact. Resolves segfault in tile_group_compactor_test.
  • Loading branch information
mbutrovich committed May 25, 2018
1 parent 7426410 commit 36d546d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gc/tile_group_compactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void TileGroupCompactor::CompactTileGroup(const oid_t &tile_group_id) {

auto pause_time = minPauseTime;

while (attempts < max_attempts) {
while (attempts < max_attempts && threadpool::MonoQueuePool::GetInstance().IsRunning()) {
auto tile_group =
catalog::Manager::GetInstance().GetTileGroup(tile_group_id);
if (tile_group == nullptr) {
Expand Down
2 changes: 2 additions & 0 deletions src/include/threadpool/mono_queue_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class MonoQueuePool {

void Shutdown();

bool IsRunning() const { return is_running_; }

template <typename F>
void SubmitTask(const F &func);

Expand Down
5 changes: 5 additions & 0 deletions test/gc/tile_group_compactor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ TEST_F(TileGroupCompactorTests, GCIntegrationTestSparse) {
LOG_DEBUG("tile_group_count_after_gc: %zu", tile_group_count_after_gc);
EXPECT_EQ(tile_group_count_after_gc, tile_group_count_after_init);

threadpool::MonoQueuePool::GetInstance().Shutdown();
gc_manager.StopGC();
gc::GCManagerFactory::Configure(0);

Expand Down Expand Up @@ -213,6 +214,7 @@ TEST_F(TileGroupCompactorTests, GCIntegrationTestDense) {
LOG_DEBUG("tile_group_count_after_gc: %zu", tile_group_count_after_gc);
EXPECT_EQ(tile_group_count_after_delete, tile_group_count_after_gc);

threadpool::MonoQueuePool::GetInstance().Shutdown();
gc_manager.StopGC();
gc::GCManagerFactory::Configure(0);

Expand Down Expand Up @@ -328,6 +330,7 @@ TEST_F(TileGroupCompactorTests, ConcurrentUpdateTest) {
table.release();
TestingExecutorUtil::DeleteDatabase(test_name + "db");
epoch_manager.SetCurrentEpochId(++current_epoch);
threadpool::MonoQueuePool::GetInstance().Shutdown();
gc_manager.StopGC();
gc::GCManagerFactory::Configure(0);
EXPECT_FALSE(storage_manager->HasDatabase(db_id));
Expand Down Expand Up @@ -412,6 +415,7 @@ TEST_F(TileGroupCompactorTests, EdgeCasesTest) {

TestingExecutorUtil::DeleteDatabase(test_name + "db");
epoch_manager.SetCurrentEpochId(++current_epoch);
threadpool::MonoQueuePool::GetInstance().Shutdown();
gc_manager.StopGC();
gc::GCManagerFactory::Configure(0);
EXPECT_FALSE(storage_manager->HasDatabase(db_id));
Expand Down Expand Up @@ -493,6 +497,7 @@ TEST_F(TileGroupCompactorTests, RetryTest) {
table.release();
TestingExecutorUtil::DeleteDatabase(test_name + "db");
epoch_manager.SetCurrentEpochId(++current_epoch);
threadpool::MonoQueuePool::GetInstance().Shutdown();
gc_manager.StopGC();
gc::GCManagerFactory::Configure(0);
EXPECT_FALSE(storage_manager->HasDatabase(db_id));
Expand Down

0 comments on commit 36d546d

Please sign in to comment.