Skip to content

Commit cd3d76a

Browse files
fix validation in case removed table indexation (#12541)
1 parent 5dba14e commit cd3d76a

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

ydb/core/tx/columnshard/engines/changes/indexation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ TConclusionStatus TInsertColumnEngineChanges::DoConstructBlobs(TConstructionCont
230230
}
231231
pathBatches.AddChunkInfo(inserted, context);
232232
}
233+
NoAppendIsCorrect = pathBatches.GetData().empty();
233234

234235
pathBatches.FinishChunksInfo();
235236

ydb/core/tx/columnshard/engines/changes/with_appended.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void TChangesWithAppend::DoWriteIndexOnComplete(NColumnShard::TColumnShard* self
119119
}
120120

121121
void TChangesWithAppend::DoCompile(TFinalizationContext& context) {
122-
AFL_VERIFY(PortionsToRemove.size() + PortionsToMove.size() + AppendedPortions.size());
122+
AFL_VERIFY(PortionsToRemove.size() + PortionsToMove.size() + AppendedPortions.size() || NoAppendIsCorrect);
123123
for (auto&& i : AppendedPortions) {
124124
i.GetPortionConstructor().MutablePortionConstructor().SetPortionId(context.NextPortionId());
125125
i.GetPortionConstructor().MutablePortionConstructor().MutableMeta().SetCompactionLevel(TargetCompactionLevel.value_or(0));

ydb/core/tx/columnshard/engines/changes/with_appended.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ class TChangesWithAppend: public TColumnEngineChanges {
1313
THashMap<TPortionAddress, std::shared_ptr<const TPortionInfo>> PortionsToMove;
1414

1515
protected:
16+
std::vector<TWritePortionInfoWithBlobsResult> AppendedPortions;
1617
std::optional<ui64> TargetCompactionLevel;
1718
TSaverContext SaverContext;
19+
bool NoAppendIsCorrect = false;
20+
1821
virtual void OnDataAccessorsInitialized(const TDataAccessorsInitializationContext& /*context*/) override {
1922

2023
}
@@ -58,6 +61,14 @@ class TChangesWithAppend: public TColumnEngineChanges {
5861

5962
}
6063

64+
const std::vector<TWritePortionInfoWithBlobsResult>& GetAppendedPortions() const {
65+
return AppendedPortions;
66+
}
67+
68+
std::vector<TWritePortionInfoWithBlobsResult>& MutableAppendedPortions() {
69+
return AppendedPortions;
70+
}
71+
6172
void AddMovePortions(const std::vector<std::shared_ptr<TPortionInfo>>& portions) {
6273
for (auto&& i : portions) {
6374
AFL_VERIFY(i);
@@ -90,7 +101,6 @@ class TChangesWithAppend: public TColumnEngineChanges {
90101
}
91102
}
92103

93-
std::vector<TWritePortionInfoWithBlobsResult> AppendedPortions;
94104
virtual ui32 GetWritePortionsCount() const override {
95105
return AppendedPortions.size();
96106
}

ydb/core/tx/columnshard/engines/ut/ut_logs_engine.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,14 @@ bool Insert(TColumnEngineForLogs& engine, TTestDbWrapper& db, TSnapshot snap, st
329329
NOlap::TConstructionContext context(engine.GetVersionedIndex(), NColumnShard::TIndexationCounters("Indexation"), snap);
330330
Y_ABORT_UNLESS(changes->ConstructBlobs(context).Ok());
331331

332-
UNIT_ASSERT_VALUES_EQUAL(changes->AppendedPortions.size(), 1);
332+
UNIT_ASSERT_VALUES_EQUAL(changes->GetAppendedPortions().size(), 1);
333333
ui32 blobsCount = 0;
334-
for (auto&& i : changes->AppendedPortions) {
334+
for (auto&& i : changes->GetAppendedPortions()) {
335335
blobsCount += i.GetBlobs().size();
336336
}
337337
UNIT_ASSERT_VALUES_EQUAL(blobsCount, 1); // add 2 columns: planStep, txId
338338

339-
AddIdsToBlobs(changes->AppendedPortions, blobs, step);
339+
AddIdsToBlobs(changes->MutableAppendedPortions(), blobs, step);
340340

341341
const bool result = engine.ApplyChangesOnTxCreate(changes, snap) && engine.ApplyChangesOnExecute(db, changes, snap);
342342

@@ -390,7 +390,7 @@ bool Compact(TColumnEngineForLogs& engine, TTestDbWrapper& db, TSnapshot snap, N
390390
Y_ABORT_UNLESS(changes->ConstructBlobs(context).Ok());
391391

392392
// UNIT_ASSERT_VALUES_EQUAL(changes->AppendedPortions.size(), expected.NewPortions);
393-
AddIdsToBlobs(changes->AppendedPortions, changes->Blobs, step);
393+
AddIdsToBlobs(changes->MutableAppendedPortions(), changes->Blobs, step);
394394

395395
// UNIT_ASSERT_VALUES_EQUAL(changes->GetTmpGranuleIds().size(), expected.NewGranules);
396396

@@ -400,7 +400,7 @@ bool Compact(TColumnEngineForLogs& engine, TTestDbWrapper& db, TSnapshot snap, N
400400
NOlap::TWriteIndexCompleteContext contextComplete(NActors::TActivationContext::AsActorContext(), 0, 0, TDuration::Zero(), engine, snap);
401401
changes->WriteIndexOnComplete(nullptr, contextComplete);
402402
if (blobsPool) {
403-
for (auto&& i : changes->AppendedPortions) {
403+
for (auto&& i : changes->GetAppendedPortions()) {
404404
for (auto&& r : i.GetPortionResult().TestGetRecords()) {
405405
Y_ABORT_UNLESS(blobsPool
406406
->emplace(i.GetPortionResult().GetPortionInfo().RestoreBlobRange(r.BlobRange),

ydb/core/tx/columnshard/ut_rw/ut_columnshard_read_write.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,10 +2462,10 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) {
24622462
// Cerr << "EvWriteIndex" << Endl << *msg->IndexChanges << Endl;
24632463

24642464
if (auto append = dynamic_pointer_cast<NOlap::TChangesWithAppend>(msg->IndexChanges)) {
2465-
Y_ABORT_UNLESS(append->AppendedPortions.size());
2465+
Y_ABORT_UNLESS(append->GetAppendedPortions().size());
24662466
TStringBuilder sb;
24672467
sb << "Added portions:";
2468-
for (const auto& portion : append->AppendedPortions) {
2468+
for (const auto& portion : append->GetAppendedPortions()) {
24692469
Y_UNUSED(portion);
24702470
++addedPortions;
24712471
sb << " " << addedPortions;

0 commit comments

Comments
 (0)