Commit fe35eeb
authored
[Backport 2.1] Go: Add Multi-Database Support for Cluster Mode Valkey 9.0 (#4696)
Go: Add Multi-Database Support for Cluster Mode Valkey 9.0 (#4660)
* - 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.
* update valkey9 multi db tests
* fix lint
* fixing valkey 9 cluster tests
* add to route to all nodes in the core
* rust lint fix
* 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+).
* add valkey9 constraint in the core tests
* fix core test not skipping test when version was lower than valkey 9
* Fix version check
* refactored test test_set_database_id_after_reconnection to be similar from standalone
removed is_valkey_9_or_higher
* removed tests and cleanup
* renamed builder.database to builder.database_id
* go: Add multi-database support for cluster mode clients
- Add DatabaseId field to baseClientConfiguration for both standalone and cluster clients
- Implement WithDatabaseId() method for ClusterClientConfiguration
- Add database ID validation with proper error handling for negative values
- Refactor standalone client to use shared database ID logic from base configuration
- Add Select() and SelectWithOptions() methods for cluster clients with routing support
- Include comprehensive test coverage for database isolation, reconnection persistence, and error handling
- Add backward compatibility support - clients default to database 0 when no database_id specified
- Add server version compatibility checks (cluster multi-database requires Valkey 9.0+)
- Update documentation with warnings about SELECT command limitations and recommended configuration approach
This enables cluster mode clients to connect to specific databases at initialization time,
with the database selection persisting across reconnections, unlike the SELECT command
which resets on reconnection.
* fixed go tests
- batch tests
- database id tests
* removed selectWithOptions
* go: Remove Select command from cluster clients
- Remove Select method from ClusterClient and related interfaces
- Delete comprehensive database_id integration tests
- Remove Select command from batch operations
- Remove Select examples and tests
- Add example for cluster client with database_id configuration
The Select command is being removed in favor of using the database_id
configuration parameter, which provides persistent database selection
across reconnections.
* remove config validation
simplified tests
* added changelog
* removing batch test, and readding standalone select and removing batch select
---------
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>1 parent d2731ec commit fe35eeb
File tree
5 files changed
+102
-5
lines changed- go
- config
5 files changed
+102
-5
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 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
155 | 160 | | |
156 | 161 | | |
157 | 162 | | |
| |||
214 | 219 | | |
215 | 220 | | |
216 | 221 | | |
217 | | - | |
218 | 222 | | |
219 | 223 | | |
220 | 224 | | |
| |||
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
333 | | - | |
| 334 | + | |
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
| |||
481 | 482 | | |
482 | 483 | | |
483 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
484 | 491 | | |
485 | 492 | | |
486 | 493 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
213 | 227 | | |
214 | 228 | | |
215 | 229 | | |
| |||
0 commit comments