aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornsofya <nsofya@yandex-team.com>2023-07-27 11:36:05 +0300
committernsofya <nsofya@yandex-team.com>2023-07-27 11:36:05 +0300
commit930489b1ca5ecac97640bf891c5141397a645d44 (patch)
tree9257a0eb7a18706a38d5fb5b30c7039b700a3401
parent4857f3a942f66f9295d71ec59b87abfff37385c9 (diff)
downloadydb-930489b1ca5ecac97640bf891c5141397a645d44.tar.gz
Clean index version selection
Clean index version selection
-rw-r--r--ydb/core/tx/columnshard/columnshard__propose_transaction.cpp2
-rw-r--r--ydb/core/tx/columnshard/columnshard__scan.cpp6
-rw-r--r--ydb/core/tx/columnshard/columnshard_schema.h2
-rw-r--r--ydb/core/tx/columnshard/engines/column_engine.h7
-rw-r--r--ydb/core/tx/columnshard/engines/column_engine_logs.cpp6
-rw-r--r--ydb/core/tx/columnshard/engines/column_engine_logs.h6
-rw-r--r--ydb/core/tx/columnshard/engines/ut_logs_engine.cpp4
-rw-r--r--ydb/core/tx/columnshard/tables_manager.cpp7
-rw-r--r--ydb/core/tx/columnshard/tables_manager.h5
9 files changed, 19 insertions, 26 deletions
diff --git a/ydb/core/tx/columnshard/columnshard__propose_transaction.cpp b/ydb/core/tx/columnshard/columnshard__propose_transaction.cpp
index 78a36b8fb55..615c5ea9c16 100644
--- a/ydb/core/tx/columnshard/columnshard__propose_transaction.cpp
+++ b/ydb/core/tx/columnshard/columnshard__propose_transaction.cpp
@@ -241,7 +241,7 @@ bool TTxProposeTransaction::Execute(TTransactionContext& txc, const TActorContex
break;
}
- auto schema = Self->TablesManager.GetIndexInfo().ArrowSchema();
+ auto schema = Self->TablesManager.GetPrimaryIndexSafe().GetVersionedIndex().GetLastSchema()->GetSchema();
auto ttlColumn = schema->GetFieldByName(columnName);
if (!ttlColumn) {
statusMessage = "TTL tx wrong TTL column '" + columnName + "'";
diff --git a/ydb/core/tx/columnshard/columnshard__scan.cpp b/ydb/core/tx/columnshard/columnshard__scan.cpp
index d0a330c832a..465738719f3 100644
--- a/ydb/core/tx/columnshard/columnshard__scan.cpp
+++ b/ydb/core/tx/columnshard/columnshard__scan.cpp
@@ -916,8 +916,7 @@ bool TTxScan::Execute(TTransactionContext& txc, const TActorContext& ctx) {
indexInfo->GetPrimaryKey();
for (auto& range: record.GetRanges()) {
- if (!FillPredicatesFromRange(read, range, ydbKey, Self->TabletID(), isIndexStats ? nullptr : &Self->TablesManager.GetIndexInfo())) {
- ErrorDescription = "cannot fill predicates from range";
+ if (!FillPredicatesFromRange(read, range, ydbKey, Self->TabletID(), isIndexStats ? nullptr : indexInfo)) {
ReadMetadataRanges.clear();
return true;
}
@@ -925,7 +924,6 @@ bool TTxScan::Execute(TTransactionContext& txc, const TActorContext& ctx) {
{
auto newRange = CreateReadMetadata(read, isIndexStats, record.GetReverse(), itemsLimit);
if (!newRange) {
- ErrorDescription = "cannot create new range";
ReadMetadataRanges.clear();
return true;
}
@@ -976,7 +974,7 @@ void TTxScan::Complete(const TActorContext& ctx) {
std::vector<NOlap::TReadMetadata::TConstPtr> rMetadataRanges;
if (ReadMetadataRanges.empty()) {
- LOG_S_ERROR("TTxScan failed "
+ LOG_S_DEBUG("TTxScan failed "
<< " txId: " << txId
<< " scanId: " << scanId
<< " gen: " << scanGen
diff --git a/ydb/core/tx/columnshard/columnshard_schema.h b/ydb/core/tx/columnshard/columnshard_schema.h
index 345e05cd900..8ba55007c15 100644
--- a/ydb/core/tx/columnshard/columnshard_schema.h
+++ b/ydb/core/tx/columnshard/columnshard_schema.h
@@ -521,7 +521,7 @@ struct Schema : NIceDb::Schema {
static void IndexGranules_Write(NIceDb::TNiceDb& db, ui32 index, const NOlap::IColumnEngine& engine,
const TGranuleRecord& row) {
TString metaStr;
- const auto& indexInfo = engine.GetIndexInfo();
+ const auto& indexInfo = engine.GetVersionedIndex().GetLastSchema()->GetIndexInfo();
if (indexInfo.IsCompositeIndexKey()) {
NKikimrTxColumnShard::TIndexGranuleMeta meta;
Y_VERIFY(indexInfo.GetIndexKey());
diff --git a/ydb/core/tx/columnshard/engines/column_engine.h b/ydb/core/tx/columnshard/engines/column_engine.h
index 9fa4859ddbe..fae205043e2 100644
--- a/ydb/core/tx/columnshard/engines/column_engine.h
+++ b/ydb/core/tx/columnshard/engines/column_engine.h
@@ -340,11 +340,10 @@ class IColumnEngine {
public:
virtual ~IColumnEngine() = default;
- virtual const TIndexInfo& GetIndexInfo() const = 0;
virtual const TVersionedIndex& GetVersionedIndex() const = 0;
- virtual const std::shared_ptr<arrow::Schema>& GetReplaceKey() const { return GetIndexInfo().GetReplaceKey(); }
- virtual const std::shared_ptr<arrow::Schema>& GetSortingKey() const { return GetIndexInfo().GetSortingKey(); }
- virtual const std::shared_ptr<arrow::Schema>& GetIndexKey() const { return GetIndexInfo().GetIndexKey(); }
+ virtual const std::shared_ptr<arrow::Schema>& GetReplaceKey() const { return GetVersionedIndex().GetLastSchema()->GetIndexInfo().GetReplaceKey(); }
+ virtual const std::shared_ptr<arrow::Schema>& GetSortingKey() const { return GetVersionedIndex().GetLastSchema()->GetIndexInfo().GetSortingKey(); }
+ virtual const std::shared_ptr<arrow::Schema>& GetIndexKey() const { return GetVersionedIndex().GetLastSchema()->GetIndexInfo().GetIndexKey(); }
virtual const THashSet<ui64>* GetOverloadedGranules(const ui64 pathId) const = 0;
bool HasOverloadedGranules(const ui64 pathId) const {
return GetOverloadedGranules(pathId) != nullptr;
diff --git a/ydb/core/tx/columnshard/engines/column_engine_logs.cpp b/ydb/core/tx/columnshard/engines/column_engine_logs.cpp
index f9a4667f7f3..1d37b22dbd0 100644
--- a/ydb/core/tx/columnshard/engines/column_engine_logs.cpp
+++ b/ydb/core/tx/columnshard/engines/column_engine_logs.cpp
@@ -235,7 +235,7 @@ bool TColumnEngineForLogs::LoadGranules(IDbWrapper& db) {
bool TColumnEngineForLogs::LoadColumns(IDbWrapper& db, THashSet<TUnifiedBlobId>& lostBlobs) {
return ColumnsTable->Load(db, [&](const TColumnRecord& rec) {
- auto& indexInfo = GetIndexInfo();
+ auto& indexInfo = VersionedIndex.GetLastSchema()->GetIndexInfo();
Y_VERIFY(rec.Valid());
// Do not count the blob as lost since it exists in the index.
lostBlobs.erase(rec.BlobRange.BlobId);
@@ -410,7 +410,7 @@ std::shared_ptr<TTTLColumnEngineChanges> TColumnEngineForLogs::StartTtl(const TH
ui64 dropBlobs = 0;
bool allowDrop = true;
- auto& indexInfo = GetIndexInfo();
+ auto& indexInfo = VersionedIndex.GetLastSchema()->GetIndexInfo();
const TMonotonic nowMonotonic = TlsActivationContext ? AppData()->MonotonicTimeProvider->Now() : TMonotonic::Now();
for (const auto& [pathId, ttl] : pathEviction) {
auto it = NextCheckInstantForTTL.find(pathId);
@@ -747,7 +747,7 @@ std::shared_ptr<TSelectInfo> TColumnEngineForLogs::Select(ui64 pathId, TSnapshot
}
}
Y_VERIFY(outPortion.Produced());
- if (!pkRangesFilter.IsPortionInUsage(outPortion, GetIndexInfo())) {
+ if (!pkRangesFilter.IsPortionInUsage(outPortion, VersionedIndex.GetLastSchema()->GetIndexInfo())) {
AFL_TRACE(NKikimrServices::TX_COLUMNSHARD_SCAN)("event", "portion_skipped")
("granule", granule)("portion", portionInfo->Portion());
continue;
diff --git a/ydb/core/tx/columnshard/engines/column_engine_logs.h b/ydb/core/tx/columnshard/engines/column_engine_logs.h
index f33f1a398cd..0b2d0e5291d 100644
--- a/ydb/core/tx/columnshard/engines/column_engine_logs.h
+++ b/ydb/core/tx/columnshard/engines/column_engine_logs.h
@@ -71,10 +71,6 @@ public:
virtual void OnTieringModified(std::shared_ptr<NColumnShard::TTiersManager> manager) override;
- const TIndexInfo& GetIndexInfo() const override {
- return VersionedIndex.GetLastSchema()->GetIndexInfo();
- }
-
const TVersionedIndex& GetVersionedIndex() const override {
return VersionedIndex;
}
@@ -201,7 +197,7 @@ private:
}
bool UseCompositeMarks() const noexcept {
- return GetIndexInfo().IsCompositeIndexKey();
+ return VersionedIndex.GetLastSchema()->GetIndexInfo().IsCompositeIndexKey();
}
void ClearIndex() {
diff --git a/ydb/core/tx/columnshard/engines/ut_logs_engine.cpp b/ydb/core/tx/columnshard/engines/ut_logs_engine.cpp
index bbc20cc3946..2169430819b 100644
--- a/ydb/core/tx/columnshard/engines/ut_logs_engine.cpp
+++ b/ydb/core/tx/columnshard/engines/ut_logs_engine.cpp
@@ -498,7 +498,7 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestLogs) {
planStep = 3;
- const TIndexInfo& indexInfo = engine.GetIndexInfo();
+ const TIndexInfo& indexInfo = engine.GetVersionedIndex().GetLastSchema()->GetIndexInfo();
THashSet<ui32> oneColumnId = { indexInfo.GetColumnId(key[0].first) };
{ // full scan
@@ -676,7 +676,7 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestLogs) {
// read
planStep = 3;
- const TIndexInfo& indexInfo = engine.GetIndexInfo();
+ const TIndexInfo& indexInfo = engine.GetVersionedIndex().GetLastSchema()->GetIndexInfo();
THashSet<ui32> oneColumnId = { indexInfo.GetColumnId(testColumns[0].first) };
{ // full scan
diff --git a/ydb/core/tx/columnshard/tables_manager.cpp b/ydb/core/tx/columnshard/tables_manager.cpp
index 0633adac11d..d92c226455c 100644
--- a/ydb/core/tx/columnshard/tables_manager.cpp
+++ b/ydb/core/tx/columnshard/tables_manager.cpp
@@ -273,13 +273,14 @@ void TTablesManager::IndexSchemaVersion(const TRowVersion& version, const NKikim
if (!PrimaryIndex) {
PrimaryIndex = std::make_unique<NOlap::TColumnEngineForLogs>(TabletId);
} else {
- Y_VERIFY(PrimaryIndex->GetIndexInfo().GetReplaceKey()->Equals(indexInfo.GetReplaceKey()));
- Y_VERIFY(PrimaryIndex->GetIndexInfo().GetIndexKey()->Equals(indexInfo.GetIndexKey()));
+ const NOlap::TIndexInfo& lastIndexInfo = PrimaryIndex->GetVersionedIndex().GetLastSchema()->GetIndexInfo();
+ Y_VERIFY(lastIndexInfo.GetReplaceKey()->Equals(indexInfo.GetReplaceKey()));
+ Y_VERIFY(lastIndexInfo.GetIndexKey()->Equals(indexInfo.GetIndexKey()));
}
PrimaryIndex->UpdateDefaultSchema(snapshot, std::move(indexInfo));
for (auto& columnName : Ttl.TtlColumns()) {
- PrimaryIndex->GetIndexInfo().CheckTtlColumn(columnName);
+ PrimaryIndex->GetVersionedIndex().GetLastSchema()->GetIndexInfo().CheckTtlColumn(columnName);
}
}
diff --git a/ydb/core/tx/columnshard/tables_manager.h b/ydb/core/tx/columnshard/tables_manager.h
index af2f9780704..654901d13fe 100644
--- a/ydb/core/tx/columnshard/tables_manager.h
+++ b/ydb/core/tx/columnshard/tables_manager.h
@@ -175,10 +175,9 @@ public:
return *PrimaryIndex;
}
- const NOlap::TIndexInfo& GetIndexInfo(const NOlap::TSnapshot& version = NOlap::TSnapshot::Zero()) const {
- Y_UNUSED(version);
+ const NOlap::TIndexInfo& GetIndexInfo(const NOlap::TSnapshot& version) const {
Y_VERIFY(!!PrimaryIndex);
- return PrimaryIndex->GetIndexInfo();
+ return PrimaryIndex->GetVersionedIndex().GetSchema(version)->GetIndexInfo();
}
const std::unique_ptr<NOlap::IColumnEngine>& GetPrimaryIndex() const {