Skip to content

Commit c5975f0

Browse files
authored
Merge ffb1cc4 into 1f307a1
2 parents 1f307a1 + ffb1cc4 commit c5975f0

File tree

24 files changed

+188
-42
lines changed

24 files changed

+188
-42
lines changed

ydb/core/fq/libs/actors/run_actor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,11 @@ class TRunActor : public NActors::TActorBootstrapped<TRunActor> {
779779
mkqlDefaultLimit = 8_GB;
780780
}
781781

782+
// This part is for backward compatibility. TODO: remove this part after migration to TS3GatewayConfig
782783
auto s3ReadDefaultInflightLimit = Params.Config.GetReadActorsFactoryConfig().GetS3ReadActorFactoryConfig().GetDataInflight();
784+
if (s3ReadDefaultInflightLimit == 0) {
785+
s3ReadDefaultInflightLimit = Params.Config.GetGateways().GetS3().GetDataInflight();
786+
}
783787
if (s3ReadDefaultInflightLimit == 0) {
784788
s3ReadDefaultInflightLimit = 200_MB;
785789
}
@@ -1936,7 +1940,7 @@ class TRunActor : public NActors::TActorBootstrapped<TRunActor> {
19361940

19371941
{
19381942
dataProvidersInit.push_back(GetS3DataProviderInitializer(Params.S3Gateway, Params.CredentialsFactory,
1939-
Params.Config.GetReadActorsFactoryConfig().GetS3ReadActorFactoryConfig().GetAllowLocalFiles()));
1943+
Params.Config.GetReadActorsFactoryConfig().HasS3ReadActorFactoryConfig() ? Params.Config.GetReadActorsFactoryConfig().GetS3ReadActorFactoryConfig().GetAllowLocalFiles() : Params.Config.GetGateways().GetS3().GetAllowLocalFiles())); // This part is for backward compatibility. TODO: remove this part after migration to TS3GatewayConfig
19401944
}
19411945

