Serialize and Restore Schema command - [MOD-11803]#7032
Conversation
963f5c3 to
b950314
Compare
| .rdb_load = IndexSpec_RdbLoad_Logic, // We don't store the index spec in the key space, | ||
| .rdb_save = IndexSpec_RdbSave_Wrapper, // but these are useful for serialization/deserialization (and legacy loading) |
There was a problem hiding this comment.
Can you remind me of the motivation for this change?
Is the reason for not using simply using Indexes_RdbLoad upon handling the new ASM event of adding a new node (next PR) supporting legacy loading?
There was a problem hiding this comment.
We can't serialize all the schemas together with aux_save, first and foremost, because there is no API to do so. It's also simpler to handle the schemas one by one, as some may exist already, while others may not.
This change gives back the existing load and save functionalities of single schema serialization and deserialization, allowing us to use RedisModule_LoadDataTypeFromStringEncver and RedisModule_SaveDataTypeToString, and maybe other APIs in the future.
We still don't actually create any key of the schema type, so these should not be called automatically by redis while saving to RDB (only by the aux_save callback)
cd4e361 to
17b4fe3
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7032 +/- ##
==========================================
- Coverage 85.51% 85.51% -0.01%
==========================================
Files 321 321
Lines 50738 50786 +48
Branches 10351 10351
==========================================
+ Hits 43391 43430 +39
- Misses 7196 7205 +9
Partials 151 151
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
raz-mon
left a comment
There was a problem hiding this comment.
LGTM overall
One question
There was a problem hiding this comment.
LGTM
Regarding the ASM design (upcoming PRs to use this), I think it is not a great design (for our module at least), since replication of the index should occur upon shard addition rather than upon slot migration. It's quite wasteful to send all the aux data for every slot migration.
Nonetheless this functionality is good for us and nicely done! 💪
* layout basic schema command generation * implement IndexSpec_Serialize and IndexSpec_Deserialize * added a unit-test * fix warning * implement mock API * implement restore schema command * add tests (and a dump debug command) * improve test * remove temporary logs * fix tests
|
/backport |
* layout basic schema command generation * implement IndexSpec_Serialize and IndexSpec_Deserialize * added a unit-test * fix warning * implement mock API * implement restore schema command * add tests (and a dump debug command) * improve test * remove temporary logs * fix tests (cherry picked from commit 5feebc4)
|
Successfully created backport PR for |
Serialize and Restore Schema command - [MOD-11803] (#7032) * layout basic schema command generation * implement IndexSpec_Serialize and IndexSpec_Deserialize * added a unit-test * fix warning * implement mock API * implement restore schema command * add tests (and a dump debug command) * improve test * remove temporary logs * fix tests (cherry picked from commit 5feebc4) Co-authored-by: GuyAv46 <[email protected]>
Implement schema serialization and deserialization as part of the ASM effort
Serialization & Deserialization
Implement
IndexSpec_SerializeandIndexSpec_Deserializefunctions to generate aRedisModuleStringfrom a schema and a schema (IndexSpec) from a serialization string.The implementations rely on the type
rdb_loadandrdb_saveimplementations, so we now re-expose these methods to redis. This is okay, as we don't actually save the schemas as part of the key-space, so they won't be called by Redis if we don't call the manual implementations.Testing is focused on the new logic, as the RDB serialization/deserialization is already well tested
_FT._RESTOREIFNX Command
A new command for manual
RESTORElogic for non-key module-type objects of the module. Currently, there is a single "SCHEMA" sub-command to restore indexes.An additional
FT.DEBUG DUMP_SCHEMAcommand was added to generate a schema dump for the restore command.Testing is again focused on the behavior of the restore command. The new debug command and the ACL registration are also tested
Main objects this PR modified
ft_index0) RDB load and save implementationsIndexSpecMark if applicable
Note
Introduce IndexSpec serialization/deserialization, an internal schema restore command, and a debug command to dump schemas, with supporting RDB refactors and tests.
IndexSpec_SerializeandIndexSpec_Deserializeto convert schemas to/from RDB-encodedRedisModuleString.IndexSpec_RdbLoad_Logicand wrapper forIndexSpec_RdbSave; split store logic intoIndexSpec_StoreAfterRdbLoad.IndexSpec_StartGCto removeRedisModuleCtx*; switch GC logs toRSDummyContext.'_FT._RESTOREIFNX SCHEMA <encver> <blob>'(macroRS_RESTORE_IF_NX) to restore schema; register subcommand.FT.DEBUG DUMP_SCHEMA <index>returning serialized schema and encoding version; register in debug help.SaveDataTypeToString/LoadDataTypeFromStringEncverhelpers.DUMP_SCHEMA, and end-to-end restore (_FT._RESTOREIFNX SCHEMA).Written by Cursor Bugbot for commit 17b4fe3. This will update automatically on new commits. Configure here.