-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: vector index description wasn't persisted #11969
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
6ffde9b
to
6964950
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
⚪ Test history | Ya make output | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
⚪ Test history | Ya make output | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
@@ -35,6 +35,7 @@ NKikimrSchemeOp::TModifyScheme CreateIndexTask(NKikimr::NSchemeShard::TTableInde | |||
operation->SetName(dst.LeafName()); | |||
|
|||
operation->SetType(indexInfo->Type); | |||
Y_ENSURE(indexInfo->Type != NKikimrSchemeOp::EIndexType::EIndexTypeGlobalVectorKmeansTree); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Y_ENSURE
throws an exception and that is not appropriate for the schemeshard. At least, exceptions are not used in the schemeshard. (And there is a little sense in introducing new way of acting on code assumptions violation as a sidecar of a bugfix).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem, I don't like the idea of schemeshard aborting if something is written incorrectly and we pass the wrong index type in some schemeshard operation, I prefer abort this operation instead.
Do you have any suggestions on what I can replace this "ensure" code with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -1043,9 +1044,10 @@ struct Schema : NIceDb::Schema { | |||
struct AlterVersion : Column<3, NScheme::NTypeIds::Uint64> {}; | |||
struct IndexType : Column<4, NScheme::NTypeIds::Uint32> { using Type = NKikimrSchemeOp::EIndexType; static constexpr Type Default = NKikimrSchemeOp::EIndexTypeInvalid; }; | |||
struct State : Column<5, NScheme::NTypeIds::Uint32> { using Type = NKikimrSchemeOp::EIndexState; static constexpr Type Default = NKikimrSchemeOp::EIndexStateInvalid; }; | |||
struct Description : Column<6, NScheme::NTypeIds::String> {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a tail comment with the type that is stored in that field.
Not all fields that are intended to store serialized protobuf messages are marked in this way, but many are, and that is very helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -1007,7 +1008,8 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { | |||
} | |||
while (!rowSet.EndOfSet()) { | |||
const auto pathId = Self->MakeLocalId(TLocalPathId(rowSet.GetValue<Schema::TableIndex::PathId>())); | |||
tableIndexes.push_back(MakeTableIndexRec<Schema::TableIndex>(pathId, rowSet)); | |||
auto& back = tableIndexes.emplace_back(MakeTableIndexRec<Schema::TableIndex>(pathId, rowSet)); | |||
std::get<4>(back) = rowSet.GetValue<Schema::TableIndex::Description>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected either having different variants of MakeTableIndexRec()
for a different number of columns or a single variadic MakeTableIndexRec()
.
But not a special treatment like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think current code is more compact, but ok, I will change it
Changed
@@ -2371,11 +2371,16 @@ struct TTableIndexInfo : public TSimpleRefCount<TTableIndexInfo> { | |||
using EType = NKikimrSchemeOp::EIndexType; | |||
using EState = NKikimrSchemeOp::EIndexState; | |||
|
|||
TTableIndexInfo(ui64 version, EType type, EState state) | |||
TTableIndexInfo(ui64 version, EType type, EState state, std::string_view description) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to use std::string_view
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my head it's commonly best way to pass something like const string reference.
Also ParseFromString
uses string_view
(abseil but it's kind of same):
bool ParseFromString(y_absl::string_view data);
Do you have some other preference? What and why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const TString&
.
We don't store original argument value in the object and don't construct TTableIndexInfo from anything but TString value, so string_view doesn't bring any benefits here.
@@ -2391,8 +2396,20 @@ struct TTableIndexInfo : public TSimpleRefCount<TTableIndexInfo> { | |||
return result; | |||
} | |||
|
|||
TString DescriptionToStr() const { | |||
return std::visit([](const auto& v) { | |||
if constexpr (requires { v.SerializeAsString(); }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this check is necessary? I guess, we expect all variants of SpecializedIndexDescription
to be of protobuf message type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We expect monostate for global secondary indexes, but I agree that is maybe better to check this instead
@@ -2391,8 +2396,20 @@ struct TTableIndexInfo : public TSimpleRefCount<TTableIndexInfo> { | |||
return result; | |||
} | |||
|
|||
TString DescriptionToStr() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToStr
has a misleading connotation. According to our codebase it doesn't have a meaning of "encode value to a sequence of bytes" but rather "make something printable to be viewed by a person".
I would recommend using something more accurate: SerializedDescription
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, changed to SerializeDescription
, not SerializedDescription
because I want it to be clear that it's not just getter
⚪ Test history | Ya make output | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
⚪ Test history | Ya make output | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
⚪ Test history | Ya make output | Test bloat
⚪ Test history | Ya make output | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
No description provided.