Skip to content

Commit

Permalink
Abort uploading checkpoint if s3 lock client is not initialized (ping…
Browse files Browse the repository at this point in the history
…cap#318)

Signed-off-by: Calvin Neo <[email protected]>
  • Loading branch information
CalvinNeo authored Nov 19, 2024
1 parent 3641c0f commit ce36dfc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,7 @@ class VectorIndexSegmentOnS3Test
TiFlashStorageTestBasic::SetUp();

auto & global_context = TiFlashTestEnv::getGlobalContext();
global_context.getTMTContext().initS3GCManager(nullptr);

global_context.getSharedContextDisagg()->initRemoteDataStore(
global_context.getFileProvider(),
Expand Down
14 changes: 11 additions & 3 deletions dbms/src/Storages/KVStore/TMTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,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)
Expand All @@ -179,7 +178,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(),
Expand All @@ -188,6 +187,15 @@ 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<S3::S3LockClient>(cluster.get(), s3gc_owner);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ce36dfc

Please sign in to comment.