-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(search): persist FT.SYNUPDATE synonyms across server restarts #5988
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
Conversation
src/server/rdb_load.cc
Outdated
| } | ||
|
|
||
| // Prepend FT.CREATE to index definiton | ||
| // Determine command type and prepend appropriate prefix |
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.
what is the aux format for these definitions?
will it stay compatible with previous snapshots?
will it be extendable with more commands?
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.
Aux format: Two separate fields - "search-index" for FT.CREATE, "search-synonyms" for FT.SYNUPDATE
Backward compatible: Yes. Tested with the main branch.
Extensible: Yes. Can add search-aliases, search-config, etc., as separate aux fields using the same pattern.
src/server/rdb_save.cc
Outdated
| // Convert set<string> to vector for joining | ||
| std::vector<std::string_view> terms_vec(terms.begin(), terms.end()); |
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'm almost sure that StrJoin works with as set as well?
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
src/server/rdb_load.cc
Outdated
| string command_name; | ||
| if (!arg_vec.empty()) { | ||
| string_view first_token = facade::ToSV(arg_vec[0]); | ||
| if (first_token == "SYNUPDATE") { |
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.
Why not just pass a flag to LoadSearchIndexDefFromAux instead of all the ifs?
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.
Added a separate method.
src/server/rdb_save.cc
Outdated
| // Format: "SYNUPDATE index_name group_id term1 term2 term3" | ||
| std::string syn_cmd = absl::StrCat("SYNUPDATE ", index_name, " ", group_id, " ", | ||
| absl::StrJoin(terms_vec, " ")); |
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 also don't need the SYNUPDATE prefix if we have a special aux header for it
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
Synonyms created with
FT.SYNUPDATEwere lost after the Dragonfly restart, causing data loss.Solution:
SYNUPDATEcommands alongside index definitionsFT.SYNUPDATEcommands during RDB restore