Skip to content

Conversation

@vyavdoshenko
Copy link
Contributor

Synonyms created with FT.SYNUPDATE were lost after the Dragonfly restart, causing data loss.

Solution:

  • Save synonym groups to RDB as SYNUPDATE commands alongside index definitions
  • Load and dispatch FT.SYNUPDATE commands during RDB restore

}

// Prepend FT.CREATE to index definiton
// Determine command type and prepend appropriate prefix
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@vyavdoshenko vyavdoshenko requested a review from romange October 31, 2025 12:30
Comment on lines 1381 to 1382
// Convert set<string> to vector for joining
std::vector<std::string_view> terms_vec(terms.begin(), terms.end());
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 2835 to 2838
string command_name;
if (!arg_vec.empty()) {
string_view first_token = facade::ToSV(arg_vec[0]);
if (first_token == "SYNUPDATE") {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a separate method.

Comment on lines 1384 to 1386
// Format: "SYNUPDATE index_name group_id term1 term2 term3"
std::string syn_cmd = absl::StrCat("SYNUPDATE ", index_name, " ", group_id, " ",
absl::StrJoin(terms_vec, " "));
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@vyavdoshenko vyavdoshenko requested a review from dranikpg October 31, 2025 15:18
@vyavdoshenko vyavdoshenko merged commit e3f75b2 into main Nov 5, 2025
10 checks passed
@vyavdoshenko vyavdoshenko deleted the bobik/save_synonyms branch November 5, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants