Skip to content

Commit a4c61b1

Browse files
authored
Merge pull request #10871 from uzhastik/24_3_merge_9
24 3 merge 9
2 parents 346c71f + fbead47 commit a4c61b1

File tree

163 files changed

+3834
-1201
lines changed

Some content is hidden

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

163 files changed

+3834
-1201
lines changed

ydb/core/base/counters.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static const THashSet<TString> DATABASE_SERVICES
4040
TString("pqproxy|readSession"),
4141
TString("pqproxy|schemecache"),
4242
TString("pqproxy|mirrorWriteTimeLag"),
43+
TString("pqproxy|userAgents"),
4344
TString("datastreams"),
4445
}};
4546

ydb/core/blobstorage/vdisk/repl/query_donor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ namespace NKikimr {
6868
}
6969

7070
if (action) {
71-
const TActorId temp(actorId);
7271
LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::BS_VDISK_GET, SelfId() << " sending " << query->ToString()
73-
<< " to " << temp);
74-
Send(actorId, query.release());
72+
<< " to " << actorId);
73+
Send(actorId, query.release(), IEventHandle::FlagTrackDelivery);
7574
} else {
7675
PassAway();
7776
}
@@ -116,6 +115,7 @@ namespace NKikimr {
116115

117116
STRICT_STFUNC(StateFunc,
118117
hFunc(TEvBlobStorage::TEvVGetResult, Handle);
118+
cFunc(TEvents::TSystem::Undelivered, Step);
119119
cFunc(TEvents::TSystem::Poison, PassAway);
120120
)
121121
};

ydb/core/driver_lib/run/run.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
#include <ydb/services/ydb/ydb_scripting.h>
123123
#include <ydb/services/ydb/ydb_table.h>
124124
#include <ydb/services/ydb/ydb_object_storage.h>
125+
#include <ydb/services/view/grpc_service.h>
125126

126127
#include <ydb/core/fq/libs/init/init.h>
127128

@@ -600,6 +601,8 @@ void TKikimrRunner::InitializeGRpc(const TKikimrRunConfig& runConfig) {
600601
names["keyvalue"] = &hasKeyValue;
601602
TServiceCfg hasReplication = services.empty();
602603
names["replication"] = &hasReplication;
604+
TServiceCfg hasView = services.empty();
605+
names["view"] = &hasView;
603606

604607
std::unordered_set<TString> enabled;
605608
for (const auto& name : services) {
@@ -875,6 +878,11 @@ void TKikimrRunner::InitializeGRpc(const TKikimrRunConfig& runConfig) {
875878
grpcRequestProxies[0], hasReplication.IsRlAllowed()));
876879
}
877880

