Support RDB_TYPE_HASH_2 (Valkey 9) in DumpRdbValueVisitor#119
Merged
Conversation
Owner
|
This PR is awesome — I’ve gone ahead and merged it. I have an idea: now that this is in place, we could also support format conversion between Valkey and Redis (Valkey → Redis and Redis → Valkey). For example, converting HashMetadata to Hash_2, or Hash_2 back to HashMetadata. It’s just an initial thought for now — after the merge, I’ll spend some time thinking through how we might approach this. In that case, migrating from Valkey to a newer version of Redis wouldn’t require dropping TTL information anymore.And the reverse would work as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds parsing support for
RDB_TYPE_HASH_2(opcode 22, introduced in Valkey 9 / RDB v80), which encodes a hashtable with field-level expirations. Wire format per entry is [field, value, ttl_ms], distinct fromRDB_TYPE_HASH_METADATA(Redis 7.4) which uses [ttl, field, value] with a leading minExpire.Changes
DefaultRdbVisitor#applyHash2— new override that emits KeyStringValueTTLHash with valueRdbType = RDB_TYPE_HASH_2, mirroring applyHashMetadata.DumpRdbValueVisitor#applyHash2— two branches:testHash2Passthrough— asserts re-parsed dump preserves keys, values, and TTLs.testHash2DowngradeToHash— runsDumpRdbVisitor(replicator, 79) and asserts the dump comes through asRDB_TYPE_HASHwith TTLs stripped.src/test/resources/dump-hash2.rdbgenerated against a local Valkey 9 instance (commands documented in a comment abovetestHash2Passthrough).Notes
applyHash2toDefaultRdbVisitorfor now. Wondering if it's time to split the RDB visitor into Redis and Valkey variants — happy either way, just flagging. Thoughts welcome!RDB_TYPE_HASH(dropping per-field TTLs) to keep things compatible with older targets — same approach applyHashMetadata already takes. An alternative would be to throw so the caller knows TTLs were lost. I leaned toward compatibility but I'm not sure it's the right call. What do you think?3.12.0as a placeholder — let me know if you'd prefer something different.