Skip to content

Commit f2c77f7

Browse files
authored
24-1-async-replication: Sync with main (#6618)
1 parent 3f6c7e3 commit f2c77f7

Some content is hidden

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

49 files changed

+1287
-189
lines changed

ydb/core/base/services_assert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#include <ydb/library/services/services.pb.h>
33

44
static_assert(static_cast<ui32>(NKikimrServices::EServiceKikimr_MIN) > static_cast<ui32>(NActorsServices::EServiceCommon_MAX), "KIKIMR SERVICES IDs SHOULD BE GREATER THAN COMMON ONES");
5-
static_assert(NKikimrServices::TActivity::EType_ARRAYSIZE < 640, "ACTOR ACTIVITY TYPES MUST BE NOT VERY BIG TO BE ARRAY INDICES"); // If we would have many different actor activities, it is OK to increase this value.
5+
static_assert(NKikimrServices::TActivity::EType_ARRAYSIZE < 768, "ACTOR ACTIVITY TYPES MUST BE NOT VERY BIG TO BE ARRAY INDICES"); // If we would have many different actor activities, it is OK to increase this value.

ydb/core/change_exchange/change_sender_common_ops.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void TBaseChangeSender::SendRecords() {
197197
EraseNodesIf(broadcast.PendingPartitions, [&](ui64 partitionId) {
198198
if (Senders.contains(partitionId)) {
199199
auto& sender = Senders.at(partitionId);
200-
sender.Prepared.push_back(std::move(it->second));
200+
sender.Prepared.push_back(it->second);
201201
if (!sender.ActorId) {
202202
Y_ABORT_UNLESS(!sender.Ready);
203203
registrations.insert(partitionId);
@@ -351,7 +351,7 @@ bool TBaseChangeSender::AddBroadcastPartition(ui64 order, ui64 partitionId) {
351351
Y_ABORT_UNLESS(it != Broadcasting.end());
352352

353353
auto& broadcast = it->second;
354-
if (broadcast.Partitions.contains(partitionId)) {
354+
if (broadcast.CompletedPartitions.contains(partitionId)) {
355355
return false;
356356
}
357357

ydb/core/grpc_services/rpc_replication.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class TDescribeReplicationRPC: public TRpcSchemeRequestActor<TDescribeReplicatio
102102

103103
auto ev = std::make_unique<NReplication::TEvController::TEvDescribeReplication>();
104104
PathIdFromPathId(pathId, ev->Record.MutablePathId());
105+
ev->Record.SetIncludeStats(GetProtoRequest()->include_stats());
105106

106107
NTabletPipe::SendData(SelfId(), ControllerPipeClient, ev.release());
107108
Become(&TDescribeReplicationRPC::StateDescribeReplication);
@@ -167,16 +168,26 @@ class TDescribeReplicationRPC: public TRpcSchemeRequestActor<TDescribeReplicatio
167168
if (from.HasSrcStreamName()) {
168169
to.set_source_changefeed_name(from.GetSrcStreamName());
169170
}
171+
if (from.HasLagMilliSeconds()) {
172+
*to.mutable_stats()->mutable_lag() = google::protobuf::util::TimeUtil::MillisecondsToDuration(
173+
from.GetLagMilliSeconds());
174+
}
175+
if (from.HasInitialScanProgress()) {
176+
to.mutable_stats()->set_initial_scan_progress(from.GetInitialScanProgress());
177+
}
170178
}
171179

172180
static void ConvertState(NKikimrReplication::TReplicationState& from, Ydb::Replication::DescribeReplicationResult& to) {
173181
switch (from.GetStateCase()) {
174182
case NKikimrReplication::TReplicationState::kStandBy:
175183
to.mutable_running();
176184
if (from.GetStandBy().HasLagMilliSeconds()) {
177-
*to.mutable_running()->mutable_lag() = google::protobuf::util::TimeUtil::MillisecondsToDuration(
185+
*to.mutable_running()->mutable_stats()->mutable_lag() = google::protobuf::util::TimeUtil::MillisecondsToDuration(
178186
from.GetStandBy().GetLagMilliSeconds());
179187
}
188+
if (from.GetStandBy().HasInitialScanProgress()) {
189+
to.mutable_running()->mutable_stats()->set_initial_scan_progress(from.GetStandBy().GetInitialScanProgress());
190+
}
180191
break;
181192
case NKikimrReplication::TReplicationState::kError:
182193
*to.mutable_error()->mutable_issues() = std::move(*from.MutableError()->MutableIssues());

ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5275,7 +5275,10 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
52755275
}
52765276

52775277
Y_UNIT_TEST(CreateAsyncReplicationWithSecret) {
5278+
using namespace NReplication;
5279+
52785280
TKikimrRunner kikimr("root@builtin");
5281+
auto repl = TReplicationClient(kikimr.GetDriver(), TCommonClientSettings().Database("/Root"));
52795282
auto db = kikimr.GetTableClient();
52805283
auto session = db.CreateSession().GetValueSync().GetSession();
52815284

@@ -5319,6 +5322,34 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
53195322

53205323
Sleep(TDuration::Seconds(1));
53215324
}
5325+
5326+
while (true) {
5327+
auto settings = TDescribeReplicationSettings().IncludeStats(true);
5328+
const auto result = repl.DescribeReplication("/Root/replication", settings).ExtractValueSync();
5329+
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
5330+
5331+
const auto& desc = result.GetReplicationDescription();
5332+
UNIT_ASSERT_VALUES_EQUAL(desc.GetState(), TReplicationDescription::EState::Running);
5333+
5334+
const auto& total = desc.GetRunningState().GetStats();
5335+
if (!total.GetInitialScanProgress() || *total.GetInitialScanProgress() < 100) {
5336+
Sleep(TDuration::Seconds(1));
5337+
continue;
5338+
}
5339+
5340+
UNIT_ASSERT(total.GetInitialScanProgress());
5341+
UNIT_ASSERT_DOUBLES_EQUAL(*total.GetInitialScanProgress(), 100.0, 0.01);
5342+
5343+
const auto& items = desc.GetItems();
5344+
UNIT_ASSERT_VALUES_EQUAL(items.size(), 1);
5345+
const auto& item = items.at(0).Stats;
5346+
5347+
UNIT_ASSERT(item.GetInitialScanProgress());
5348+
UNIT_ASSERT_DOUBLES_EQUAL(*item.GetInitialScanProgress(), *total.GetInitialScanProgress(), 0.01);
5349+
5350+
// TODO: check lag too
5351+
break;
5352+
}
53225353
}
53235354

53245355
Y_UNIT_TEST(AlterAsyncReplication) {

ydb/core/persqueue/partition_sourcemanager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ void TPartitionSourceManager::TModificationBatch::Cancel() {
8181
}
8282

8383
bool TPartitionSourceManager::TModificationBatch::HasModifications() const {
84-
return !SourceIdWriter.GetSourceIdsToWrite().empty();
84+
return !SourceIdWriter.GetSourceIdsToWrite().empty()
85+
|| !SourceIdWriter.GetSourceIdsToDelete().empty();
8586
}
8687

8788
void TPartitionSourceManager::TModificationBatch::FillRequest(TEvKeyValue::TEvRequest* request) {

ydb/core/persqueue/sourceid.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ class TSourceIdWriter {
122122
return Registrations;
123123
}
124124

125+
const THashSet<TString>& GetSourceIdsToDelete() const {
126+
return Deregistrations;
127+
}
128+
125129
template <typename... Args>
126130
void RegisterSourceId(const TString& sourceId, Args&&... args) {
127131
Registrations[sourceId] = TSourceIdInfo(std::forward<Args>(args)...);

ydb/core/protos/counters_datashard.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,4 +486,5 @@ enum ETxTypes {
486486
TXTYPE_CLEANUP_VOLATILE = 80 [(TxTypeOpts) = {Name: "TxCleanupVolatile"}];
487487
TXTYPE_PLAN_PREDICTED_TXS = 81 [(TxTypeOpts) = {Name: "TxPlanPredictedTxs"}];
488488
TXTYPE_WRITE = 82 [(TxTypeOpts) = {Name: "TxWrite"}];
489+
TXTYPE_REMOVE_SCHEMA_SNAPSHOTS = 83 [(TxTypeOpts) = {Name: "TxRemoveSchemaSnapshots"}];
489490
}

ydb/core/protos/flat_scheme_op.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,11 @@ enum ECdcStreamFormat {
807807
ECdcStreamFormatDebeziumJson = 4;
808808
}
809809

810+
message TCdcStreamScanProgress {
811+
optional uint32 ShardsTotal = 1;
812+
optional uint32 ShardsCompleted = 2;
813+
}
814+
810815
message TCdcStreamDescription {
811816
optional string Name = 1;
812817
optional ECdcStreamMode Mode = 2;
@@ -820,6 +825,7 @@ message TCdcStreamDescription {
820825
optional string AwsRegion = 9;
821826
// Set to '0' to disable resolved timestamps
822827
optional uint64 ResolvedTimestampsIntervalMs = 10;
828+
optional TCdcStreamScanProgress ScanProgress = 11;
823829
}
824830

825831
message TCreateCdcStream {

ydb/core/protos/replication.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ message TReplicationConfig {
3333

3434
message TTargetSpecific {
3535
message TTarget {
36+
// in/out
3637
optional string SrcPath = 1;
3738
optional string DstPath = 2;
3839
optional string SrcStreamName = 3;
40+
// out
3941
optional uint64 Id = 4;
42+
optional uint32 LagMilliSeconds = 5;
43+
optional float InitialScanProgress = 6; // pencentage
4044
}
4145

4246
repeated TTarget Targets = 1;
@@ -59,6 +63,7 @@ message TReplicationConfig {
5963
message TReplicationState {
6064
message TStandBy {
6165
optional uint32 LagMilliSeconds = 1;
66+
optional float InitialScanProgress = 2; // pencentage
6267
}
6368

6469
message TPaused {
@@ -146,6 +151,7 @@ message TEvDropReplicationResult {
146151

147152
message TEvDescribeReplication {
148153
optional NKikimrProto.TPathID PathId = 1;
154+
optional bool IncludeStats = 2;
149155
}
150156

151157
message TEvDescribeReplicationResult {

0 commit comments

Comments
 (0)