diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_vector_index.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_vector_index.cpp index 83bac689bfb..69f123e035b 100644 --- a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_vector_index.cpp +++ b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_vector_index.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,8 @@ class DeltaMergeStoreVectorTest void SetUp() override { TiFlashStorageTestBasic::SetUp(); + auto & global_context = TiFlashTestEnv::getGlobalContext(); + global_context.getTMTContext().initS3GCManager(nullptr); store = reload(); } diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_segment_s3.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_segment_s3.cpp index 01694d3c0e4..63d1bbd1f0e 100644 --- a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_segment_s3.cpp +++ b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_segment_s3.cpp @@ -65,6 +65,7 @@ class SegmentTestS3 : public DB::base::TiFlashStorageTestBasic ASSERT_TRUE(::DB::tests::TiFlashTestEnv::createBucketIfNotExist(*s3_client)); TiFlashStorageTestBasic::SetUp(); auto & global_context = TiFlashTestEnv::getGlobalContext(); + global_context.getTMTContext().initS3GCManager(nullptr); if (global_context.getSharedContextDisagg()->remote_data_store == nullptr) { already_initialize_data_store = false; diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_vector_index.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_vector_index.cpp index 2fc283eb6a8..89f7181f98d 100644 --- a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_vector_index.cpp +++ b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_vector_index.cpp @@ -1708,6 +1708,7 @@ class VectorIndexSegmentOnS3Test TiFlashStorageTestBasic::SetUp(); auto & global_context = TiFlashTestEnv::getGlobalContext(); + global_context.getTMTContext().initS3GCManager(nullptr); global_context.getSharedContextDisagg()->initRemoteDataStore( global_context.getFileProvider(), diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_segment_replace_stable_data.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_segment_replace_stable_data.cpp index 189eb26dda4..07854c0f0a0 100644 --- a/dbms/src/Storages/DeltaMerge/tests/gtest_segment_replace_stable_data.cpp +++ b/dbms/src/Storages/DeltaMerge/tests/gtest_segment_replace_stable_data.cpp @@ -388,6 +388,7 @@ class SegmentReplaceStableDataDisaggregated TiFlashStorageTestBasic::SetUp(); auto & global_context = TiFlashTestEnv::getGlobalContext(); + global_context.getTMTContext().initS3GCManager(nullptr); ASSERT_TRUE(global_context.getSharedContextDisagg()->remote_data_store == nullptr); global_context.getSharedContextDisagg()->initRemoteDataStore( diff --git a/dbms/src/Storages/KVStore/TMTContext.cpp b/dbms/src/Storages/KVStore/TMTContext.cpp index 0ff11218734..51aac88284d 100644 --- a/dbms/src/Storages/KVStore/TMTContext.cpp +++ b/dbms/src/Storages/KVStore/TMTContext.cpp @@ -170,8 +170,7 @@ TMTContext::TMTContext( void TMTContext::initS3GCManager(const TiFlashRaftProxyHelper * proxy_helper) { - if (!raftproxy_config.pd_addrs.empty() && S3::ClientFactory::instance().isEnabled() - && !context.getSharedContextDisagg()->isDisaggregatedComputeMode()) + if (S3::ClientFactory::instance().isEnabled() && !context.getSharedContextDisagg()->isDisaggregatedComputeMode()) { kvstore->fetchProxyConfig(proxy_helper); if (kvstore->getProxyConfigSummay().valid) @@ -185,7 +184,7 @@ void TMTContext::initS3GCManager(const TiFlashRaftProxyHelper * proxy_helper) /*id*/ kvstore->getProxyConfigSummay().engine_addr, etcd_client); } - else + else if (!raftproxy_config.pd_addrs.empty()) { LOG_INFO( Logger::get(), @@ -194,9 +193,19 @@ void TMTContext::initS3GCManager(const TiFlashRaftProxyHelper * proxy_helper) s3gc_owner = OwnerManager::createS3GCOwner(context, /*id*/ raftproxy_config.advertise_engine_addr, etcd_client); } + else + { +#ifdef DBMS_PUBLIC_GTEST + s3gc_owner = OwnerManager::createMockOwner("mocked"); +#else + LOG_INFO(Logger::get(), "quit init s3 gc manager, no effective pd addr"); + return; +#endif + } s3gc_owner->campaignOwner(); // start campaign s3lock_client = std::make_shared(cluster.get(), s3gc_owner); + LOG_INFO(Logger::get(), "Build s3lock client success"); S3::S3GCConfig remote_gc_config; { Int64 gc_method_int = context.getSettingsRef().remote_gc_method; diff --git a/dbms/src/Storages/KVStore/tests/gtest_kvstore_fast_add_peer.cpp b/dbms/src/Storages/KVStore/tests/gtest_kvstore_fast_add_peer.cpp index 1e6c33caf8a..566d6bc3e43 100644 --- a/dbms/src/Storages/KVStore/tests/gtest_kvstore_fast_add_peer.cpp +++ b/dbms/src/Storages/KVStore/tests/gtest_kvstore_fast_add_peer.cpp @@ -63,8 +63,11 @@ class RegionKVStoreTestFAP : public KVStoreTestBase public: void SetUp() override { + // Need S3 for S3 lock client, otherwise UniversalPageStorage::write would block waiting. + DB::tests::TiFlashTestEnv::enableS3Config(); test_path = TiFlashTestEnv::getTemporaryPath("/region_kvs_fap_test"); auto & global_context = TiFlashTestEnv::getGlobalContext(); + global_context.getTMTContext().initS3GCManager(nullptr); // clean data and create path pool instance path_pool = TiFlashTestEnv::createCleanPathPool(test_path); diff --git a/dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp b/dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp index 432281db324..9cc62fb0c98 100644 --- a/dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp +++ b/dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp @@ -155,6 +155,12 @@ bool UniversalPageStorageService::uploadCheckpoint() return false; } auto s3lock_client = tmt.getS3LockClient(); + if (s3lock_client == nullptr) + { + LOG_INFO(log, "Skip checkpoint because s3lock_client is not initialized"); + return false; + } + const bool force_upload = upload_all_at_next_upload.load(); bool upload_done = uploadCheckpointImpl(store_info, s3lock_client, remote_store, force_upload); if (force_upload && upload_done)