Skip to content

Commit ce348a9

Browse files
authored
Fix flaky test (#7137)
1 parent 90e960b commit ce348a9

File tree

5 files changed

+71
-58
lines changed

5 files changed

+71
-58
lines changed

ydb/core/tx/schemeshard/schemeshard__operation_alter_continuous_backup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ TVector<ISubOperation::TPtr> CreateAlterContinuousBackup(TOperationId opId, cons
8888
const NScheme::TTypeRegistry* typeRegistry = AppData(context.Ctx)->TypeRegistry;
8989

9090
NKikimrSchemeOp::TTableDescription schema;
91-
context.SS->DescribeTable(table, typeRegistry, true, &schema);
91+
context.SS->DescribeTable(*table, typeRegistry, true, &schema);
9292
schema.MutablePartitionConfig()->CopyFrom(table->TableDescription.GetPartitionConfig());
9393

9494
TString errStr;

ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void PrepareScheme(NKikimrSchemeOp::TTableDescription* schema, const TString& na
1414
const NScheme::TTypeRegistry* typeRegistry = AppData(context.Ctx)->TypeRegistry;
1515

1616
NKikimrSchemeOp::TTableDescription completedSchema;
17-
context.SS->DescribeTable(srcTableInfo, typeRegistry, true, &completedSchema);
17+
context.SS->DescribeTable(*srcTableInfo, typeRegistry, true, &completedSchema);
1818
completedSchema.SetName(name);
1919

2020
//inherit all from Src except PartitionConfig, PartitionConfig could be altered

ydb/core/tx/schemeshard/schemeshard_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ class TSchemeShard
10211021

10221022
void FillAsyncIndexInfo(const TPathId& tableId, NKikimrTxDataShard::TFlatSchemeTransaction& tx);
10231023

1024-
void DescribeTable(const TTableInfo::TPtr tableInfo, const NScheme::TTypeRegistry* typeRegistry,
1024+
void DescribeTable(const TTableInfo& tableInfo, const NScheme::TTypeRegistry* typeRegistry,
10251025
bool fillConfig, NKikimrSchemeOp::TTableDescription* entry) const;
10261026
void DescribeTableIndex(const TPathId& pathId, const TString& name,
10271027
bool fillConfig, bool fillBoundaries, NKikimrSchemeOp::TIndexDescription& entry

ydb/core/tx/schemeshard/schemeshard_info_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ struct TTableInfo : public TSimpleRefCount<TTableInfo> {
447447
const NKikimrSchemeOp::TPartitionConfig& PartitionConfig() const { return TableDescription.GetPartitionConfig(); }
448448
NKikimrSchemeOp::TPartitionConfig& MutablePartitionConfig() { return *TableDescription.MutablePartitionConfig(); }
449449

450-
bool HasReplicationConfig() { return TableDescription.HasReplicationConfig(); }
451-
const NKikimrSchemeOp::TTableReplicationConfig& ReplicationConfig() { return TableDescription.GetReplicationConfig(); }
450+
bool HasReplicationConfig() const { return TableDescription.HasReplicationConfig(); }
451+
const NKikimrSchemeOp::TTableReplicationConfig& ReplicationConfig() const { return TableDescription.GetReplicationConfig(); }
452452
NKikimrSchemeOp::TTableReplicationConfig& MutableReplicationConfig() { return *TableDescription.MutableReplicationConfig(); }
453453

454454
bool IsAsyncReplica() const {

ydb/core/tx/schemeshard/schemeshard_path_describer.cpp

Lines changed: 66 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ void TPathDescriber::DescribeChildren(const TPath& path) {
190190
pathDescription->MutableChildren()->Reserve(pathEl->GetAliveChildren());
191191
for (const auto& child : pathEl->GetChildren()) {
192192
TPathId childId = child.second;
193-
TPathElement::TPtr childEl = *Self->PathsById.FindPtr(childId);
193+
const auto* childElPtr = Self->PathsById.FindPtr(childId);
194+
Y_ASSERT(childElPtr);
195+
TPathElement::TPtr childEl = *childElPtr;
194196
if (childEl->Dropped() || childEl->IsMigrated()) {
195197
continue;
196198
}
@@ -225,18 +227,18 @@ void TPathDescriber::DescribeDir(const TPath& path) {
225227

226228
void FillTableBoundaries(
227229
google::protobuf::RepeatedPtrField<NKikimrSchemeOp::TSplitBoundary>* result,
228-
const TTableInfo::TPtr tableInfo
230+
const TTableInfo& tableInfo
229231
) {
230232
TString errStr;
231233
// Number of split boundaries equals to number of partitions - 1
232-
result->Reserve(tableInfo->GetPartitions().size() - 1);
233-
for (ui32 pi = 0; pi < tableInfo->GetPartitions().size() - 1; ++pi) {
234-
const auto& p = tableInfo->GetPartitions()[pi];
234+
result->Reserve(tableInfo.GetPartitions().size() - 1);
235+
for (ui32 pi = 0; pi < tableInfo.GetPartitions().size() - 1; ++pi) {
236+
const auto& p = tableInfo.GetPartitions()[pi];
235237
TSerializedCellVec endKey(p.EndOfRange);
236238
auto boundary = result->Add()->MutableKeyPrefix();
237239
for (ui32 ki = 0; ki < endKey.GetCells().size(); ++ki){
238240
const auto& c = endKey.GetCells()[ki];
239-
auto type = tableInfo->Columns[tableInfo->KeyColumnIds[ki]].PType;
241+
auto type = tableInfo.Columns.at(tableInfo.KeyColumnIds[ki]).PType;
240242
bool ok = NMiniKQL::CellToValue(type, c, *boundary->AddTuple(), errStr);
241243
Y_ABORT_UNLESS(ok, "Failed to build key tuple at position %" PRIu32 " error: %s", ki, errStr.data());
242244
}
@@ -245,12 +247,12 @@ void FillTableBoundaries(
245247

246248
void FillTablePartitions(
247249
google::protobuf::RepeatedPtrField<NKikimrSchemeOp::TTablePartition>* result,
248-
const TTableInfo::TPtr tableInfo,
250+
const TTableInfo& tableInfo,
249251
const THashMap<TShardIdx, TShardInfo>& shardInfos,
250252
bool includeKeys
251253
) {
252-
result->Reserve(tableInfo->GetPartitions().size());
253-
for (auto& p : tableInfo->GetPartitions()) {
254+
result->Reserve(tableInfo.GetPartitions().size());
255+
for (auto& p : tableInfo.GetPartitions()) {
254256
const auto& tabletId = ui64(shardInfos.at(p.ShardIdx).TabletID);
255257
const auto& key = p.EndOfRange;
256258

@@ -267,13 +269,13 @@ void FillTablePartitions(
267269
}
268270

269271
const TString& GetSerializedTablePartitions(
270-
const TTableInfo::TPtr tableInfo,
272+
TTableInfo& tableInfo,
271273
const THashMap<TShardIdx, TShardInfo>& shardInfos,
272274
bool returnRangeKey
273275
) {
274276
TString& cache = (returnRangeKey
275-
? tableInfo->PreserializedTablePartitions
276-
: tableInfo->PreserializedTablePartitionsNoKeys
277+
? tableInfo.PreserializedTablePartitions
278+
: tableInfo.PreserializedTablePartitionsNoKeys
277279
);
278280

279281
if (cache.empty()) {
@@ -287,7 +289,9 @@ const TString& GetSerializedTablePartitions(
287289

288290
void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPathElement::TPtr pathEl) {
289291
const NScheme::TTypeRegistry* typeRegistry = AppData(ctx)->TypeRegistry;
290-
const TTableInfo::TPtr tableInfo = *Self->Tables.FindPtr(pathId);
292+
const auto* tableInfoPtr = Self->Tables.FindPtr(pathId);
293+
Y_ASSERT(tableInfoPtr);
294+
auto& tableInfo = **tableInfoPtr;
291295
auto pathDescription = Result->Record.MutablePathDescription();
292296
auto entry = pathDescription->MutableTable();
293297

@@ -311,13 +315,13 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
311315

312316
if (returnBoundaries) {
313317
// split boundaries (split keys without shard's tablet-ids)
314-
if (tableInfo->PreserializedTableSplitBoundaries.empty()) {
318+
if (tableInfo.PreserializedTableSplitBoundaries.empty()) {
315319
NKikimrScheme::TEvDescribeSchemeResult preSerializedResult;
316320
auto& tableDesc = *preSerializedResult.MutablePathDescription()->MutableTable();
317321
FillTableBoundaries(tableDesc.MutableSplitBoundary(), tableInfo);
318-
Y_PROTOBUF_SUPPRESS_NODISCARD preSerializedResult.SerializeToString(&tableInfo->PreserializedTableSplitBoundaries);
322+
Y_PROTOBUF_SUPPRESS_NODISCARD preSerializedResult.SerializeToString(&tableInfo.PreserializedTableSplitBoundaries);
319323
}
320-
Result->PreSerializedData += tableInfo->PreserializedTableSplitBoundaries;
324+
Result->PreSerializedData += tableInfo.PreserializedTableSplitBoundaries;
321325
}
322326

323327
if (returnPartitioning) {
@@ -327,18 +331,18 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
327331

328332
// KIKIMR-4337: table info is in flux until table is finally created
329333
if (!pathEl->IsCreateFinished()) {
330-
tableInfo->PreserializedTablePartitions.clear();
331-
tableInfo->PreserializedTablePartitionsNoKeys.clear();
332-
tableInfo->PreserializedTableSplitBoundaries.clear();
334+
tableInfo.PreserializedTablePartitions.clear();
335+
tableInfo.PreserializedTablePartitionsNoKeys.clear();
336+
tableInfo.PreserializedTableSplitBoundaries.clear();
333337
}
334338

335-
FillAggregatedStats(*Result->Record.MutablePathDescription(), tableInfo->GetStats());
339+
FillAggregatedStats(*Result->Record.MutablePathDescription(), tableInfo.GetStats());
336340

337341
if (returnPartitionStats) {
338342
NKikimrSchemeOp::TPathDescription& pathDescription = *Result->Record.MutablePathDescription();
339-
pathDescription.MutableTablePartitionStats()->Reserve(tableInfo->GetPartitions().size());
340-
for (auto& p : tableInfo->GetPartitions()) {
341-
const auto* stats = tableInfo->GetStats().PartitionStats.FindPtr(p.ShardIdx);
343+
pathDescription.MutableTablePartitionStats()->Reserve(tableInfo.GetPartitions().size());
344+
for (auto& p : tableInfo.GetPartitions()) {
345+
const auto* stats = tableInfo.GetStats().PartitionStats.FindPtr(p.ShardIdx);
342346
Y_ABORT_UNLESS(stats);
343347
auto pbStats = pathDescription.AddTablePartitionStats();
344348
FillTableStats(pbStats, *stats);
@@ -368,7 +372,7 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
368372
}));
369373
progress->SetStartTime(txState.StartTime.Seconds());
370374
progress->MutableYTSettings()->CopyFrom(
371-
tableInfo->BackupSettings.GetYTSettings());
375+
tableInfo.BackupSettings.GetYTSettings());
372376
progress->SetDataTotalSize(txState.DataTotalSize);
373377
progress->SetTxId(ui64(txId));
374378

@@ -378,7 +382,7 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
378382
}
379383

380384
/* Get information about last completed backup */
381-
for (const auto& iter: tableInfo->BackupHistory) {
385+
for (const auto& iter: tableInfo.BackupHistory) {
382386
LOG_TRACE(ctx, NKikimrServices::SCHEMESHARD_DESCRIBE,
383387
"Add last backup info item to history");
384388
auto protoResult = pathDescription->AddLastBackupResult();
@@ -444,6 +448,8 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
444448
}
445449

446450
void TPathDescriber::DescribeOlapStore(TPathId pathId, TPathElement::TPtr pathEl) {
451+
const auto* storeInfoPtr = Self->OlapStores.FindPtr(pathId);
452+
Y_ASSERT(storeInfoPtr);
447453
const TOlapStoreInfo::TPtr storeInfo = *Self->OlapStores.FindPtr(pathId);
448454

449455
Y_ABORT_UNLESS(storeInfo, "OlapStore not found");
@@ -475,7 +481,9 @@ void TPathDescriber::DescribeColumnTable(TPathId pathId, TPathElement::TPtr path
475481
if (tableInfo->IsStandalone()) {
476482
FillAggregatedStats(*pathDescription, tableInfo->GetStats());
477483
} else {
478-
const TOlapStoreInfo::TPtr storeInfo = *Self->OlapStores.FindPtr(tableInfo->GetOlapStorePathIdVerified());
484+
const auto* storeInfoPtr = Self->OlapStores.FindPtr(tableInfo->GetOlapStorePathIdVerified());
485+
Y_ASSERT(storeInfoPtr);
486+
const TOlapStoreInfo::TPtr storeInfo = *storeInfoPtr;
479487
Y_ABORT_UNLESS(storeInfo, "OlapStore not found");
480488

481489
auto& preset = storeInfo->SchemaPresets.at(description->GetSchemaPresetId());
@@ -1173,7 +1181,7 @@ THolder<TEvSchemeShard::TEvDescribeSchemeResultBuilder> DescribePath(
11731181
}
11741182

11751183
void TSchemeShard::DescribeTable(
1176-
const TTableInfo::TPtr tableInfo,
1184+
const TTableInfo& tableInfo,
11771185
const NScheme::TTypeRegistry* typeRegistry,
11781186
bool fillConfig,
11791187
NKikimrSchemeOp::TTableDescription* entry
@@ -1183,9 +1191,9 @@ void TSchemeShard::DescribeTable(
11831191
THashMap<ui32, TString> familyNames;
11841192
bool familyNamesBuilt = false;
11851193

1186-
entry->SetTableSchemaVersion(tableInfo->AlterVersion);
1187-
entry->MutableColumns()->Reserve(tableInfo->Columns.size());
1188-
for (auto col : tableInfo->Columns) {
1194+
entry->SetTableSchemaVersion(tableInfo.AlterVersion);
1195+
entry->MutableColumns()->Reserve(tableInfo.Columns.size());
1196+
for (auto col : tableInfo.Columns) {
11891197
const auto& cinfo = col.second;
11901198
if (cinfo.IsDropped())
11911199
continue;
@@ -1205,7 +1213,7 @@ void TSchemeShard::DescribeTable(
12051213
colDescr->SetFamily(cinfo.Family);
12061214

12071215
if (!familyNamesBuilt) {
1208-
for (const auto& family : tableInfo->PartitionConfig().GetColumnFamilies()) {
1216+
for (const auto& family : tableInfo.PartitionConfig().GetColumnFamilies()) {
12091217
if (family.HasName() && family.HasId()) {
12101218
familyNames[family.GetId()] = family.GetName();
12111219
}
@@ -1233,28 +1241,28 @@ void TSchemeShard::DescribeTable(
12331241
break;
12341242
}
12351243
}
1236-
Y_ABORT_UNLESS(!tableInfo->KeyColumnIds.empty());
1244+
Y_ABORT_UNLESS(!tableInfo.KeyColumnIds.empty());
12371245

1238-
entry->MutableKeyColumnNames()->Reserve(tableInfo->KeyColumnIds.size());
1239-
entry->MutableKeyColumnIds()->Reserve(tableInfo->KeyColumnIds.size());
1240-
for (ui32 keyColId : tableInfo->KeyColumnIds) {
1241-
entry->AddKeyColumnNames(tableInfo->Columns[keyColId].Name);
1246+
entry->MutableKeyColumnNames()->Reserve(tableInfo.KeyColumnIds.size());
1247+
entry->MutableKeyColumnIds()->Reserve(tableInfo.KeyColumnIds.size());
1248+
for (ui32 keyColId : tableInfo.KeyColumnIds) {
1249+
entry->AddKeyColumnNames(tableInfo.Columns.at(keyColId).Name);
12421250
entry->AddKeyColumnIds(keyColId);
12431251
}
12441252

12451253
if (fillConfig) {
1246-
FillPartitionConfig(tableInfo->PartitionConfig(), *entry->MutablePartitionConfig());
1254+
FillPartitionConfig(tableInfo.PartitionConfig(), *entry->MutablePartitionConfig());
12471255
}
12481256

1249-
if (tableInfo->HasTTLSettings()) {
1250-
entry->MutableTTLSettings()->CopyFrom(tableInfo->TTLSettings());
1257+
if (tableInfo.HasTTLSettings()) {
1258+
entry->MutableTTLSettings()->CopyFrom(tableInfo.TTLSettings());
12511259
}
12521260

1253-
if (tableInfo->HasReplicationConfig()) {
1254-
entry->MutableReplicationConfig()->CopyFrom(tableInfo->ReplicationConfig());
1261+
if (tableInfo.HasReplicationConfig()) {
1262+
entry->MutableReplicationConfig()->CopyFrom(tableInfo.ReplicationConfig());
12551263
}
12561264

1257-
entry->SetIsBackup(tableInfo->IsBackup);
1265+
entry->SetIsBackup(tableInfo.IsBackup);
12581266
}
12591267

12601268
void TSchemeShard::DescribeTableIndex(const TPathId& pathId, const TString& name,
@@ -1288,26 +1296,31 @@ void TSchemeShard::DescribeTableIndex(const TPathId& pathId, const TString& name
12881296
*entry.MutableDataColumnNames()->Add() = dataColumns;
12891297
}
12901298

1291-
auto indexPath = *PathsById.FindPtr(pathId);
1292-
Y_ABORT_UNLESS(indexPath);
1293-
if (indexInfo->Type == NKikimrSchemeOp::EIndexType::EIndexTypeGlobalVectorKmeansTree) {
1294-
// For vector index we have 4 impl tables on build stage and 2 impl tables when it's ready
1295-
Y_ABORT_UNLESS(indexPath->GetChildren().size() == 4 || indexPath->GetChildren().size() == 2);
1299+
const auto* indexPathPtr = PathsById.FindPtr(pathId);
1300+
Y_ABORT_UNLESS(indexPathPtr);
1301+
const auto& indexPath = **indexPathPtr;
1302+
if (const auto size = indexPath.GetChildren().size(); indexInfo->Type == NKikimrSchemeOp::EIndexType::EIndexTypeGlobalVectorKmeansTree) {
1303+
// For vector index we have 2 impl tables and 2 tmp impl tables
1304+
Y_VERIFY_S(2 <= size && size <= 4, size);
12961305
} else {
1297-
Y_ABORT_UNLESS(indexPath->GetChildren().size() == 1);
1306+
Y_VERIFY_S(size == 1, size);
12981307
}
12991308

13001309
ui64 dataSize = 0;
1301-
for (const auto& indexImplTablePathId : indexPath->GetChildren()) {
1302-
auto tableInfo = *Tables.FindPtr(indexImplTablePathId.second);
1303-
Y_ABORT_UNLESS(tableInfo);
1310+
for (const auto& indexImplTablePathId : indexPath.GetChildren()) {
1311+
const auto* tableInfoPtr = Tables.FindPtr(indexImplTablePathId.second);
1312+
if (!tableInfoPtr && NTableIndex::IsTmpImplTable(indexImplTablePathId.first)) {
1313+
continue; // it's possible because of dropping tmp index impl tables without dropping index
1314+
}
1315+
Y_ABORT_UNLESS(tableInfoPtr);
1316+
const auto& tableInfo = **tableInfoPtr;
13041317

1305-
const auto& tableStats = tableInfo->GetStats().Aggregated;
1318+
const auto& tableStats = tableInfo.GetStats().Aggregated;
13061319
dataSize += tableStats.DataSize + tableStats.IndexSize;
13071320

13081321
auto* tableDescription = entry.AddIndexImplTableDescriptions();
13091322
if (fillConfig) {
1310-
FillPartitionConfig(tableInfo->PartitionConfig(), *tableDescription->MutablePartitionConfig());
1323+
FillPartitionConfig(tableInfo.PartitionConfig(), *tableDescription->MutablePartitionConfig());
13111324
}
13121325
if (fillBoundaries) {
13131326
FillTableBoundaries(tableDescription->MutableSplitBoundary(), tableInfo);

0 commit comments

Comments
 (0)