Skip to content

Remove ValkeyRdbVisitor and add Valkey 9 handshake support - #112

Merged
leonchen83 merged 4 commits into
leonchen83:masterfrom
otheng03:valkey9-removed-valkeyvisitor
Mar 30, 2026
Merged

leonchen83 merged 4 commits into
leonchen83:masterfrom
otheng03:valkey9-removed-valkeyvisitor

Conversation

@otheng03

Copy link
Copy Markdown
Contributor

Summary

  • Removed ValkeyRdbVisitor and consolidated Valkey RDB parsing into DefaultRdbVisitor. Magic string, version digit count, and version validation are now driven by Flavor.
  • Added REPLCONF version negotiation for Valkey: when the flavor is VALKEY, the replicator now sends REPLCONF version 9.0.0 during handshake, as required by Valkey 9.
  • The minimum Valkey RDB version string ("9.0.0") into Flavor.getSlaveRdbVersion() to keep version knowledge co-located with the flavor definition.
  • Updated CONTRIBUTING.md with Valkey 9 test setup instructions, including a note that --repl-diskless-sync no must be set explicitly (Valkey 9 changed the default to yes), with a TODO to support diskless replication in the future.

Tests performed

  • Passed tests against Valkey 9. Please note CONTRIBUTING.md

- Remove ValkeyRdbVisitor; flavor-specific version parsing is now
  handled by Flavor.getVersionDigits() and Flavor.validateRdbVersion()
- Add versionDigits field to Flavor enum to encode per-flavor version
  string length (4 for Redis, 3 for Valkey)
- DefaultRdbVisitor.applyVersion() delegates to Flavor for digit count
  and version validation
- DefaultRdbVisitor is now the single RDB visitor for all flavors
- Add Valkey 9 Docker setup instructions to CONTRIBUTING.md
- Introduce `sendSlaveRdbVersion` to handle `REPLCONF rdb-version` for Valkey servers.
- Update `Flavor` enum to support Valkey-specific RDB versioning.
- Note Valkey 9 changes and added setup instructions to CONTRIBUTING.md.
@otheng03

otheng03 commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Sorry, I noticed that FlavorSupport was introduced upstream — should we bring ValkeyRdbVisitor back?

@otheng03 otheng03 mentioned this pull request Mar 25, 2026
6 of 12 tasks
@leonchen83

Copy link
Copy Markdown
Owner

I’m also a bit conflicted about whether we should introduce a ValkeyRdbVisitor.

The advantage is that it would give us better extensibility as the differences grow over time. However, the downside is the added complexity, since we would need to introduce additional classes like ValkeyDumpRdbVisitor, ValkeySkipRdbVisitor, and ValkeyIterableRdbVisitor.

I’d like to hear your thoughts on this.

@otheng03

otheng03 commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for asking for my thoughts.

I expect Valkey and Redis to continue diverging over time. As those differences become clearer, it may make more sense to introduce dedicated Valkey visitor classes with a better-informed design. For now, keeping the implementation flavor-driven seems like a reasonable approach.

That said, I also think it would be perfectly valid to separate Redis and Valkey more explicitly in a future 4.0 release, even if that means sacrificing some backward compatibility. In the meantime, managing the divergence through Flavor could still be helpful as a way to centralize the growing differences.

I don’t have a strong preference either way, so I’ll defer to your judgment as the author of redis-replicator.

@leonchen83

Copy link
Copy Markdown
Owner

After some consideration, I think it would be better to introduce ValkeyRdbVisitor in version 4.0, where we can properly handle the required changes.

So I’ve merged this part of the code as a preparation for that.

@leonchen83
leonchen83 merged commit 6aab59d into leonchen83:master Mar 30, 2026
7 checks passed
@leonchen83

leonchen83 commented Mar 30, 2026 •

Copy link
Copy Markdown
Owner

One more adjustment is needed here.

We shouldn’t hardcode the version like this:

@Override
public String slaveRdbVersion() {
    return "9.0.0";
}

Instead, we should first retrieve the server version via the INFO SERVER command, and then directly use that value when talking to Valkey.

This makes the behavior more flexible and avoids hardcoding assumptions about the server version.

@leonchen83

Copy link
Copy Markdown
Owner

All changes have been applied. Please sync with the latest commits.

@otheng03

Copy link
Copy Markdown
Contributor Author

After some consideration, I think it would be better to introduce ValkeyRdbVisitor in version 4.0, where we can properly handle the required changes.

I completely agree.

We shouldn’t hardcode the version like this:
All changes have been applied. Please sync with the latest commits.

I see. Thanks for the update. I’ll pull the latest changes and base my next PRs on them.

@otheng03
otheng03 deleted the valkey9-removed-valkeyvisitor branch April 1, 2026 15:59
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.

2 participants