Skip to content

Commit

Permalink
remove tiflash-proxy for tiflash_compute mode (pingcap#6588)
Browse files Browse the repository at this point in the history
close pingcap#6666

Signed-off-by: ywqzzy <592838129@qq.com>
  • Loading branch information
guo-shaoge authored and ywqzzy committed Feb 13, 2023
1 parent 6f63b7e commit 938bf07
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
6 changes: 6 additions & 0 deletions dbms/src/Flash/DiagnosticsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ ::grpc::Status DiagnosticsService::server_info(
::diagnosticspb::ServerInfoResponse * response)
try
{
if (context.isDisaggregatedComputeMode())
{
String err_msg = "tiflash compute node should be managed by AutoScaler instead of PD, this grpc should not be called be AutoScaler for now";
LOG_ERROR(log, err_msg);
return ::grpc::Status(::grpc::StatusCode::INTERNAL, err_msg);
}
const TiFlashRaftProxyHelper * helper = context.getTMTContext().getKVStore()->getProxyHelper();
if (helper)
{
Expand Down
2 changes: 2 additions & 0 deletions dbms/src/Interpreters/AsynchronousMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ static void calculateMaxAndSum(Max & max, Sum & sum, T x)

FileUsageStatistics AsynchronousMetrics::getPageStorageFileUsage()
{
RUNTIME_ASSERT(!context.isDisaggregatedComputeMode());
// Get from RegionPersister
auto & tmt = context.getTMTContext();
auto & kvstore = tmt.getKVStore();
Expand Down Expand Up @@ -195,6 +196,7 @@ void AsynchronousMetrics::update()
set("MaxDTBackgroundTasksLength", max_dt_background_tasks_length);
}

if (!context.isDisaggregatedComputeMode())
{
const FileUsageStatistics usage = getPageStorageFileUsage();
set("BlobFileNums", usage.total_file_num);
Expand Down
14 changes: 11 additions & 3 deletions dbms/src/Server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ struct TiFlashProxyConfig

explicit TiFlashProxyConfig(Poco::Util::LayeredConfiguration & config)
{
auto disaggregated_mode = getDisaggregatedMode(config);
// tiflash_compute doesn't need proxy.
if (disaggregated_mode == DisaggregatedMode::Compute)
return;
if (!config.has(config_prefix))
return;

Expand All @@ -268,7 +272,6 @@ struct TiFlashProxyConfig
else
args_map[engine_store_advertise_address] = args_map[engine_store_address];

auto disaggregated_mode = getDisaggregatedMode(config);
args_map[engine_label] = getProxyLabelByDisaggregatedMode(disaggregated_mode);

for (auto && [k, v] : args_map)
Expand Down Expand Up @@ -843,10 +846,10 @@ int Server::main(const std::vector<std::string> & /*args*/)

RaftStoreProxyRunner proxy_runner(RaftStoreProxyRunner::RunRaftStoreProxyParms{&helper, proxy_conf}, log);

proxy_runner.run();

if (proxy_conf.is_proxy_runnable)
{
proxy_runner.run();

LOG_INFO(log, "wait for tiflash proxy initializing");
while (!tiflash_instance_wrap.proxy_helper)
std::this_thread::sleep_for(std::chrono::milliseconds(200));
Expand Down Expand Up @@ -1377,6 +1380,11 @@ int Server::main(const std::vector<std::string> & /*args*/)
WaitCheckRegionReady(tmt_context, *kvstore_ptr, terminate_signals_counter);
}
SCOPE_EXIT({
if (!proxy_conf.is_proxy_runnable)
{
tmt_context.setStatusTerminated();
return;
}
if (proxy_conf.is_proxy_runnable && tiflash_instance_wrap.status != EngineStoreServerStatus::Running)
{
LOG_ERROR(log, "Current status of engine-store is NOT Running, should not happen");
Expand Down
1 change: 1 addition & 0 deletions dbms/src/Storages/Transaction/LearnerRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ LearnerReadSnapshot doLearnerRead(
const LoggerPtr & log)
{
assert(log != nullptr);
RUNTIME_ASSERT(!context.isDisaggregatedComputeMode());

auto & tmt = context.getTMTContext();

Expand Down
9 changes: 8 additions & 1 deletion dbms/src/Storages/Transaction/TMTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static SchemaSyncerPtr createSchemaSyncer(bool exist_pd_addr, bool for_unit_test

TMTContext::TMTContext(Context & context_, const TiFlashRaftConfig & raft_config, const pingcap::ClusterConfig & cluster_config)
: context(context_)
, kvstore(std::make_shared<KVStore>(context, raft_config.snapshot_apply_method))
, kvstore(context_.isDisaggregatedComputeMode() ? nullptr : std::make_shared<KVStore>(context, raft_config.snapshot_apply_method))
, region_table(context)
, background_service(nullptr)
, gc_manager(context)
Expand Down Expand Up @@ -96,6 +96,10 @@ void TMTContext::updateSecurityConfig(const TiFlashRaftConfig & raft_config, con

void TMTContext::restore(PathPool & path_pool, const TiFlashRaftProxyHelper * proxy_helper)
{
// For tiflash_compute mode, kvstore should be nullptr, no need to restore region_table.
if (context.isDisaggregatedComputeMode())
return;

kvstore->restore(path_pool, proxy_helper);
region_table.restore();
store_status = StoreStatus::Ready;
Expand Down Expand Up @@ -200,6 +204,9 @@ const std::unordered_set<std::string> & TMTContext::getIgnoreDatabases() const

void TMTContext::reloadConfig(const Poco::Util::AbstractConfiguration & config)
{
if (context.isDisaggregatedComputeMode())
return;

static constexpr const char * COMPACT_LOG_MIN_PERIOD = "flash.compact_log_min_period";
static constexpr const char * COMPACT_LOG_MIN_ROWS = "flash.compact_log_min_rows";
static constexpr const char * COMPACT_LOG_MIN_BYTES = "flash.compact_log_min_bytes";
Expand Down

0 comments on commit 938bf07

Please sign in to comment.