Skip to content

Commit 990562e

Browse files
Abort uploading checkpoint if s3 lock client is not initialized (#9655) (#9659)
close #9394 Signed-off-by: Calvin Neo <calvinneo1995@gmail.com> Co-authored-by: Calvin Neo <calvinneo1995@gmail.com>
1 parent bf389c9 commit 990562e

File tree

8 files changed

+29
-3
lines changed

8 files changed

+29
-3
lines changed

dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_vector_index.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <Storages/DeltaMerge/LocalIndexerScheduler.h>
2121
#include <Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_test_basic.h>
2222
#include <Storages/DeltaMerge/tests/gtest_dm_vector_index_utils.h>
23+
#include <Storages/KVStore/TMTContext.h>
2324
#include <Storages/KVStore/Types.h>
2425
#include <TestUtils/InputStreamTestUtils.h>
2526

@@ -40,6 +41,8 @@ class DeltaMergeStoreVectorTest
4041
void SetUp() override
4142
{
4243
TiFlashStorageTestBasic::SetUp();
44+
auto & global_context = TiFlashTestEnv::getGlobalContext();
45+
global_context.getTMTContext().initS3GCManager(nullptr);
4346
store = reload();
4447
}
4548

dbms/src/Storages/DeltaMerge/tests/gtest_dm_segment_s3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class SegmentTestS3 : public DB::base::TiFlashStorageTestBasic
6565
ASSERT_TRUE(::DB::tests::TiFlashTestEnv::createBucketIfNotExist(*s3_client));
6666
TiFlashStorageTestBasic::SetUp();
6767
auto & global_context = TiFlashTestEnv::getGlobalContext();
68+
global_context.getTMTContext().initS3GCManager(nullptr);
6869
if (global_context.getSharedContextDisagg()->remote_data_store == nullptr)
6970
{
7071
already_initialize_data_store = false;

dbms/src/Storages/DeltaMerge/tests/gtest_dm_vector_index.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,7 @@ class VectorIndexSegmentOnS3Test
17081708
TiFlashStorageTestBasic::SetUp();
17091709

17101710
auto & global_context = TiFlashTestEnv::getGlobalContext();
1711+
global_context.getTMTContext().initS3GCManager(nullptr);
17111712

17121713
global_context.getSharedContextDisagg()->initRemoteDataStore(
17131714
global_context.getFileProvider(),

dbms/src/Storages/DeltaMerge/tests/gtest_segment_read_task.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class DMStoreForSegmentReadTaskTest : public DeltaMergeStoreTest
149149
void SetUp() override
150150
{
151151
DeltaMergeStoreTest::SetUp();
152+
auto & global_context = TiFlashTestEnv::getGlobalContext();
153+
global_context.getTMTContext().initS3GCManager(nullptr);
152154
initReadNodePageCacheIfUninitialized();
153155
}
154156

dbms/src/Storages/DeltaMerge/tests/gtest_segment_replace_stable_data.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ class SegmentReplaceStableDataDisaggregated
388388
TiFlashStorageTestBasic::SetUp();
389389

390390
auto & global_context = TiFlashTestEnv::getGlobalContext();
391+
global_context.getTMTContext().initS3GCManager(nullptr);
391392

392393
ASSERT_TRUE(global_context.getSharedContextDisagg()->remote_data_store == nullptr);
393394
global_context.getSharedContextDisagg()->initRemoteDataStore(

dbms/src/Storages/KVStore/TMTContext.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ TMTContext::TMTContext(
170170

171171
void TMTContext::initS3GCManager(const TiFlashRaftProxyHelper * proxy_helper)
172172
{
173-
if (!raftproxy_config.pd_addrs.empty() && S3::ClientFactory::instance().isEnabled()
174-
&& !context.getSharedContextDisagg()->isDisaggregatedComputeMode())
173+
if (S3::ClientFactory::instance().isEnabled() && !context.getSharedContextDisagg()->isDisaggregatedComputeMode())
175174
{
176175
kvstore->fetchProxyConfig(proxy_helper);
177176
if (kvstore->getProxyConfigSummay().valid)
@@ -185,7 +184,7 @@ void TMTContext::initS3GCManager(const TiFlashRaftProxyHelper * proxy_helper)
185184
/*id*/ kvstore->getProxyConfigSummay().engine_addr,
186185
etcd_client);
187186
}
188-
else
187+
else if (!raftproxy_config.pd_addrs.empty())
189188
{
190189
LOG_INFO(
191190
Logger::get(),
@@ -194,9 +193,19 @@ void TMTContext::initS3GCManager(const TiFlashRaftProxyHelper * proxy_helper)
194193
s3gc_owner
195194
= OwnerManager::createS3GCOwner(context, /*id*/ raftproxy_config.advertise_engine_addr, etcd_client);
196195
}
196+
else
197+
{
198+
#ifdef DBMS_PUBLIC_GTEST
199+
s3gc_owner = OwnerManager::createMockOwner("mocked");
200+
#else
201+
LOG_INFO(Logger::get(), "quit init s3 gc manager, no effective pd addr");
202+
return;
203+
#endif
204+
}
197205
s3gc_owner->campaignOwner(); // start campaign
198206
s3lock_client = std::make_shared<S3::S3LockClient>(cluster.get(), s3gc_owner);
199207

208+
LOG_INFO(Logger::get(), "Build s3lock client success");
200209
S3::S3GCConfig remote_gc_config;
201210
{
202211
Int64 gc_method_int = context.getSettingsRef().remote_gc_method;

dbms/src/Storages/KVStore/tests/gtest_kvstore_fast_add_peer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ class RegionKVStoreTestFAP : public KVStoreTestBase
6363
public:
6464
void SetUp() override
6565
{
66+
// Need S3 for S3 lock client, otherwise UniversalPageStorage::write would block waiting.
67+
DB::tests::TiFlashTestEnv::enableS3Config();
6668
test_path = TiFlashTestEnv::getTemporaryPath("/region_kvs_fap_test");
6769
auto & global_context = TiFlashTestEnv::getGlobalContext();
70+
global_context.getTMTContext().initS3GCManager(nullptr);
6871
// clean data and create path pool instance
6972
path_pool = TiFlashTestEnv::createCleanPathPool(test_path);
7073

dbms/src/Storages/Page/V3/Universal/UniversalPageStorageService.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ bool UniversalPageStorageService::uploadCheckpoint()
155155
return false;
156156
}
157157
auto s3lock_client = tmt.getS3LockClient();
158+
if (s3lock_client == nullptr)
159+
{
160+
LOG_INFO(log, "Skip checkpoint because s3lock_client is not initialized");
161+
return false;
162+
}
163+
158164
const bool force_upload = upload_all_at_next_upload.load();
159165
bool upload_done = uploadCheckpointImpl(store_info, s3lock_client, remote_store, force_upload);
160166
if (force_upload && upload_done)

0 commit comments

Comments
 (0)