Skip to content

Commit

Permalink
schemeshard: remove schemeshard_utils.h from common dependencies (#12012
Browse files Browse the repository at this point in the history
)

Remove `schemeshard_utils.h` from `schemeshard_impl.h` includes.
Move `TShardDeleter` and `TSelfPinger` out of `schemeshard_utils.*`.

This is part of "improve schemeshard operation build-time" effort (#10633).
  • Loading branch information
ijon authored Nov 27, 2024
1 parent c381728 commit bb312c5
Show file tree
Hide file tree
Showing 43 changed files with 402 additions and 302 deletions.
3 changes: 2 additions & 1 deletion ydb/core/tx/schemeshard/schemeshard__init.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "schemeshard_impl.h"
#include "schemeshard_utils.h" // for PQGroupReserve

#include <ydb/core/protos/table_stats.pb.h> // for TStoragePoolsStats
#include <ydb/core/scheme/scheme_types_proto.h>
#include <ydb/core/tablet/tablet_exception.h>
#include <ydb/core/tablet_flat/flat_cxx_database.h>
#include <ydb/core/tx/schemeshard/schemeshard_utils.h>
#include <ydb/core/util/pb.h>

namespace NKikimr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#define LOG_D(stream) LOG_DEBUG_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
#define LOG_I(stream) LOG_INFO_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "schemeshard__operation_part.h"
#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/tx/schemeshard/backup/constants.h>

#include <ydb/core/engine/mkql_proto.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "schemeshard_impl.h"
#include "schemeshard__operation_common.h"
#include "schemeshard__operation_common_subdomain.h"
#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/base/subdomain.h>
#include <ydb/core/base/hive.h>
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for PQGroupReserve

#include <ydb/core/base/subdomain.h>
#include <ydb/core/mind/hive/hive.h>
#include <ydb/core/persqueue/config/config.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/base/subdomain.h>
#include <ydb/core/base/hive.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/base/table_index.h>
#include <ydb/core/protos/flat_tx_scheme.pb.h>
#include <ydb/core/protos/flat_scheme_op.pb.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <ydb/core/scheme/scheme_types_proto.h>

#include <yql/essentials/minikql/mkql_type_ops.h>

#include <utility>

namespace NKikimr::NSchemeShard::NExternalTable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"
#include "schemeshard_path_element.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/base/path.h>
#include <ydb/core/protos/flat_tx_scheme.pb.h>
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "schemeshard_tx_infly.h"
#include "schemeshard_cdc_stream_common.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/mind/hive/hive.h>
#include <ydb/core/base/subdomain.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"
#include "schemeshard_path_element.h"
#include "schemeshard_utils.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/base/table_vector_index.h>
#include <ydb/core/protos/flat_tx_scheme.pb.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include "schemeshard_cdc_stream_common.h"
#include "schemeshard_impl.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"
#include "schemeshard_path_element.h"
#include "schemeshard_utils.h"
#include "schemeshard__op_traits.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/protos/flat_tx_scheme.pb.h>
#include <ydb/core/protos/flat_scheme_op.pb.h>

Expand Down Expand Up @@ -274,7 +273,7 @@ TVector<ISubOperation::TPtr> CreateIndexedTable(TOperationId nextId, const TTxTr

*scheme.MutableCreateTable() = std::move(implTableDesc);

return CreateNewTable(NextPartId(nextId, result), scheme);
return CreateNewTable(NextPartId(nextId, result), scheme);
};

const auto& implTableColumns = indexes.at(indexDescription.GetName());
Expand All @@ -285,7 +284,7 @@ TVector<ISubOperation::TPtr> CreateIndexedTable(TOperationId nextId, const TTxTr
userLevelDesc = indexDescription.GetIndexImplTableDescriptions(0);
userPostingDesc = indexDescription.GetIndexImplTableDescriptions(1);
}

result.push_back(createIndexImplTable(CalcVectorKmeansTreeLevelImplTableDesc(baseTableDescription.GetPartitionConfig(), userLevelDesc)));
result.push_back(createIndexImplTable(CalcVectorKmeansTreePostingImplTableDesc(baseTableDescription, baseTableDescription.GetPartitionConfig(), implTableColumns, userPostingDesc)));
} else {
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "schemeshard_impl.h"
#include "schemeshard__op_traits.h"

#include "schemeshard_utils.h" // for PQGroupReserve

#include <library/cpp/int128/int128.h>

#include <ydb/core/base/subdomain.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include "schemeshard__operation_create_cdc_stream.h"

#define LOG_D(stream) LOG_DEBUG_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "schemeshard_impl.h"
#include "schemeshard__op_traits.h"

#include "schemeshard_utils.h" // for IsAllowedKeyType

#include <ydb/core/protos/flat_scheme_op.pb.h>
#include <ydb/core/protos/datashard_config.pb.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include "schemeshard__operation_drop_cdc_stream.h"

#define LOG_D(stream) LOG_DEBUG_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
#define LOG_I(stream) LOG_INFO_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"
#include "schemeshard_path_element.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include "schemeshard_impl.h"

Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for PQGroupReserve

#include <ydb/core/base/subdomain.h>
#include <ydb/core/persqueue/events/global.h>

Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/base/path.h>
#include <ydb/core/mind/hive/hive.h>
#include <ydb/core/protos/flat_tx_scheme.pb.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "schemeshard_impl.h"

#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/base/path.h>
#include <ydb/core/protos/flat_tx_scheme.pb.h>
#include <ydb/core/protos/flat_scheme_op.pb.h>
Expand Down
3 changes: 2 additions & 1 deletion ydb/core/tx/schemeshard/schemeshard__operation_part.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "schemeshard__operation_part.h"
#include "schemeshard_impl.h"
#include "schemeshard_utils.h" // for TransactionTemplate
#include "schemeshard_path.h"

#include <ydb/core/base/hive.h>
Expand Down Expand Up @@ -164,7 +165,7 @@ ISubOperation::TPtr CascadeDropTableChildren(TVector<ISubOperation::TPtr>& resul
}

for (auto& [implName, implPathId] : child.Base()->GetChildren()) {
Y_ABORT_UNLESS(NTableIndex::IsImplTable(implName)
Y_ABORT_UNLESS(NTableIndex::IsImplTable(implName)
|| implName == "streamImpl"
, "unexpected name %s", implName.c_str());

Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/schemeshard/schemeshard__table_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <ydb/core/base/appdata.h>
#include <ydb/core/base/cputime.h>
#include <ydb/core/protos/sys_view.pb.h>
#include <ydb/core/protos/table_stats.pb.h>

namespace {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "schemeshard_impl.h"
#include <ydb/core/base/appdata.h>
#include <ydb/core/tx/tx_proxy/proxy.h>
#include <ydb/core/protos/table_stats.pb.h>

namespace NKikimr {
namespace NSchemeShard {
Expand Down Expand Up @@ -44,7 +45,7 @@ TSerializedCellVec ChooseSplitKeyByHistogram(const NKikimrTableStats::THistogram
for (const auto& point : histogram.GetBuckets()) {
ui64 leftSize = Min(point.GetValue(), total);
ui64 rightSize = total - leftSize;

// search for a median point at which abs(leftSize - rightSize) is minimum
ui64 sizesDiff = Max(leftSize, rightSize) - Min(leftSize, rightSize);
if (idxMedDiff > sizesDiff) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "schemeshard_build_index_helpers.h"
#include "schemeshard_build_index_tx_base.h"
#include "schemeshard_impl.h"
#include "schemeshard_utils.h"
#include "schemeshard_utils.h" // for NTableIndex::CommonCheck

#include <ydb/core/ydb_convert/table_settings.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "schemeshard_build_index.h"
#include "schemeshard_impl.h"
#include "schemeshard_utils.h" // for NTableIndex::ExtractInfo
#include "schemeshard_build_index_helpers.h"
#include "schemeshard_build_index_tx_base.h"

Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/schemeshard/schemeshard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <ydb/core/base/appdata.h>
#include <ydb/core/base/tx_processing.h>
#include <ydb/core/protos/feature_flags.pb.h>
#include <ydb/core/protos/table_stats.pb.h> // for TStoragePoolsStats
#include <ydb/core/engine/mkql_proto.h>
#include <ydb/core/sys_view/partition_stats/partition_stats.h>
#include <ydb/core/statistics/events.h>
Expand Down
3 changes: 2 additions & 1 deletion ydb/core/tx/schemeshard/schemeshard_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include "schemeshard_domain_links.h"
#include "schemeshard_info_types.h"
#include "schemeshard_tx_infly.h"
#include "schemeshard_utils.h"
#include "schemeshard_self_pinger.h"
#include "schemeshard_shard_deleter.h"
#include "schemeshard_schema.h"
#include "schemeshard__operation.h"
#include "schemeshard__stats.h"
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/schemeshard/schemeshard_info_types.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "schemeshard_info_types.h"
#include "schemeshard_path.h"
#include "schemeshard_utils.h"
#include "schemeshard_utils.h" // for IsValidColumnName

#include <ydb/core/base/appdata.h>
#include <ydb/core/base/tx_processing.h>
Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/schemeshard/schemeshard_path_describer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <ydb/core/base/appdata.h>
#include <ydb/core/engine/mkql_proto.h>
#include <ydb/core/protos/flat_tx_scheme.pb.h>
#include <ydb/core/protos/table_stats.pb.h>
#include <ydb/core/scheme/scheme_types_proto.h>
#include <ydb/public/api/protos/annotations/sensitive.pb.h>

Expand Down
62 changes: 62 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard_self_pinger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "schemeshard_self_pinger.h"
#include "schemeshard.h" // for TEvMeasureSelfResponseTime and TEvWakeupToMeasureSelfResponseTime

#include <ydb/core/protos/counters_schemeshard.pb.h>

namespace NKikimr::NSchemeShard {

void TSelfPinger::Handle(TEvSchemeShard::TEvMeasureSelfResponseTime::TPtr &ev, const NActors::TActorContext &ctx) {
Y_UNUSED(ev);
TInstant now = AppData(ctx)->TimeProvider->Now();
TDuration responseTime = now - SelfPingSentTime;
LastResponseTime = responseTime;
TabletCounters->Simple()[COUNTER_RESPONSE_TIME_USEC].Set(LastResponseTime.MicroSeconds());
if (responseTime.MilliSeconds() > 1000) {
LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
"Schemeshard " << TabletId << " response time is " << responseTime.MilliSeconds() << " msec");
}
SelfPingInFlight = false;
if (responseTime > SELF_PING_INTERVAL) {
DoSelfPing(ctx);
} else {
ScheduleSelfPingWakeup(ctx);
}
}

void TSelfPinger::Handle(TEvSchemeShard::TEvWakeupToMeasureSelfResponseTime::TPtr &ev, const NActors::TActorContext &ctx) {
Y_UNUSED(ev);
SelfPingWakeupScheduled = false;
DoSelfPing(ctx);
}

void TSelfPinger::OnAnyEvent(const NActors::TActorContext &ctx) {
TInstant now = AppData(ctx)->TimeProvider->Now();
if (SelfPingInFlight) {
TDuration responseTime = now - SelfPingSentTime;
// Increase measured response time is ping is taking longer than then the previous one
LastResponseTime = Max(LastResponseTime, responseTime);
TabletCounters->Simple()[COUNTER_RESPONSE_TIME_USEC].Set(LastResponseTime.MicroSeconds());
} else if ((now - SelfPingWakeupScheduledTime) > SELF_PING_INTERVAL) {
DoSelfPing(ctx);
}
}

void TSelfPinger::DoSelfPing(const NActors::TActorContext &ctx) {
if (SelfPingInFlight)
return;

ctx.Send(ctx.SelfID, new TEvSchemeShard::TEvMeasureSelfResponseTime);
SelfPingSentTime = AppData(ctx)->TimeProvider->Now();
SelfPingInFlight = true;
}

void TSelfPinger::ScheduleSelfPingWakeup(const NActors::TActorContext &ctx) {
if (SelfPingWakeupScheduled)
return;

ctx.Schedule(SELF_PING_INTERVAL, new TEvSchemeShard::TEvWakeupToMeasureSelfResponseTime);
SelfPingWakeupScheduled = true;
SelfPingWakeupScheduledTime = AppData(ctx)->TimeProvider->Now();
}

} // namespace NKikimr::NSchemeShard
Loading

0 comments on commit bb312c5

Please sign in to comment.