Skip to content

CORE: Track HELLO and AUTH state for reconnection - #5145

Merged
affonsov merged 1 commit into
valkey-io:mainfrom
pratheep-kumar:reconnection-info-update
Feb 13, 2026
Merged

CORE: Track HELLO and AUTH state for reconnection#5145
affonsov merged 1 commit into
valkey-io:mainfrom
pratheep-kumar:reconnection-info-update

Conversation

@pratheep-kumar

@pratheep-kumar pratheep-kumar commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Issue link

This Pull Request is linked to issue: #5146

Description

This PR implements state tracking for HELLO and AUTH commands in glide-core, ensuring that protocol version changes and runtime authentication updates persist across automatic reconnections.

Problem

Previously, when a client executed HELLO or AUTH commands at runtime and the connection was automatically reconnected, the state changes (protocol version, credentials) were lost. This prevented language bindings from safely exposing these commands as first-class APIs.

Solution

1. Protocol Version Tracking (glide-core/src/client/reconnecting_connection.rs)

  • Added update_connection_protocol() method to store protocol version changes in connection_info
  • Protocol version is now persisted and restored during reconnection

2. HELLO Command Handling (glide-core/src/client/mod.rs)

  • Added is_hello_command() to detect HELLO command execution
  • Added handle_hello_command() to extract and store:
    • Protocol version (e.g., RESP3)
    • Authentication parameters (username/password if provided)
    • Client name (if provided via HELLO's SETNAME option)
  • Integrated with command pipeline to automatically track state changes

3. AUTH Command Handling (glide-core/src/client/mod.rs)

  • Added handle_auth_command() to track runtime credential changes
  • Extracts and stores username/password for reconnection
  • Distinguished from initial connection authentication

4. Reconnection Logic Updates

  • During reconnection, stored protocol version is applied via HELLO
  • Stored credentials from AUTH are re-applied automatically
  • Ensures connection state matches what the application expects

5. Testing

  • Added test_hello_command_persistence_after_reconnection() - verifies protocol version persists
  • Added test_auth_command_persistence_after_reconnection() - verifies credentials persist
  • Tests follow the pattern of existing test_select_command_persistence_after_reconnection()

Impact on Language Bindings

This unblocks language bindings from exposing HELLO and AUTH as first-class APIs:

  • ✅ Java client can now safely expose hello() and auth() methods
  • ✅ Other language bindings (Python, Node.js, Go) can implement these commands

Follows Existing Patterns

This implementation follows the established patterns for:

  • SELECT command tracking (update_connection_database())
  • CLIENT SETNAME command tracking (update_connection_client_name())
  • updateConnectionPassword() method

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

Breaking Changes

None. This is a backward-compatible enhancement.

Additional Notes

  • The RwLock mechanism for connection_info ensures thread-safe access during concurrent command execution and reconnection
  • Protocol version changes via HELLO are only tracked if explicitly set by the application (default protocol is not overridden)
  • AUTH command tracking complements updateConnectionPassword() - use updateConnectionPassword() for config-based auth, and AUTH command for runtime credential switching

@pratheep-kumar
pratheep-kumar marked this pull request as ready for review January 9, 2026 15:21
@pratheep-kumar
pratheep-kumar requested a review from a team as a code owner January 9, 2026 15:21
@pratheep-kumar

Copy link
Copy Markdown
Contributor Author

@xShinnRyuu @jduo @affonsov Please review this. Thanks. This unblocks PR

Comment thread glide-core/src/client/reconnecting_connection.rs
@xShinnRyuu

xShinnRyuu commented Jan 30, 2026

Copy link
Copy Markdown
Collaborator

Hi @pratheep-kumar, there is feedback from other maintainers, could you address them? Please add a reply to the review comments so that they can accurately review the changes you have made to fix them. Thank you

@jduo

jduo commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

Hi @pratheep-kumar , as mentioned above there are some unaddressed comments. Would you be able to handle these to complete the PR? Thanks.

@xShinnRyuu

Copy link
Copy Markdown
Collaborator

Hi @pratheep-kumar

Sorry for the delay in reviews.

There’s a review comment left by someone on our team. If you’re able to take care of that, we’ll be happy to merge it right away. Otherwise, I can also jump in and help get it across the line.

…ersisting authentication state

- Add update_connection_username() and update_connection_protocol() methods to ClusterConnection for cluster-wide state updates
- Add UpdateConnectionUsername and UpdateConnectionProtocol operations to cluster routing
- Reclassify AUTH command as write operation in cluster routing to ensure state is tracked across all nodes
- Update CHANGELOG.md to document HELLO and AUTH state tracking feature
- Ensure reconnections preserve protocol version and username from previous successful connections

Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
@affonsov
affonsov force-pushed the reconnection-info-update branch from 65f5678 to 7c37fc5 Compare February 13, 2026 18:42
@affonsov affonsov changed the title Adding username and protocol in reconnection info CORE: Track HELLO and AUTH state for reconnection Feb 13, 2026
@affonsov
affonsov merged commit 6f96c84 into valkey-io:main Feb 13, 2026
115 of 121 checks passed
tavomaciel pushed a commit to tavomaciel/valkey-glide that referenced this pull request Feb 16, 2026
- Add update_username() and update_protocol() methods to Client for persisting authentication state
- Add update_connection_username() and update_connection_protocol() methods to ClusterConnection for cluster-wide state updates
- Add UpdateConnectionUsername and UpdateConnectionProtocol operations to cluster routing
- Reclassify AUTH command as write operation in cluster routing to ensure state is tracked across all nodes
- Update CHANGELOG.md to document HELLO and AUTH state tracking feature
- Ensure reconnections preserve protocol version and username from previous successful connections

Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Co-authored-by: Pratheep Kumar <pratheepkumar0403@gmail.com>
prashanna-frsh pushed a commit to prashanna-frsh/valkey-glide that referenced this pull request Feb 16, 2026
- Add update_username() and update_protocol() methods to Client for persisting authentication state
- Add update_connection_username() and update_connection_protocol() methods to ClusterConnection for cluster-wide state updates
- Add UpdateConnectionUsername and UpdateConnectionProtocol operations to cluster routing
- Reclassify AUTH command as write operation in cluster routing to ensure state is tracked across all nodes
- Update CHANGELOG.md to document HELLO and AUTH state tracking feature
- Ensure reconnections preserve protocol version and username from previous successful connections

Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Co-authored-by: Pratheep Kumar <pratheepkumar0403@gmail.com>
Signed-off-by: prashanna-frsh <prashanna.rajendran@freshworks.com>
prashanna-frsh pushed a commit to prashanna-frsh/valkey-glide that referenced this pull request Feb 16, 2026
- Add update_username() and update_protocol() methods to Client for persisting authentication state
- Add update_connection_username() and update_connection_protocol() methods to ClusterConnection for cluster-wide state updates
- Add UpdateConnectionUsername and UpdateConnectionProtocol operations to cluster routing
- Reclassify AUTH command as write operation in cluster routing to ensure state is tracked across all nodes
- Update CHANGELOG.md to document HELLO and AUTH state tracking feature
- Ensure reconnections preserve protocol version and username from previous successful connections

Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Co-authored-by: Pratheep Kumar <pratheepkumar0403@gmail.com>
Kaushik-Vijayakumar pushed a commit to Kaushik-Vijayakumar/valkey-glide that referenced this pull request Feb 17, 2026
- Add update_username() and update_protocol() methods to Client for persisting authentication state
- Add update_connection_username() and update_connection_protocol() methods to ClusterConnection for cluster-wide state updates
- Add UpdateConnectionUsername and UpdateConnectionProtocol operations to cluster routing
- Reclassify AUTH command as write operation in cluster routing to ensure state is tracked across all nodes
- Update CHANGELOG.md to document HELLO and AUTH state tracking feature
- Ensure reconnections preserve protocol version and username from previous successful connections

Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Co-authored-by: Pratheep Kumar <pratheepkumar0403@gmail.com>
affonsov pushed a commit that referenced this pull request Aug 21, 2026
- Add update_username() and update_protocol() methods to Client for persisting authentication state
- Add update_connection_username() and update_connection_protocol() methods to ClusterConnection for cluster-wide state updates
- Add UpdateConnectionUsername and UpdateConnectionProtocol operations to cluster routing
- Reclassify AUTH command as write operation in cluster routing to ensure state is tracked across all nodes
- Update CHANGELOG.md to document HELLO and AUTH state tracking feature
- Ensure reconnections preserve protocol version and username from previous successful connections

Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Co-authored-by: Pratheep Kumar <pratheepkumar0403@gmail.com>
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.

feat(core): Track HELLO and AUTH state for reconnection in glide-core

4 participants