diff --git a/dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp b/dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp index 535bd7a9c48..b6752d42559 100644 --- a/dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp +++ b/dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp @@ -67,14 +67,24 @@ UniversalPageStorageServicePtr UniversalPageStorageService::create( service->checkpoint_pool = std::make_unique(1, "ps-checkpoint", context.getJointThreadInfoJeallocMap()); service->remote_checkpoint_handle = service->checkpoint_pool->addTask( - [service] { return service->uploadCheckpoint(); }, + [srv_weak = std::weak_ptr(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(service)] { + auto service = srv_weak.lock(); + if (!service) + return false; + return service->gc(); + }, false, /*interval_ms*/ 60 * 1000); return service;