Commit 91890d0
authored
Java: Multi-Database Support for Cluster Mode Valkey 9.0 (#4658)
* - Implement database selection for cluster clients when database_id != 0
- Send SELECT command to all cluster nodes using MultiNode routing
- Add comprehensive error handling with clear error messages
- Include test for database selection error handling in cluster mode
- Support backward compatibility with servers that don't support multi-db cluster mode
- Enable cluster-databases=16 for Valkey 9.0+ in cluster manager
This enables cluster clients to work with non-default databases on Valkey 9.0+
servers configured with cluster-databases support, while gracefully handling
older servers that don't support this feature.
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* update valkey9 multi db tests
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* fix lint
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* fixing valkey 9 cluster tests
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* add to route to all nodes in the core
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* rust lint fix
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* implement database selection in cluster mode via connection parameters
- Add database_id field to ClusterParams and BuilderParams structs
- Add database() method to ClusterClientBuilder for setting database ID
- Pass database_id through connection info instead of post-connection SELECT
- Remove SELECT command from cluster routing
- Remove post-connection SELECT command logic from create_cluster_client
- Add comprehensive tests for database isolation and reconnection behavior
- Verify database ID persistence across node reconnections
- Test multi-database cluster support with proper isolation verification
This change moves database selection from a post-connection SELECT command
to a connection parameter, which is more reliable for cluster mode and
handles reconnections automatically. The approach works with servers that
support multi-database cluster configurations (like Valkey 9.0+).
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* add valkey9 constraint in the core tests
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* fix core test not skipping test when version was lower than valkey 9
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* Fix version check
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* refactored test test_set_database_id_after_reconnection to be similar from standalone
removed is_valkey_9_or_higher
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* removed tests and cleanup
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* renamed builder.database to builder.database_id
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* Java: implement multi-database support for cluster mode
- Move databaseId from GlideClientConfiguration to BaseClientConfiguration
- Add databaseId validation and protobuf integration
- Update SELECT command with AllNodes routing and reconnection warnings
- Add connection management for database selection after auth
- Add comprehensive tests with Valkey 9+ version guards
Completes Java client implementation for Valkey 9 cluster multi-database support.
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* fixing database id restriction
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* fixed java test error select_command_invalid_database_standalone
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* fixed lint errors
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* Refactored select command to route to all nodes per default
Removed the option to provide a route
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* java lint fix
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* java: Remove SELECT command from cluster client
- Remove select() method from GlideClusterClient and ConnectionManagementClusterCommands interface
- Delete MultiDatabaseTests.java which tested SELECT command functionality
- Remove SELECT command tests from SharedCommandTests.java
- Add focused test for cluster database_id configuration in ClusterClientTests
- Remove SELECT import from GlideClusterClient
The SELECT command is being removed from the cluster client API as database
selection should be handled through client configuration (databaseId parameter)
rather than runtime commands, which provides better consistency and avoids
reconnection issues.
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* remove database_id validatation and simplified tests
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* added changelog
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* fix documentation
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
* fix databaseId documentation
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
---------
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>1 parent b9c031d commit 91890d0
File tree
7 files changed
+105
-7
lines changed- java
- client/src
- main/java/glide
- api
- commands
- models/configuration
- managers
- test/java/glide/api/models/configuration
- integTest/src/test/java/glide/cluster
7 files changed
+105
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
113 | 130 | | |
114 | 131 | | |
115 | 132 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
165 | 169 | | |
166 | 170 | | |
167 | 171 | | |
| |||
176 | 180 | | |
177 | 181 | | |
178 | 182 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
157 | 175 | | |
158 | 176 | | |
159 | 177 | | |
| |||
0 commit comments