19421946
{

ydb/core/fq/libs/init/init.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ void Init(
198198
if (protoConfig.GetPrivateApi().GetEnabled()) {
199199
const auto& s3readConfig = protoConfig.GetReadActorsFactoryConfig().GetS3ReadActorFactoryConfig();
200200
auto s3HttpRetryPolicy = NYql::GetHTTPDefaultRetryPolicy(NYql::THttpRetryPolicyOptions{.MaxTime = TDuration::Max(), .RetriedCurlCodes = NYql::FqRetriedCurlCodes()});
201-
NYql::NDq::TS3ReadActorFactoryConfig readActorFactoryCfg;
201+
NYql::NDq::TS3ReadActorFactoryConfig readActorFactoryCfg = NYql::NDq::CreateReadActorFactoryConfig(protoConfig.GetGateways().GetS3());
202+
203+
// These fillings were left for the backward compatibility. TODO: remove this part after migration to TS3GatewayConfig
202204
if (const ui64 rowsInBatch = s3readConfig.GetRowsInBatch()) {
203205
readActorFactoryCfg.RowsInBatch = rowsInBatch;
204206
}
@@ -208,22 +210,9 @@ void Init(
208210
if (const ui64 dataInflight = s3readConfig.GetDataInflight()) {
209211
readActorFactoryCfg.DataInflight = dataInflight;
210212
}
211-
for (auto& formatSizeLimit: protoConfig.GetGateways().GetS3().GetFormatSizeLimit()) {
212-
if (formatSizeLimit.GetName()) { // ignore unnamed limits
213-
readActorFactoryCfg.FormatSizeLimits.emplace(
214-
formatSizeLimit.GetName(), formatSizeLimit.GetFileSizeLimit());
215-
}
216-
}
217-
if (protoConfig.GetGateways().GetS3().HasFileSizeLimit()) {
218-
readActorFactoryCfg.FileSizeLimit =
219-
protoConfig.GetGateways().GetS3().GetFileSizeLimit();
220-
}
221-
if (protoConfig.GetGateways().GetS3().HasBlockFileSizeLimit()) {
222-
readActorFactoryCfg.BlockFileSizeLimit =
223-
protoConfig.GetGateways().GetS3().GetBlockFileSizeLimit();
224-
}
213+
225214
RegisterDqInputTransformLookupActorFactory(*asyncIoFactory);
226-
RegisterDqPqReadActorFactory(*asyncIoFactory, yqSharedResources->UserSpaceYdbDriver, credentialsFactory);
215+
RegisterDqPqReadActorFactory(*asyncIoFactory, yqSharedResources->UserSpaceYdbDriver, credentialsFactory, yqCounters->GetSubgroup("subsystem", "DqSourceTracker"));
227216
RegisterYdbReadActorFactory(*asyncIoFactory, yqSharedResources->UserSpaceYdbDriver, credentialsFactory);
228217

229218
s3ActorsFactory->RegisterS3ReadActorFactory(*asyncIoFactory, credentialsFactory, httpGateway, s3HttpRetryPolicy, readActorFactoryCfg,

ydb/core/grpc_services/ydb_over_fq/execute_data_query.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ class ExecuteDataQueryRPC
127127
)
128128

129129
void HandleResultSets(const TString& queryId, const TActorContext& ctx) {
130+
if (ResultSetSizes_.empty()) {
131+
SendReply(ctx);
132+
return;
133+
}
134+
130135
Become(&ExecuteDataQueryRPC::GatherResultSetsState);
131136
QueryId_ = queryId;
132137
MakeLocalCall(CreateResultSetRequest(queryId, 0, 0), ctx);

ydb/core/kqp/compute_actor/kqp_compute_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ NYql::NDq::IDqAsyncIoFactory::TPtr CreateKqpAsyncIoFactory(
7878

7979
if (federatedQuerySetup) {
8080
auto s3HttpRetryPolicy = NYql::GetHTTPDefaultRetryPolicy(NYql::THttpRetryPolicyOptions{.RetriedCurlCodes = NYql::FqRetriedCurlCodes()});
81-
s3ActorsFactory->RegisterS3ReadActorFactory(*factory, federatedQuerySetup->CredentialsFactory, federatedQuerySetup->HttpGateway, s3HttpRetryPolicy);
81+
s3ActorsFactory->RegisterS3ReadActorFactory(*factory, federatedQuerySetup->CredentialsFactory, federatedQuerySetup->HttpGateway, s3HttpRetryPolicy, federatedQuerySetup->S3ReadActorFactoryConfig);
8282
s3ActorsFactory->RegisterS3WriteActorFactory(*factory, federatedQuerySetup->CredentialsFactory, federatedQuerySetup->HttpGateway, s3HttpRetryPolicy);
8383

8484
if (federatedQuerySetup->ConnectorClient) {

ydb/core/kqp/federated_query/kqp_federated_query_helpers.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ namespace NKikimr::NKqp {
7272

7373
S3GatewayConfig = queryServiceConfig.GetS3();
7474

75+
S3ReadActorFactoryConfig = NYql::NDq::CreateReadActorFactoryConfig(S3GatewayConfig);
76+
7577
YtGatewayConfig = queryServiceConfig.GetYt();
7678
YtGateway = MakeYtGateway(appData->FunctionRegistry, queryServiceConfig);
7779

@@ -127,7 +129,8 @@ namespace NKikimr::NKqp {
127129
GenericGatewaysConfig,
128130
YtGatewayConfig,
129131
YtGateway,
130-
nullptr};
132+
nullptr,
133+
S3ReadActorFactoryConfig};
131134

132135
// Init DatabaseAsyncResolver only if all requirements are met
133136
if (DatabaseResolverActorId && MdbEndpointGenerator &&

ydb/core/kqp/federated_query/kqp_federated_query_helpers.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <ydb/library/yql/providers/common/http_gateway/yql_http_gateway.h>
1010
#include <ydb/library/yql/providers/common/token_accessor/client/factory.h>
1111
#include <ydb/library/yql/providers/generic/connector/libcpp/client.h>
12+
#include <ydb/library/yql/providers/s3/actors_factory/yql_s3_actors_factory.h>
1213
#include <ydb/library/yql/providers/yt/provider/yql_yt_gateway.h>
1314

1415
namespace NKikimrConfig {
@@ -30,6 +31,7 @@ namespace NKikimr::NKqp {
3031
NYql::TYtGatewayConfig YtGatewayConfig;
3132
NYql::IYtGateway::TPtr YtGateway;
3233
NMiniKQL::TComputationNodeFactory ComputationFactory;
34+
NYql::NDq::TS3ReadActorFactoryConfig S3ReadActorFactoryConfig;
3335
};
3436

3537
struct IKqpFederatedQuerySetupFactory {
@@ -65,6 +67,7 @@ namespace NKikimr::NKqp {
6567
NYql::NConnector::IClient::TPtr ConnectorClient;
6668
std::optional<NActors::TActorId> DatabaseResolverActorId;
6769
NYql::IMdbEndpointGenerator::TPtr MdbEndpointGenerator;
70+
NYql::NDq::TS3ReadActorFactoryConfig S3ReadActorFactoryConfig;
6871
};
6972

7073
struct TKqpFederatedQuerySetupFactoryMock: public IKqpFederatedQuerySetupFactory {
@@ -94,7 +97,7 @@ namespace NKikimr::NKqp {
9497

9598
std::optional<TKqpFederatedQuerySetup> Make(NActors::TActorSystem*) override {
9699
return TKqpFederatedQuerySetup{
97-
HttpGateway, ConnectorClient, CredentialsFactory, DatabaseAsyncResolver, S3GatewayConfig, GenericGatewayConfig, YtGatewayConfig, YtGateway, ComputationFactories};
100+
HttpGateway, ConnectorClient, CredentialsFactory, DatabaseAsyncResolver, S3GatewayConfig, GenericGatewayConfig, YtGatewayConfig, YtGateway, ComputationFactories, S3ReadActorFactoryConfig};
98101
}
99102

100103
private:
@@ -107,6 +110,7 @@ namespace NKikimr::NKqp {
107110
NYql::TYtGatewayConfig YtGatewayConfig;
108111
NYql::IYtGateway::TPtr YtGateway;
109112
NMiniKQL::TComputationNodeFactory ComputationFactories;
113+
NYql::NDq::TS3ReadActorFactoryConfig S3ReadActorFactoryConfig;
110114
};
111115

112116
IKqpFederatedQuerySetupFactory::TPtr MakeKqpFederatedQuerySetupFactory(

ydb/core/kqp/ut/indexes/kqp_indexes_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ TIntrusivePtr<IKqpHost> CreateKikimrQueryProcessor(TIntrusivePtr<IKqpGateway> ga
5353
UNIT_ASSERT(TryParseFromTextFormat(defaultSettingsStream, defaultSettings));
5454
kikimrConfig->Init(defaultSettings.GetDefaultSettings(), cluster, settings, true);
5555

56-
auto federatedQuerySetup = std::make_optional<TKqpFederatedQuerySetup>({NYql::IHTTPGateway::Make(), nullptr, nullptr, nullptr, {}, {}, {}, nullptr, nullptr});
56+
auto federatedQuerySetup = std::make_optional<TKqpFederatedQuerySetup>({NYql::IHTTPGateway::Make(), nullptr, nullptr, nullptr, {}, {}, {}, nullptr, nullptr, {}});
5757
return NKqp::CreateKqpHost(gateway, cluster, "/Root", kikimrConfig, moduleResolver,
5858
federatedQuerySetup, nullptr, nullptr, {}, funcRegistry, funcRegistry, keepConfigChanges, nullptr, actorSystem);
5959
}

ydb/library/yql/providers/common/proto/gateways_config.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ message TS3GatewayConfig {
398398
optional uint64 RegexpCacheSize = 14;
399399
optional uint64 GeneratorPathsLimit = 15;
400400
optional uint64 MaxListingResultSizePerPartition = 16;
401+
optional uint64 RowsInBatch = 17; // Default = 1000
402+
optional uint64 MaxInflight = 18; // Default = 20
403+
optional uint64 DataInflight = 19; // Default = 200 MB
404+
optional bool AllowLocalFiles = 20;
401405

402406
repeated TAttr DefaultSettings = 100;
403407
}

ydb/library/yql/providers/pq/async_io/dq_pq_read_actor.cpp

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,30 @@ struct TEvPrivate {
8585
} // namespace
8686

8787
class TDqPqReadActor : public NActors::TActor<TDqPqReadActor>, public IDqComputeActorAsyncInput {
88+
struct TMetrics {
89+
TMetrics(const TTxId& txId, ui64 taskId, const ::NMonitoring::TDynamicCounterPtr& counters)
90+
: TxId(std::visit([](auto arg) { return ToString(arg); }, txId))
91+
, Counters(counters) {
92+
SubGroup = Counters->GetSubgroup("sink", "PqRead");
93+
auto sink = SubGroup->GetSubgroup("tx_id", TxId);
94+
auto task = sink->GetSubgroup("task_id", ToString(taskId));
95+
InFlyAsyncInputData = task->GetCounter("InFlyAsyncInputData");
96+
InFlySubscribe = task->GetCounter("InFlySubscribe");
97+
AsyncInputDataRate = task->GetCounter("AsyncInputDataRate", true);
98+
}
99+
100+
~TMetrics() {
101+
SubGroup->RemoveSubgroup("id", TxId);
102+
}
103+
104+
TString TxId;
105+
::NMonitoring::TDynamicCounterPtr Counters;
106+
::NMonitoring::TDynamicCounterPtr SubGroup;
107+
::NMonitoring::TDynamicCounters::TCounterPtr InFlyAsyncInputData;
108+
::NMonitoring::TDynamicCounters::TCounterPtr InFlySubscribe;
109+
::NMonitoring::TDynamicCounters::TCounterPtr AsyncInputDataRate;
110+
};
111+
88112
public:
89113
using TPartitionKey = std::pair<TString, ui64>; // Cluster, partition id.
90114
using TDebugOffsets = TMaybe<std::pair<ui64, ui64>>;
@@ -100,10 +124,12 @@ class TDqPqReadActor : public NActors::TActor<TDqPqReadActor>, public IDqCompute
100124
NYdb::TDriver driver,
101125
std::shared_ptr<NYdb::ICredentialsProviderFactory> credentialsProviderFactory,
102126
const NActors::TActorId& computeActorId,
127+
const ::NMonitoring::TDynamicCounterPtr& counters,
103128
i64 bufferSize)
104129
: TActor<TDqPqReadActor>(&TDqPqReadActor::StateFunc)
105130
, InputIndex(inputIndex)
106131
, TxId(txId)
132+
, Metrics(txId, taskId, counters)
107133
, BufferSize(bufferSize)
108134
, HolderFactory(holderFactory)
109135
, LogPrefix(TStringBuilder() << "SelfId: " << this->SelfId() << ", TxId: " << TxId << ", task: " << taskId << ". PQ source. ")
@@ -245,9 +271,14 @@ class TDqPqReadActor : public NActors::TActor<TDqPqReadActor>, public IDqCompute
245271
hFunc(TEvPrivate::TEvSourceDataReady, Handle);
246272
)
247273

248-
void Handle(TEvPrivate::TEvSourceDataReady::TPtr&) {
274+
void Handle(TEvPrivate::TEvSourceDataReady::TPtr& ev) {
249275
SRC_LOG_T("SessionId: " << GetSessionId() << " Source data ready");
250276
SubscribedOnEvent = false;
277+
if (ev.Get()->Cookie) {
278+
Metrics.InFlySubscribe->Dec();
279+
}
280+
Metrics.InFlyAsyncInputData->Set(1);
281+
Metrics.AsyncInputDataRate->Inc();
251282
Send(ComputeActorId, new TEvNewAsyncInputDataArrived(InputIndex));
252283
}
253284

@@ -282,6 +313,7 @@ class TDqPqReadActor : public NActors::TActor<TDqPqReadActor>, public IDqCompute
282313
}
283314

284315
i64 GetAsyncInputData(NKikimr::NMiniKQL::TUnboxedValueBatch& buffer, TMaybe<TInstant>& watermark, bool&, i64 freeSpace) override {
316+
Metrics.InFlyAsyncInputData->Set(0);
285317
SRC_LOG_T("SessionId: " << GetSessionId() << " GetAsyncInputData freeSpace = " << freeSpace);
286318

287319
const auto now = TInstant::Now();
@@ -387,9 +419,10 @@ class TDqPqReadActor : public NActors::TActor<TDqPqReadActor>, public IDqCompute
387419
void SubscribeOnNextEvent() {
388420
if (!SubscribedOnEvent) {
389421
SubscribedOnEvent = true;
422+
Metrics.InFlySubscribe->Inc();
390423
NActors::TActorSystem* actorSystem = NActors::TActivationContext::ActorSystem();
391424
EventFuture = GetReadSession().WaitEvent().Subscribe([actorSystem, selfId = SelfId()](const auto&){
392-
actorSystem->Send(selfId, new TEvPrivate::TEvSourceDataReady());
425+
actorSystem->Send(selfId, new TEvPrivate::TEvSourceDataReady(), 0, 1);
393426
});
394427
}
395428
}
@@ -595,6 +628,7 @@ class TDqPqReadActor : public NActors::TActor<TDqPqReadActor>, public IDqCompute
595628
const ui64 InputIndex;
596629
TDqAsyncStats IngressStats;
597630
const TTxId TxId;
631+
TMetrics Metrics;
598632
const i64 BufferSize;
599633
const THolderFactory& HolderFactory;
600634
const TString LogPrefix;
@@ -629,6 +663,7 @@ std::pair<IDqComputeActorAsyncInput*, NActors::IActor*> CreateDqPqReadActor(
629663
ISecuredServiceAccountCredentialsFactory::TPtr credentialsFactory,
630664
const NActors::TActorId& computeActorId,
631665
const NKikimr::NMiniKQL::THolderFactory& holderFactory,
666+
const ::NMonitoring::TDynamicCounterPtr& counters,
632667
i64 bufferSize
633668
)
634669
{
@@ -653,15 +688,16 @@ std::pair<IDqComputeActorAsyncInput*, NActors::IActor*> CreateDqPqReadActor(
653688
std::move(driver),
654689
CreateCredentialsProviderFactoryForStructuredToken(credentialsFactory, token, addBearerToToken),
655690
computeActorId,
691+
counters,
656692
bufferSize
657693
);
658694

659695
return {actor, actor};
660696
}
661697

662-
void RegisterDqPqReadActorFactory(TDqAsyncIoFactory& factory, NYdb::TDriver driver, ISecuredServiceAccountCredentialsFactory::TPtr credentialsFactory) {
698+
void RegisterDqPqReadActorFactory(TDqAsyncIoFactory& factory, NYdb::TDriver driver, ISecuredServiceAccountCredentialsFactory::TPtr credentialsFactory, const ::NMonitoring::TDynamicCounterPtr& counters) {
663699
factory.RegisterSource<NPq::NProto::TDqPqTopicSource>("PqSource",
664-
[driver = std::move(driver), credentialsFactory = std::move(credentialsFactory)](
700+
[driver = std::move(driver), credentialsFactory = std::move(credentialsFactory), counters](
665701
NPq::NProto::TDqPqTopicSource&& settings,
666702
IDqAsyncIoFactory::TSourceArguments&& args)
667703
{
@@ -678,6 +714,7 @@ void RegisterDqPqReadActorFactory(TDqAsyncIoFactory& factory, NYdb::TDriver driv
678714
credentialsFactory,
679715
args.ComputeActorId,
680716
args.HolderFactory,
717+
counters,
681718
PQReadDefaultFreeSpace);
682719
});
683720

ydb/library/yql/providers/pq/async_io/dq_pq_read_actor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ std::pair<IDqComputeActorAsyncInput*, NActors::IActor*> CreateDqPqReadActor(
3434
ISecuredServiceAccountCredentialsFactory::TPtr credentialsFactory,
3535
const NActors::TActorId& computeActorId,
3636
const NKikimr::NMiniKQL::THolderFactory& holderFactory,
37+
const ::NMonitoring::TDynamicCounterPtr& counters,
3738
i64 bufferSize = PQReadDefaultFreeSpace
3839
);
3940

40-
void RegisterDqPqReadActorFactory(TDqAsyncIoFactory& factory, NYdb::TDriver driver, ISecuredServiceAccountCredentialsFactory::TPtr credentialsFactory);
41+
void RegisterDqPqReadActorFactory(TDqAsyncIoFactory& factory, NYdb::TDriver driver, ISecuredServiceAccountCredentialsFactory::TPtr credentialsFactory, const ::NMonitoring::TDynamicCounterPtr& counters = MakeIntrusive<::NMonitoring::TDynamicCounters>());
4142

4243
} // namespace NYql::NDq

0 commit comments

Comments
 (0)