Skip to content

Commit 78749cc

Browse files
authored
Merge branch 'main' into merge-libs-250627-0050
2 parents 87f4b5f + a84fcc2 commit 78749cc

File tree

1,058 files changed

+32331
-9828
lines changed

Some content is hidden

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

1,058 files changed

+32331
-9828
lines changed

.github/config/muted_ya.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ydb/core/blobstorage/pdisk/ut TPDiskTest.PDiskSlotSizeInUnits
1919
ydb/core/blobstorage/ut_blobstorage GroupReconfiguration.BsControllerDoesNotDisableGroupNoRequestsToNodesWVDisks
2020
ydb/core/blobstorage/ut_blobstorage NodeDisconnected.BsQueueRetries
2121
ydb/core/blobstorage/ut_blobstorage/ut_group_reconfiguration GroupReconfigurationRace.Test_block42
22-
ydb/core/blobstorage/ut_blobstorage/ut_group_reconfiguration unittest.[*/*] chunk
22+
ydb/core/blobstorage/ut_blobstorage/ut_group_reconfiguration *.[*/*] chunk
2323
ydb/core/blobstorage/ut_blobstorage/ut_huge HugeBlobOnlineSizeChange.Compaction
2424
ydb/core/blobstorage/ut_blobstorage/ut_huge unittest.[*/*] chunk
2525
ydb/core/blobstorage/ut_blobstorage/ut_scrub BlobScrubbing.block42
@@ -36,7 +36,7 @@ ydb/core/keyvalue/ut_trace TKeyValueTracingTest.ReadHuge
3636
ydb/core/keyvalue/ut_trace TKeyValueTracingTest.ReadSmall
3737
ydb/core/keyvalue/ut_trace TKeyValueTracingTest.WriteHuge
3838
ydb/core/keyvalue/ut_trace TKeyValueTracingTest.WriteSmall
39-
ydb/core/kqp/ut/batch_operations unittest.[*/*] chunk
39+
ydb/core/kqp/ut/batch_operations *.[*/*] chunk
4040
ydb/core/kqp/ut/cost KqpCost.VectorIndexLookup+useSink
4141
ydb/core/kqp/ut/cost KqpCost.VectorIndexLookup-useSink
4242
ydb/core/kqp/ut/data_integrity KqpDataIntegrityTrails.UpsertEvWriteQueryService-isOlap+useOltpSink

.github/workflows/update_changelog.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ on:
1313
description: "Date '2021-01-01' or tag 'v1.0.0' or commit 'sha'"
1414
required: true
1515
changelog_path:
16-
description: "The value associated with the type."
16+
description: "Changelog path"
1717
required: true
1818
default: "CHANGELOG.md"
1919
prefix:
20-
description: "Prefix for the changelog update"
20+
description: "Prefix for the branch with PR"
2121
required: true
2222
default: "changelog-for-"
2323

ROADMAP.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ We use the following symbols as abbreviations:
126126
## Embedded UI
127127
Detailed roadmap could be found at [YDB Embedded UI repo](https://github.com/ydb-platform/ydb-embedded-ui/blob/main/ROADMAP.md).
128128

129-
## Command Line Utility
130-
1. 🚧 ㉓ Use a **single `ydb yql`** instead of `ydb table query` or `ydb scripting`
129+
## Command Line Interface
130+
1. ✅ ㉔ Use a **single `ydb sql` command** instead of `ydb yql`, `ydb table query` or `ydb scripting` to execute any query
131131
1. ✅ ㉓ Interactive CLI
132132

133133
## Tests and Benchmarks

ydb/apps/etcd_proxy/proxy.cpp

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/discovery/discovery.h>
1212
#include <ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/table/table.h>
1313
#include <ydb/apps/etcd_proxy/service/etcd_base_init.h>
14+
#include <ydb/apps/etcd_proxy/service/etcd_gate.h>
15+
#include <ydb/apps/etcd_proxy/service/etcd_lease.h>
1416
#include <ydb/apps/etcd_proxy/service/etcd_watch.h>
1517
#include <ydb/apps/etcd_proxy/service/etcd_grpc.h>
1618
#include <ydb/core/grpc_services/base/base.h>
@@ -61,25 +63,6 @@ int TProxy::Discovery() {
6163
}
6264

6365
int TProxy::StartServer() {
64-
if (const auto res = Stuff->Client->ExecuteQuery(NEtcd::GetLastRevisionSQL(Stuff->TablePrefix), NYdb::NQuery::TTxControl::NoTx()).ExtractValueSync(); res.IsSuccess()) {
65-
if (auto result = res.GetResultSetParser(0); result.TryNextRow()) {
66-
Stuff->Revision.store(NYdb::TValueParser(result.GetValue(0)).GetInt64());
67-
} else {
68-
std::cout << "Unexpected result of get last revision." << std::endl;
69-
return 1;
70-
}
71-
if (auto result = res.GetResultSetParser(1); result.TryNextRow()) {
72-
Stuff->Lease.store(NYdb::TValueParser(result.GetValue(0)).GetInt64());
73-
} else {
74-
std::cout << "Unexpected result of get last lease." << std::endl;
75-
return 1;
76-
}
77-
std::cout << "The last revision is " << Stuff->Revision.load() << ", the last lease is " << Stuff->Lease.load() << '.' << std::endl;
78-
} else {
79-
std::cout << res.GetIssues().ToString() << std::endl;
80-
return 1;
81-
}
82-
8366
NYdbGrpc::TServerOptions opts;
8467
opts.SetPort(ListeningPort);
8568

@@ -94,11 +77,13 @@ int TProxy::StartServer() {
9477
}
9578

9679
const auto watchtower = ActorSystem->Register(NEtcd::BuildWatchtower(Counters, Stuff));
80+
const auto holderhouse = ActorSystem->Register(NEtcd::BuildHolderHouse(Counters, Stuff));
81+
ActorSystem->Register(NEtcd::BuildMainGate(Counters, Stuff));
9782

9883
GRpcServer = std::make_unique<NYdbGrpc::TGRpcServer>(opts, Counters);
99-
GRpcServer->AddService(new NEtcd::TEtcdKVService(ActorSystem.get(), Counters, watchtower, Stuff));
84+
GRpcServer->AddService(new NEtcd::TEtcdKVService(ActorSystem.get(), Counters, {}, Stuff));
10085
GRpcServer->AddService(new NEtcd::TEtcdWatchService(ActorSystem.get(), Counters, watchtower, Stuff));
101-
GRpcServer->AddService(new NEtcd::TEtcdLeaseService(ActorSystem.get(), Counters, watchtower, Stuff));
86+
GRpcServer->AddService(new NEtcd::TEtcdLeaseService(ActorSystem.get(), Counters, holderhouse, Stuff));
10287
GRpcServer->Start();
10388
std::cout << "Etcd service over " << Database << " on " << Endpoint << " was started." << std::endl;
10489
return 0;
@@ -135,13 +120,18 @@ int TProxy::Run() {
135120
}
136121

137122
int TProxy::InitDatabase() {
138-
if (const auto res = Stuff->Client->ExecuteQuery(NEtcd::GetCreateTablesSQL(Stuff->TablePrefix), NYdb::NQuery::TTxControl::NoTx()).ExtractValueSync(); res.IsSuccess()) {
139-
std::cout << "Database " << Database << " on " << Endpoint << " was initialized." << std::endl;
140-
return 0;
141-
} else {
123+
if (const auto res = Stuff->Client->ExecuteQuery(NEtcd::GetCreateTablesSQL(Stuff->TablePrefix), NYdb::NQuery::TTxControl::NoTx()).ExtractValueSync(); !res.IsSuccess()) {
142124
std::cout << res.GetIssues().ToString() << std::endl;
143125
return 1;
144126
}
127+
if (ImportPrefix_.empty()) {
128+
if (const auto res = Stuff->Client->ExecuteQuery(NEtcd::GetInitializeTablesSQL(Stuff->TablePrefix), NYdb::NQuery::TTxControl::NoTx()).ExtractValueSync(); !res.IsSuccess()) {
129+
std::cout << res.GetIssues().ToString() << std::endl;
130+
return 1;
131+
}
132+
}
133+
std::cout << "Database " << Database << " on " << Endpoint << " was initialized." << std::endl;
134+
return 0;
145135
}
146136

147137
int TProxy::ImportDatabase() {
@@ -216,13 +206,28 @@ int TProxy::ImportDatabase() {
216206
const auto driver = NYdb::TDriver(config);
217207
auto client = NYdb::NTable::TTableClient(driver);
218208

209+
if (const auto res = Stuff->Client->ExecuteQuery(Stuff->TablePrefix + "ALTER TABLE `current` DROP INDEX `lease`;", NYdb::NQuery::TTxControl::NoTx()).ExtractValueSync(); !res.IsSuccess()) {
210+
std::cout << res.GetIssues().ToString() << std::endl;
211+
return 1;
212+
}
213+
219214
if (const auto res = client.BulkUpsert(Database + Folder + "/current", std::move(value)).ExtractValueSync(); !res.IsSuccess()) {
220215
std::cout << res.GetIssues().ToString() << std::endl;
221216
return 1;
222217
}
223218

219+
if (const auto res = Stuff->Client->ExecuteQuery(Stuff->TablePrefix + "ALTER TABLE `current` ADD INDEX `lease` GLOBAL ON (`lease`);", NYdb::NQuery::TTxControl::NoTx()).ExtractValueSync(); !res.IsSuccess()) {
220+
std::cout << res.GetIssues().ToString() << std::endl;
221+
return 1;
222+
}
223+
224224
const auto& param = NYdb::TParamsBuilder().AddParam("$Prefix").String(ImportPrefix_).Build().Build();
225-
if (const auto res = Stuff->Client->ExecuteQuery("insert into `history` select * from `current` where startswith(`key`,$Prefix);", NYdb::NQuery::TTxControl::NoTx(), param).ExtractValueSync(); !res.IsSuccess()) {
225+
if (const auto res = Stuff->Client->ExecuteQuery(Stuff->TablePrefix + R"(
226+
insert into `history` select * from `current` where startswith(`key`,$Prefix);
227+
insert into `revision` (`stub`,`revision`,`timestamp`) values (true,0L,CurrentUtcTimestamp());
228+
insert into `revision` select false as `stub`, nvl(max(`modified`), 0L) as `revision`, CurrentUtcTimestamp(max(`modified`)) as `timestamp` from `history`;
229+
insert into `commited` select `revision`, `timestamp` from `revision` where not `stub`;
230+
)", NYdb::NQuery::TTxControl::NoTx(), param).ExtractValueSync(); !res.IsSuccess()) {
226231
std::cout << res.GetIssues().ToString() << std::endl;
227232
return 1;
228233
}

ydb/apps/etcd_proxy/readme.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
Etcd over YDB. Zero version.
22

33
Main restriction: Can work only in single instance mode.
4-
5-
To remove the restriction two tasks must be done:
6-
- First, get and update a current revision number on YDB side trought a separate request before any logical query.
7-
- Second, use CDC for implement the watches instead of self-notifications.
4+
To remove the restriction we have to use CDC for implement the watches instead of self-notifications.
85

96
And other todo's:
107
- Add merics.

ydb/apps/etcd_proxy/service/create.sql

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
CREATE TABLE revision
2+
(
3+
`stub` Bool NOT NULL,
4+
`revision` Int64 NOT NULL,
5+
`timestamp` Timestamp NOT NULL,
6+
PRIMARY KEY (`stub`)
7+
) WITH (PARTITION_AT_KEYS=(false,true));
8+
9+
CREATE TABLE commited
10+
(
11+
`revision` Int64 NOT NULL,
12+
`timestamp` Timestamp NOT NULL,
13+
PRIMARY KEY (`revision`)
14+
)
15+
WITH (AUTO_PARTITIONING_BY_LOAD = ENABLED, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 23, AUTO_PARTITIONING_PARTITION_SIZE_MB = 11);
16+
117
CREATE TABLE current
218
(
319
`key` Bytes NOT NULL,
@@ -8,7 +24,6 @@ CREATE TABLE current
824
`lease` Int64 NOT NULL,
925
PRIMARY KEY (`key`),
1026
INDEX `lease` GLOBAL ON (`lease`)
11-
1227
)
1328
WITH (AUTO_PARTITIONING_BY_LOAD = ENABLED, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 23, AUTO_PARTITIONING_PARTITION_SIZE_MB = 11);
1429

@@ -34,4 +49,4 @@ CREATE TABLE leases
3449
)
3550
WITH (AUTO_PARTITIONING_BY_LOAD = ENABLED, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 23, AUTO_PARTITIONING_PARTITION_SIZE_MB = 11);
3651

37-
ALTER TABLE history ADD CHANGEFEED changes WITH (format="JSON", mode="UPDATES");
52+
ALTER TABLE `current` ADD CHANGEFEED changes WITH (format="JSON", mode="NEW_AND_OLD_IMAGES");

ydb/apps/etcd_proxy/service/etcd_base_init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ std::string GetCreateTablesSQL(const std::string& prefix) {
88
return prefix + NResource::Find("create.sql"sv);
99
}
1010

11-
std::string GetLastRevisionSQL(const std::string& prefix) {
12-
return prefix + "select nvl(max(`modified`), 1L) from `history`; select nvl(max(`id`), 1L) from `leases`;";
11+
std::string GetInitializeTablesSQL(const std::string& prefix) {
12+
return prefix + "insert into `revision` (`stub`,`revision`,`timestamp`) values (false,0L,CurrentUtcTimestamp()),(true,0L,CurrentUtcTimestamp());";
1313
}
1414

1515
}

ydb/apps/etcd_proxy/service/etcd_base_init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace NEtcd {
66

77
std::string GetCreateTablesSQL(const std::string& prefix);
88

9-
std::string GetLastRevisionSQL(const std::string& prefix);
9+
std::string GetInitializeTablesSQL(const std::string& prefix);
1010

1111
}
1212

ydb/apps/etcd_proxy/service/etcd_events.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ enum Ev : ui32 {
3838
Changes,
3939
Cancel,
4040

41+
RequestRevision,
42+
ReturnRevision,
43+
4144
End
4245
};
4346

@@ -111,6 +114,25 @@ class TEtcdRequestStreamWrapper
111114
const TIntrusivePtr<IStreamCtx> Ctx_;
112115
};
113116

117+
using TKeysSet = std::set<std::pair<std::string, std::string>>;
118+
119+
struct TEvRequestRevision : public NActors::TEventLocal<TEvRequestRevision, Ev::RequestRevision> {
120+
explicit TEvRequestRevision(TKeysSet&& keysSet = {})
121+
: KeysSet(std::move(keysSet))
122+
{}
123+
124+
TKeysSet KeysSet;
125+
};
126+
127+
using TGuard = std::shared_ptr<void>;
128+
129+
struct TEvReturnRevision : public NActors::TEventLocal<TEvReturnRevision, Ev::ReturnRevision> {
130+
explicit TEvReturnRevision(const i64 revision, const TGuard& guard = {}) : Revision(revision), Guard(std::move(guard)) {}
131+
132+
const i64 Revision;
133+
const TGuard Guard;
134+
};
135+
114136
using TEvWatchRequest = TEtcdRequestStreamWrapper<Ev::Watch, etcdserverpb::WatchRequest, etcdserverpb::WatchResponse>;
115137
using TEvLeaseKeepAliveRequest = TEtcdRequestStreamWrapper<Ev::LeaseKeepAlive, etcdserverpb::LeaseKeepAliveRequest, etcdserverpb::LeaseKeepAliveResponse>;
116138

0 commit comments

Comments
 (0)