Skip to content

Commit

Permalink
disagg: Fix a potential crash when shutting down (#8848) (#8914)
Browse files Browse the repository at this point in the history
close #8837
  • Loading branch information
ti-chi-bot authored May 8, 2024
1 parent 3f0929f commit 3691fdf
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,24 @@ UniversalPageStorageServicePtr UniversalPageStorageService::create(
// Only upload checkpoint when S3 is enabled
service->checkpoint_pool = std::make_unique<BackgroundProcessingPool>(1, "ps-checkpoint");
service->remote_checkpoint_handle = service->checkpoint_pool->addTask(
[service] { return service->uploadCheckpoint(); },
[srv_weak = std::weak_ptr<UniversalPageStorageService>(service)] {
auto service = srv_weak.lock();
if (!service)
return false;
return service->uploadCheckpoint();
},
/*multi*/ false,
/*interval_ms*/ interval_s * 1000);
}

auto & bkg_pool = context.getBackgroundPool();
service->gc_handle = bkg_pool.addTask(
[service] { return service->gc(); },
[srv_weak = std::weak_ptr<UniversalPageStorageService>(service)] {
auto service = srv_weak.lock();
if (!service)
return false;
return service->gc();
},
false,
/*interval_ms*/ 60 * 1000);
return service;
Expand Down

0 comments on commit 3691fdf

Please sign in to comment.