Skip to content

Commit 20fd222

Browse files
authored
Merge pull request #10389 from uzhastik/24_3_merge_6
24 3 merge 6
2 parents f60c468 + 3ab3902 commit 20fd222

File tree

539 files changed

+1462
-1340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

539 files changed

+1462
-1340
lines changed

ydb/core/client/server/msgbus_server_pq_metacache.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class TPersQueueMetaCacheActor : public TActorBootstrapped<TPersQueueMetaCacheAc
218218
req->Record.MutableRequest()->SetType(NKikimrKqp::QUERY_TYPE_SQL_DML);
219219
req->Record.MutableRequest()->SetKeepSession(false);
220220
req->Record.MutableRequest()->SetDatabase(NKikimr::NPQ::GetDatabaseFromConfig(AppData(ctx)->PQConfig));
221+
req->Record.MutableRequest()->SetUsePublicResponseDataFormat(true);
221222

222223
req->Record.MutableRequest()->MutableQueryCachePolicy()->set_keep_in_cache(true);
223224
req->Record.MutableRequest()->MutableTxControl()->mutable_begin_tx()->mutable_serializable_read_write();
@@ -274,9 +275,14 @@ class TPersQueueMetaCacheActor : public TActorBootstrapped<TPersQueueMetaCacheAc
274275

275276
const auto& record = ev->Get()->Record.GetRef();
276277

277-
Y_ABORT_UNLESS(record.GetResponse().GetResults().size() == 1);
278-
const auto& rr = record.GetResponse().GetResults(0).GetValue().GetStruct(0);
279-
ui64 newVersion = rr.ListSize() == 0 ? 0 : rr.GetList(0).GetStruct(0).GetOptional().GetInt64();
278+
Y_VERIFY(record.GetResponse().YdbResultsSize() == 1);
279+
NYdb::TResultSetParser parser(record.GetResponse().GetYdbResults(0));
280+
281+
ui64 newVersion = 0;
282+
if (parser.RowsCount() != 0) {
283+
parser.TryNextRow();
284+
newVersion = *parser.ColumnParser(0).GetOptionalInt64();
285+
}
280286

