Skip to content

Commit b5341bd

Browse files
Register pathes for insert table (#9881)
1 parent ce9f20d commit b5341bd

File tree

8 files changed

+42
-23
lines changed

8 files changed

+42
-23
lines changed

ydb/core/tx/columnshard/columnshard__init.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,6 @@ bool TTxInit::ReadEverything(TTransactionContext& txc, const TActorContext& ctx)
101101
NIceDb::TNiceDb db(txc.DB);
102102
TBlobGroupSelector dsGroupSelector(Self->Info());
103103
NOlap::TDbWrapper dbTable(txc.DB, &dsGroupSelector);
104-
{
105-
ACFL_DEBUG("step", "TInsertTable::Load_Start");
106-
TMemoryProfileGuard g("TTxInit/InsertTable");
107-
auto localInsertTable = std::make_unique<NOlap::TInsertTable>();
108-
if (!localInsertTable->Load(db, dbTable, TAppData::TimeProvider->Now())) {
109-
ACFL_ERROR("step", "TInsertTable::Load_Fails");
110-
return false;
111-
}
112-
ACFL_DEBUG("step", "TInsertTable::Load_Finish");
113-
Self->InsertTable.swap(localInsertTable);
114-
}
115-
116104
{
117105
ACFL_DEBUG("step", "TTablesManager::Load_Start");
118106
TTablesManager tManagerLocal(Self->StoragesManager, Self->TabletID());
@@ -138,6 +126,21 @@ bool TTxInit::ReadEverything(TTransactionContext& txc, const TActorContext& ctx)
138126
ACFL_DEBUG("step", "TTablesManager::Load_Finish");
139127
}
140128

129+
{
130+
ACFL_DEBUG("step", "TInsertTable::Load_Start");
131+
TMemoryProfileGuard g("TTxInit/InsertTable");
132+
auto localInsertTable = std::make_unique<NOlap::TInsertTable>();
133+
for (auto&& i : Self->TablesManager.GetTables()) {
134+
localInsertTable->RegisterPathInfo(i.first);
135+
}
136+
if (!localInsertTable->Load(db, dbTable, TAppData::TimeProvider->Now())) {
137+
ACFL_ERROR("step", "TInsertTable::Load_Fails");
138+
return false;
139+
}
140+
ACFL_DEBUG("step", "TInsertTable::Load_Finish");
141+
Self->InsertTable.swap(localInsertTable);
142+
}
143+
141144
{
142145
ACFL_DEBUG("step", "TTxController::Load_Start");
143146
TMemoryProfileGuard g("TTxInit/TTxController");

ydb/core/tx/columnshard/columnshard_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ void TColumnShard::RunEnsureTable(const NKikimrTxColumnShard::TCreateTable& tabl
418418
tableVerProto.SetSchemaPresetVersionAdj(tableProto.GetSchemaPresetVersionAdj());
419419

420420
TablesManager.AddTableVersion(pathId, version, tableVerProto, db, Tiers);
421+
InsertTable->RegisterPathInfo(pathId);
421422

422423
Counters.GetTabletCounters()->SetCounter(COUNTER_TABLES, TablesManager.GetTables().size());
423424
Counters.GetTabletCounters()->SetCounter(COUNTER_TABLE_PRESETS, TablesManager.GetSchemaPresets().size());

ydb/core/tx/columnshard/engines/insert_table/insert_table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ TInsertionSummary::TCounters TInsertTable::CommitEphemeral(IDbWrapper& dbTable,
6565

6666
AddBlobLink(data.GetBlobRange().BlobId);
6767
const ui64 pathId = data.GetPathId();
68-
auto& pathInfo = Summary.GetPathInfo(pathId);
68+
auto& pathInfo = Summary.GetPathInfoVerified(pathId);
6969
AFL_TRACE(NKikimrServices::TX_COLUMNSHARD)("event", "commit_insertion")("path_id", pathId)("blob_range", data.GetBlobRange().ToString());
7070
dbTable.Commit(data);
7171
pathInfo.AddCommitted(std::move(data));

ydb/core/tx/columnshard/engines/insert_table/insert_table.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class TInsertTableAccessor {
2525
bool RemoveBlobLinkOnComplete(const TUnifiedBlobId& blobId);
2626

2727
public:
28+
TPathInfo& RegisterPathInfo(const ui64 pathId) {
29+
return Summary.RegisterPathInfo(pathId);
30+
}
31+
2832
void ErasePath(const ui64 pathId) {
2933
Summary.ErasePath(pathId);
3034
}
@@ -64,7 +68,7 @@ class TInsertTableAccessor {
6468
AddBlobLink(data.GetBlobRange().BlobId);
6569
}
6670
const ui64 pathId = data.GetPathId();
67-
return Summary.GetPathInfo(pathId).AddCommitted(std::move(data), load);
71+
return Summary.GetPathInfoVerified(pathId).AddCommitted(std::move(data), load);
6872
}
6973
bool HasPathIdData(const ui64 pathId) const {
7074
return Summary.HasPathIdData(pathId);

ydb/core/tx/columnshard/engines/insert_table/rt_insertion.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ void TInsertionSummary::AddPriority(const TPathInfo& pathInfo) noexcept {
3939
}
4040
}
4141

42-
NKikimr::NOlap::TPathInfo& TInsertionSummary::GetPathInfo(const ui64 pathId) {
42+
TPathInfo& TInsertionSummary::RegisterPathInfo(const ui64 pathId) {
4343
auto it = PathInfo.find(pathId);
4444
if (it == PathInfo.end()) {
4545
it = PathInfo.emplace(pathId, TPathInfo(*this, pathId)).first;
4646
}
4747
return it->second;
4848
}
4949

50-
NKikimr::NOlap::TPathInfo* TInsertionSummary::GetPathInfoOptional(const ui64 pathId) {
50+
TPathInfo* TInsertionSummary::GetPathInfoOptional(const ui64 pathId) {
5151
auto it = PathInfo.find(pathId);
5252
if (it == PathInfo.end()) {
5353
return nullptr;
5454
}
5555
return &it->second;
5656
}
5757

58-
const NKikimr::NOlap::TPathInfo* TInsertionSummary::GetPathInfoOptional(const ui64 pathId) const {
58+
const TPathInfo* TInsertionSummary::GetPathInfoOptional(const ui64 pathId) const {
5959
auto it = PathInfo.find(pathId);
6060
if (it == PathInfo.end()) {
6161
return nullptr;
@@ -134,7 +134,7 @@ bool TInsertionSummary::HasCommitted(const TCommittedData& data) {
134134
return pathInfo->HasCommitted(data);
135135
}
136136

137-
const NKikimr::NOlap::TInsertedData* TInsertionSummary::AddAborted(TInsertedData&& data, const bool load /*= false*/) {
137+
const TInsertedData* TInsertionSummary::AddAborted(TInsertedData&& data, const bool load /*= false*/) {
138138
const TInsertWriteId writeId = data.GetInsertWriteId();
139139
Counters.Aborted.Add(data.BlobSize(), load);
140140
AFL_VERIFY_DEBUG(!Inserted.contains(writeId));
@@ -143,7 +143,7 @@ const NKikimr::NOlap::TInsertedData* TInsertionSummary::AddAborted(TInsertedData
143143
return &insertInfo.first->second;
144144
}
145145

146-
std::optional<NKikimr::NOlap::TInsertedData> TInsertionSummary::ExtractInserted(const TInsertWriteId id) {
146+
std::optional<TInsertedData> TInsertionSummary::ExtractInserted(const TInsertWriteId id) {
147147
auto result = Inserted.ExtractOptional(id);
148148
if (result) {
149149
auto pathInfo = GetPathInfoOptional(result->GetPathId());
@@ -154,10 +154,10 @@ std::optional<NKikimr::NOlap::TInsertedData> TInsertionSummary::ExtractInserted(
154154
return result;
155155
}
156156

157-
const NKikimr::NOlap::TInsertedData* TInsertionSummary::AddInserted(TInsertedData&& data, const bool load /*= false*/) {
157+
const TInsertedData* TInsertionSummary::AddInserted(TInsertedData&& data, const bool load /*= false*/) {
158158
auto* insertInfo = Inserted.AddVerified(std::move(data));
159159
AFL_VERIFY_DEBUG(!Aborted.contains(insertInfo->GetInsertWriteId()));
160-
OnNewInserted(GetPathInfo(insertInfo->GetPathId()), insertInfo->BlobSize(), load);
160+
OnNewInserted(GetPathInfoVerified(insertInfo->GetPathId()), insertInfo->BlobSize(), load);
161161
return insertInfo;
162162
}
163163

ydb/core/tx/columnshard/engines/insert_table/rt_insertion.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,19 @@ class TInsertionSummary {
199199
const NColumnShard::TInsertTableCounters& GetCounters() const {
200200
return Counters;
201201
}
202-
NKikimr::NOlap::TPathInfo& GetPathInfo(const ui64 pathId);
202+
NKikimr::NOlap::TPathInfo& RegisterPathInfo(const ui64 pathId);
203203
TPathInfo* GetPathInfoOptional(const ui64 pathId);
204204
const TPathInfo* GetPathInfoOptional(const ui64 pathId) const;
205+
TPathInfo& GetPathInfoVerified(const ui64 pathId) {
206+
auto* result = GetPathInfoOptional(pathId);
207+
AFL_VERIFY(result);
208+
return *result;
209+
}
210+
const TPathInfo& GetPathInfoVerified(const ui64 pathId) const {
211+
auto* result = GetPathInfoOptional(pathId);
212+
AFL_VERIFY(result);
213+
return *result;
214+
}
205215

206216
const THashMap<ui64, TPathInfo>& GetPathInfo() const {
207217
return PathInfo;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestInsertTable) {
8484

8585
// insert, not commited
8686
auto userData1 = std::make_shared<TUserData>(tableId, TBlobRange(blobId1), TLocalHelper::GetMetaProto(), indexSnapshot, std::nullopt);
87+
insertTable.RegisterPathInfo(tableId);
8788
bool ok = insertTable.Insert(dbTable, TInsertedData(writeId, userData1));
8889
UNIT_ASSERT(ok);
8990

ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class TWriteAggregation {
9696
YDB_READONLY(ui64, Size, 0);
9797
YDB_READONLY(ui64, Rows, 0);
9898
YDB_ACCESSOR_DEF(std::vector<TWideSerializedBatch>, SplittedBlobs);
99-
YDB_READONLY_DEF(TVector<TInsertWriteId>, InsertWriteIds);
99+
YDB_READONLY_DEF(std::vector<TInsertWriteId>, InsertWriteIds);
100100
YDB_READONLY_DEF(std::shared_ptr<NOlap::IBlobsWritingAction>, BlobsAction);
101101
YDB_READONLY_DEF(NArrow::TSchemaSubset, SchemaSubset);
102102
std::shared_ptr<arrow::RecordBatch> RecordBatch;

0 commit comments

Comments
 (0)