881+
if (hasView) {
882+
server.AddService(new NGRpcService::TGRpcViewService(ActorSystem.Get(), Counters,
883+
grpcRequestProxies[0], hasView.IsRlAllowed()));
884+
}
885+
878886
if (ModuleFactories) {
879887
for (const auto& service : ModuleFactories->GrpcServiceFactory.Create(enabled, disabled, ActorSystem.Get(), Counters, grpcRequestProxies[0])) {
880888
server.AddService(service);
@@ -1190,6 +1198,8 @@ void TKikimrRunner::InitializeLogSettings(const TKikimrRunConfig& runConfig)
11901198
);
11911199

11921200
LogSettings->ClusterName = logConfig.HasClusterName() ? logConfig.GetClusterName() : "";
1201+
LogSettings->TenantName = runConfig.TenantName;
1202+
LogSettings->NodeId = runConfig.NodeId;
11931203

11941204
if (logConfig.GetFormat() == "full") {
11951205
LogSettings->Format = NLog::TSettings::PLAIN_FULL_FORMAT;

ydb/core/driver_lib/run/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ PEERDIR(
172172
ydb/services/persqueue_v1
173173
ydb/services/rate_limiter
174174
ydb/services/replication
175+
ydb/services/view
175176
ydb/services/ydb
176177
)
177178

ydb/core/engine/mkql_proto.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,19 @@ bool CellsFromTuple(const NKikimrMiniKQL::TType* tupleType,
223223
}
224224
break;
225225
}
226+
case NScheme::NTypeIds::Decimal:
227+
{
228+
if (v.HasLow128() && v.HasHi128()) {
229+
NYql::NDecimal::TInt128 int128 = NYql::NDecimal::FromProto(v);
230+
auto &data = memoryOwner.emplace_back();
231+
data.resize(sizeof(NYql::NDecimal::TInt128));
232+
std::memcpy(data.Detach(), &int128, sizeof(NYql::NDecimal::TInt128));
233+
c = TCell(data);
234+
} else {
235+
CHECK_OR_RETURN_ERROR(false, Sprintf("Cannot parse value of type Decimal in tuple at position %" PRIu32, i));
236+
}
237+
break;
238+
}
226239
default:
227240
CHECK_OR_RETURN_ERROR(false, Sprintf("Unsupported typeId %" PRIu16 " at index %" PRIu32, typeId, i));
228241
break;
@@ -328,6 +341,13 @@ bool CellToValue(NScheme::TTypeInfo type, const TCell& c, NKikimrMiniKQL::TValue
328341
val.MutableOptional()->SetText(c.Data(), c.Size());
329342
break;
330343

344+
case NScheme::NTypeIds::Decimal: {
345+
const auto loHi = c.AsValue<std::pair<ui64, i64>>();
346+
val.MutableOptional()->SetLow128(loHi.first);
347+
val.MutableOptional()->SetHi128(loHi.second);
348+
break;
349+
}
350+
331351
case NScheme::NTypeIds::Pg: {
332352
auto convert = NPg::PgNativeTextFromNativeBinary(c.AsBuf(), type.GetTypeDesc());
333353
if (convert.Error) {

ydb/core/grpc_services/rpc_object_storage.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ bool CellFromTuple(NScheme::TTypeInfo type,
144144
}
145145
break;
146146
}
147+
case NScheme::NTypeIds::Decimal:
148+
{
149+
if (tupleValue.Haslow_128()) {
150+
NYql::NDecimal::TInt128 int128 = NYql::NDecimal::FromHalfs(tupleValue.Getlow_128(), tupleValue.Gethigh_128());
151+
auto &data = memoryOwner.emplace_back();
152+
data.resize(sizeof(NYql::NDecimal::TInt128));
153+
std::memcpy(data.Detach(), &int128, sizeof(NYql::NDecimal::TInt128));
154+
c = TCell(data);
155+
} else {
156+
CHECK_OR_RETURN_ERROR(false, Sprintf("Cannot parse value of type Decimal in tuple at position %" PRIu32, position));
157+
}
158+
break;
159+
}
147160
default:
148161
CHECK_OR_RETURN_ERROR(false, Sprintf("Unsupported typeId %" PRIu16 " at index %" PRIu32, typeId, position));
149162
break;

ydb/core/grpc_services/rpc_view.cpp

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#include "rpc_scheme_base.h"
2+
#include "service_view.h"
3+
4+
#include <ydb/core/grpc_services/base/base.h>
5+
#include <ydb/core/tx/schemeshard/schemeshard.h>
6+
#include <ydb/core/ydb_convert/ydb_convert.h>
7+
#include <ydb/library/actors/core/actor.h>
8+
#include <ydb/library/actors/core/hfunc.h>
9+
#include <ydb/public/api/protos/draft/ydb_view.pb.h>
10+
11+
namespace NKikimr::NGRpcService {
12+
13+
using namespace Ydb;
14+
15+
using TEvDescribeView = TGrpcRequestOperationCall<View::DescribeViewRequest, View::DescribeViewResponse>;
16+
17+
class TDescribeViewRPC : public TRpcSchemeRequestActor<TDescribeViewRPC, TEvDescribeView> {
18+
using TBase = TRpcSchemeRequestActor<TDescribeViewRPC, TEvDescribeView>;
19+
20+
public:
21+
using TBase::TBase;
22+
23+
void Bootstrap() {
24+
DescribeScheme();
25+
}
26+
27+
void PassAway() override {
28+
TBase::PassAway();
29+
}
30+
31+
private:
32+
void DescribeScheme() {
33+
auto ev = std::make_unique<TEvTxUserProxy::TEvNavigate>();
34+
SetAuthToken(ev, *Request_);
35+
SetDatabase(ev.get(), *Request_);
36+
ev->Record.MutableDescribePath()->SetPath(GetProtoRequest()->path());
37+
38+
Send(MakeTxProxyID(), ev.release());
39+
Become(&TDescribeViewRPC::StateDescribeScheme);
40+
}
41+
42+
STATEFN(StateDescribeScheme) {
43+
switch (ev->GetTypeRewrite()) {
44+
HFunc(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult, Handle);
45+
default:
46+
return TBase::StateWork(ev);
47+
}
48+
}
49+
50+
void Handle(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult::TPtr& ev, const TActorContext& ctx) {
51+
const auto& record = ev->Get()->GetRecord();
52+
const auto& desc = record.GetPathDescription();
53+
54+
if (record.HasReason()) {
55+
Request_->RaiseIssue(NYql::TIssue(record.GetReason()));
56+
}
57+
58+
switch (record.GetStatus()) {
59+
case NKikimrScheme::StatusSuccess:
60+
if (desc.GetSelf().GetPathType() != NKikimrSchemeOp::EPathTypeView) {
61+
auto message = TStringBuilder() << "Expected a view, but got: " << desc.GetSelf().GetPathType();
62+
Request_->RaiseIssue(NYql::TIssue(message));
63+
return Reply(StatusIds::SCHEME_ERROR, ctx);
64+
}
65+
66+
ConvertDirectoryEntry(desc.GetSelf(), Result_.mutable_self(), true);
67+
Result_.set_query_text(desc.GetViewDescription().GetQueryText());
68+
69+
return ReplyWithResult(StatusIds::SUCCESS, Result_, ctx);
70+
71+
case NKikimrScheme::StatusPathDoesNotExist:
72+
case NKikimrScheme::StatusSchemeError:
73+
return Reply(StatusIds::SCHEME_ERROR, ctx);
74+
75+
case NKikimrScheme::StatusAccessDenied:
76+
return Reply(StatusIds::UNAUTHORIZED, ctx);
77+
78+
case NKikimrScheme::StatusNotAvailable:
79+
return Reply(StatusIds::UNAVAILABLE, ctx);
80+
81+
default:
82+
return Reply(StatusIds::GENERIC_ERROR, ctx);
83+
}
84+
}
85+
86+
private:
87+
View::DescribeViewResult Result_;
88+
};
89+
90+
void DoDescribeView(std::unique_ptr<IRequestOpCtx> p, const IFacilityProvider& f) {
91+
f.RegisterActor(new TDescribeViewRPC(p.release()));
92+
}
93+
94+
}

ydb/core/grpc_services/service_view.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include <memory>
4+
5+
namespace NKikimr::NGRpcService {
6+
7+
class IRequestOpCtx;
8+
class IFacilityProvider;
9+
10+
void DoDescribeView(std::unique_ptr<IRequestOpCtx> p, const IFacilityProvider& f);
11+
12+
}

ydb/core/grpc_services/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ SRCS(
7474
rpc_stream_execute_yql_script.cpp
7575
rpc_whoami.cpp
7676
rpc_object_storage.cpp
77+
rpc_view.cpp
7778
table_settings.cpp
7879

7980
rpc_common/rpc_common_kqp_session.cpp

ydb/core/health_check/health_check.cpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,34 @@ class TSelfCheckRequest : public TActorBootstrapped<TSelfCheckRequest> {
189189
int Count = 1;
190190
TStackVec<TString> Identifiers;
191191

192-
TNodeTabletStateCount(const NKikimrHive::TTabletInfo& info, const TTabletStateSettings& settings) {
193-
Type = info.tablettype();
194-
Leader = info.followerid() == 0;
192+
static ETabletState GetState(const NKikimrHive::TTabletInfo& info, const TTabletStateSettings& settings) {
195193
if (info.volatilestate() == NKikimrHive::TABLET_VOLATILE_STATE_STOPPED) {
196-
State = ETabletState::Stopped;
197-
} else if (!settings.IsHiveSynchronizationPeriod
198-
&& info.volatilestate() != NKikimrHive::TABLET_VOLATILE_STATE_RUNNING
199-
&& TInstant::MilliSeconds(info.lastalivetimestamp()) < settings.AliveBarrier
200-
&& info.tabletbootmode() == NKikimrHive::TABLET_BOOT_MODE_DEFAULT) {
201-
State = ETabletState::Dead;
202-
} else if (info.restartsperperiod() >= settings.MaxRestartsPerPeriod) {
203-
State = ETabletState::RestartsTooOften;
204-
} else {
205-
State = ETabletState::Good;
194+
return ETabletState::Stopped;
195+
}
196+
ETabletState state = (info.restartsperperiod() >= settings.MaxRestartsPerPeriod) ? ETabletState::RestartsTooOften : ETabletState::Good;
197+
if (info.volatilestate() == NKikimrHive::TABLET_VOLATILE_STATE_RUNNING) {
198+
return state;
199+
}
200+
if (info.tabletbootmode() != NKikimrHive::TABLET_BOOT_MODE_DEFAULT) {
201+
return state;
202+
}
203+
if (info.lastalivetimestamp() != 0 && TInstant::MilliSeconds(info.lastalivetimestamp()) < settings.AliveBarrier) {
204+
// Tablet is not alive for a long time
205+
// We should report it as dead unless it's just waiting to be created
206+
if (info.generation() == 0 && info.volatilestate() == NKikimrHive::TABLET_VOLATILE_STATE_BOOTING && !info.inwaitqueue()) {
207+
return state;
208+
}
209+
return ETabletState::Dead;
206210
}
211+
return state;
212+
213+
}
214+
215+
TNodeTabletStateCount(const NKikimrHive::TTabletInfo& info, const TTabletStateSettings& settings)
216+
: Type(info.tablettype())
217+
, State(GetState(info, settings))
218+
, Leader(info.followerid() == 0)
219+
{
207220
}
208221

209222
bool operator ==(const TNodeTabletStateCount& o) const {
@@ -1983,6 +1996,8 @@ class TSelfCheckRequest : public TActorBootstrapped<TSelfCheckRequest> {
19831996
}
19841997
}
19851998

1999+
// do not propagate RED status to vdisk - so that vdisk is not considered down when computing group status
2000+
context.OverallStatus = MinStatus(context.OverallStatus, Ydb::Monitoring::StatusFlag::ORANGE);
19862001
storagePDiskStatus.set_overall(context.GetOverallStatus());
19872002
}
19882003

0 commit comments

Comments
 (0)