281287
LastVersionUpdate = ctx.Now();
282288
if (newVersion > CurrentTopicsVersion || CurrentTopicsVersion == 0 || SkipVersionCheck) {
@@ -293,17 +299,18 @@ class TPersQueueMetaCacheActor : public TActorBootstrapped<TPersQueueMetaCacheAc
293299

294300
const auto& record = ev->Get()->Record.GetRef();
295301

296-
Y_ABORT_UNLESS(record.GetResponse().GetResults().size() == 1);
302+
Y_VERIFY(record.GetResponse().YdbResultsSize() == 1);
297303
TString path, dc;
298-
const auto& rr = record.GetResponse().GetResults(0).GetValue().GetStruct(0);
299-
for (const auto& row : rr.GetList()) {
300-
301-
path = row.GetStruct(0).GetOptional().GetText();
302-
dc = row.GetStruct(1).GetOptional().GetText();
304+
NYdb::TResultSetParser parser(record.GetResponse().GetYdbResults(0));
305+
const ui32 rowCount = parser.RowsCount();
306+
while (parser.TryNextRow()) {
307+
path = *parser.ColumnParser(0).GetOptionalUtf8();
308+
dc = *parser.ColumnParser(1).GetOptionalUtf8();
303309

304310
NewTopics.emplace_back(decltype(NewTopics)::value_type{path, dc});
305311
}
306-
if (rr.ListSize() > 0) {
312+
313+
if (rowCount > 0) {
307314
LastTopicKey = {path, dc};
308315
return RunQuery(EQueryType::EGetTopics, ctx);
309316
} else {
@@ -710,7 +717,7 @@ class TPersQueueMetaCacheActor : public TActorBootstrapped<TPersQueueMetaCacheAc
710717
void ProcessNodesInfoWaitersQueue(bool status, const TActorContext& ctx) {
711718
if (DynamicNodesMapping == nullptr) {
712719
Y_ABORT_UNLESS(!status);
713-
DynamicNodesMapping.reset(new THashMap<ui32, ui32>);
720+
DynamicNodesMapping.reset(new THashMap<ui32, ui32>);
714721
}
715722
while(!NodesMappingWaiters.empty()) {
716723
ctx.Send(NodesMappingWaiters.front(),

ydb/core/cms/cms.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,12 @@ bool TCms::CheckEvictVDisks(const TAction &action, TErrorInfo &error) const {
563563
return false;
564564
}
565565

566+
if (State->Config.SentinelConfig.EvictVDisksStatus.Empty()) {
567+
error.Code = TStatus::ERROR;
568+
error.Reason = "Evict vdisks is disabled in Sentinel (self heal)";
569+
return false;
570+
}
571+
566572
switch (action.GetType()) {
567573
case TAction::RESTART_SERVICES:
568574
case TAction::SHUTDOWN_HOST:

ydb/core/cms/cms_ut.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,46 @@ Y_UNIT_TEST_SUITE(TCmsTest) {
19511951
env.CheckDonePermission("user", permission2.GetPermissions(0).GetId());
19521952
}
19531953

1954+
Y_UNIT_TEST(DisabledEvictVDisks)
1955+
{
1956+
auto opts = TTestEnvOpts(8).WithSentinel();
1957+
TCmsTestEnv env(opts);
1958+
env.SetLogPriority(NKikimrServices::CMS, NLog::PRI_DEBUG);
1959+
1960+
// Make transition faster for tests purposes
1961+
auto cmsConfig = env.GetCmsConfig();
1962+
cmsConfig.MutableSentinelConfig()->SetDefaultStateLimit(1);
1963+
env.SetCmsConfig(cmsConfig);
1964+
1965+
// Evict VDisks
1966+
auto request = env.CheckPermissionRequest(
1967+
MakePermissionRequest(TRequestOptions("user").WithEvictVDisks(),
1968+
MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(0), 600000000, "storage")
1969+
),
1970+
TStatus::DISALLOW_TEMP // ok, waiting for move VDisks
1971+
);
1972+
1973+
// Check that FAULTY BSC request is sent
1974+
env.CheckBSCUpdateRequests({ env.GetNodeId(0) }, NKikimrBlobStorage::FAULTY);
1975+
1976+
// Disable VDisks eviction
1977+
cmsConfig.MutableSentinelConfig()->SetEvictVDisksStatus(NKikimrCms::TCmsConfig::TSentinelConfig::DISABLED);
1978+
env.SetCmsConfig(cmsConfig);
1979+
1980+
// Check that ACTIVE BSC request is sent
1981+
env.CheckBSCUpdateRequests({ env.GetNodeId(0) }, NKikimrBlobStorage::ACTIVE);
1982+
1983+
// Check that CMS returns ERROR when VDisks eviction is disabled
1984+
env.CheckRequest("user", request.GetRequestId(), false, TStatus::ERROR, 0);
1985+
1986+
// Enable VDisks eviction again
1987+
cmsConfig.MutableSentinelConfig()->SetEvictVDisksStatus(NKikimrCms::TCmsConfig::TSentinelConfig::FAULTY);
1988+
env.SetCmsConfig(cmsConfig);
1989+
1990+
// Check that FAULTY BSC request is sent again
1991+
env.CheckBSCUpdateRequests({ env.GetNodeId(0) }, NKikimrBlobStorage::FAULTY);
1992+
}
1993+
19541994
Y_UNIT_TEST(EmergencyDuringRollingRestart)
19551995
{
19561996
TCmsTestEnv env(8);

ydb/core/cms/config.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#pragma once
22

33
#include "pdisk_state.h"
4+
#include "pdisk_status.h"
45

56
#include <ydb/core/protos/cms.pb.h>
67

78
#include <util/datetime/base.h>
89
#include <util/generic/hash.h>
910
#include <util/generic/map.h>
11+
#include <util/generic/maybe.h>
1012

1113
namespace NKikimr::NCms {
1214

@@ -30,6 +32,8 @@ struct TCmsSentinelConfig {
3032
ui32 RoomRatio;
3133
ui32 RackRatio;
3234

35+
TMaybeFail<EPDiskStatus> EvictVDisksStatus;
36+
3337
void Serialize(NKikimrCms::TCmsConfig::TSentinelConfig &config) const {
3438
config.SetEnable(Enable);
3539
config.SetDryRun(DryRun);
@@ -45,6 +49,7 @@ struct TCmsSentinelConfig {
4549
config.SetRackRatio(RackRatio);
4650

4751
SaveStateLimits(config);
52+
SaveEvictVDisksStatus(config);
4853
}
4954

5055
void Deserialize(const NKikimrCms::TCmsConfig::TSentinelConfig &config) {
@@ -63,6 +68,8 @@ struct TCmsSentinelConfig {
6368

6469
auto newStateLimits = LoadStateLimits(config);
6570
StateLimits.swap(newStateLimits);
71+
72+
EvictVDisksStatus = LoadEvictVDisksStatus(config);
6673
}
6774

6875
void SaveStateLimits(NKikimrCms::TCmsConfig::TSentinelConfig &config) const {
@@ -129,6 +136,31 @@ struct TCmsSentinelConfig {
129136

130137
return stateLimits;
131138
}
139+
140+
static TMaybeFail<EPDiskStatus> LoadEvictVDisksStatus(const NKikimrCms::TCmsConfig::TSentinelConfig &config) {
141+
using EEvictVDisksStatus = NKikimrCms::TCmsConfig::TSentinelConfig;
142+
switch (config.GetEvictVDisksStatus()) {
143+
case EEvictVDisksStatus::UNKNOWN:
144+
case EEvictVDisksStatus::FAULTY:
145+
return EPDiskStatus::FAULTY;
146+
case EEvictVDisksStatus::DISABLED:
147+
return Nothing();
148+
}
149+
return EPDiskStatus::FAULTY;
150+
}
151+
152+
void SaveEvictVDisksStatus(NKikimrCms::TCmsConfig::TSentinelConfig &config) const {
153+
using EEvictVDisksStatus = NKikimrCms::TCmsConfig::TSentinelConfig;
154+
155+
if (EvictVDisksStatus.Empty()) {
156+
config.SetEvictVDisksStatus(EEvictVDisksStatus::DISABLED);
157+
return;
158+
}
159+
160+
if (*EvictVDisksStatus == EPDiskStatus::FAULTY) {
161+
config.SetEvictVDisksStatus(EEvictVDisksStatus::FAULTY);
162+
}
163+
}
132164
};
133165

134166
struct TCmsLogConfig {

ydb/core/cms/sentinel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,8 @@ class TSentinel: public TActorBootstrapped<TSentinel> {
895895
continue;
896896
}
897897

898-
if (it->second.HasFaultyMarker()) {
899-
info.SetForcedStatus(EPDiskStatus::FAULTY);
898+
if (it->second.HasFaultyMarker() && Config.EvictVDisksStatus.Defined()) {
899+
info.SetForcedStatus(*Config.EvictVDisksStatus);
900900
} else {
901901
info.ResetForcedStatus();
902902
}

ydb/core/driver_lib/run/kikimr_services_initializers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,8 @@ TPersQueueL2CacheInitializer::TPersQueueL2CacheInitializer(const TKikimrRunConfi
20082008
{}
20092009

20102010
void TPersQueueL2CacheInitializer::InitializeServices(NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) {
2011-
static const ui64 DEFAULT_PQ_L2_MAX_SIZE_MB = 8 * 1024;
2011+
static const ui64 DEFAULT_PQ_L2_MAX_SIZE_MB =
2012+
NKikimrNodeLimits::TNodeLimitsConfig_TPersQueueNodeConfig::default_instance().GetSharedCacheSizeMb();
20122013
static const TDuration DEFAULT_PQ_L2_KEEP_TIMEOUT = TDuration::Seconds(10);
20132014

20142015
NPQ::TCacheL2Parameters params;

ydb/core/grpc_services/rpc_execute_data_query.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,8 @@ class TExecuteDataQueryRPC : public TRpcKqpRequestActor<TExecuteDataQueryRPC, TE
185185
// https://protobuf.dev/reference/cpp/arenas/#swap
186186
// Actualy will be copy in case pf remote execution
187187
queryResult->mutable_result_sets()->Swap(record.MutableResponse()->MutableYdbResults());
188-
} else {
189-
NKqp::ConvertKqpQueryResultsToDbResult(kqpResponse, queryResult);
190188
}
189+
191190
ConvertQueryStats(kqpResponse, queryResult);
192191
if (kqpResponse.HasTxMeta()) {
193192
queryResult->mutable_tx_meta()->CopyFrom(kqpResponse.GetTxMeta());

ydb/core/grpc_services/rpc_execute_yql_script.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ class TExecuteYqlScriptRPC : public TRpcKqpRequestActor<TExecuteYqlScriptRPC, TE
9797
auto queryResult = TEvExecuteYqlScriptRequest::AllocateResult<TResult>(Request_);
9898

9999
try {
100-
NKqp::ConvertKqpQueryResultsToDbResult(kqpResponse, queryResult);
100+
const auto& results = kqpResponse.GetYdbResults();
101+
for (const auto& result : results) {
102+
queryResult->add_result_sets()->CopyFrom(result);
103+
}
104+
101105
} catch (const std::exception& ex) {
102106
NYql::TIssues issues;
103107
issues.AddIssue(NYql::ExceptionToIssue(ex));

ydb/core/grpc_services/rpc_stream_execute_yql_script.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace {
4949
{}
5050

5151
NKqp::TEvKqp::TEvDataQueryStreamPart::TPtr Handle;
52-
google::protobuf::RepeatedPtrField<NKikimrMiniKQL::TResult>::const_iterator ResultIterator;
52+
google::protobuf::RepeatedPtrField<Ydb::ResultSet>::const_iterator ResultIterator;
5353
};
5454

5555
enum EStreamRpcWakeupTag : ui64 {
@@ -218,7 +218,7 @@ class TStreamExecuteYqlScriptRPC
218218
auto result = response.mutable_result();
219219

220220
try {
221-
NKqp::ConvertKqpQueryResultToDbResult(kqpResult, result->mutable_result_set());
221+
result->mutable_result_set()->CopyFrom(kqpResult);
222222
} catch (std::exception ex) {
223223
ReplyFinishStream(ex.what());
224224
}

ydb/core/kafka_proxy/actors/kafka_produce_actor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <ydb/core/persqueue/utils.h>
77
#include <ydb/core/protos/grpc_pq_old.pb.h>
8+
#include <ydb/public/api/protos/draft/persqueue_common.pb.h>
89

910
namespace NKafka {
1011

@@ -262,6 +263,7 @@ THolder<TEvPartitionWriter::TEvWriteRequest> Convert(const TProduceRequestData::
262263

263264
for (const auto& record : batch->Records) {
264265
NKikimrPQClient::TDataChunk proto;
266+
proto.set_codec(NPersQueueCommon::RAW);
265267
for(auto& h : record.Headers) {
266268
auto res = proto.AddMessageMeta();
267269
if (h.Key) {

0 commit comments

Comments
 (0)