Commit cb8a4e5
committed
feat: process push notifications before returning connections from pool
Implement push notification processing in baseClient._getConn() to ensure
that all cluster topology changes are handled immediately before connections
are used for commands. This is critical for hitless upgrades and real-time
cluster state awareness.
Key Enhancements:
1. Enhanced Connection Retrieval (_getConn):
- Process push notifications for both existing and new connections
- Added processPushNotifications() call before returning connections
- Ensures immediate handling of cluster topology changes
- Proper error handling with connection removal on processing failures
2. Push Notification Processing Method:
- Added processPushNotifications() method to baseClient
- Only processes notifications for RESP3 connections with processors
- Uses WithReader() to safely access connection reader
- Integrates with existing push notification infrastructure
3. Connection Flow Enhancement:
- Existing connections: Health check → Push notification processing → Return
- New connections: Initialization → Push notification processing → Return
- Failed processing results in connection removal and error return
- Seamless integration with existing connection management
4. RESP3 Protocol Integration:
- Protocol version check (only process for RESP3)
- Push processor availability check
- Graceful handling when processors are not available
- Consistent behavior with existing push notification system
5. Error Handling and Recovery:
- Remove connections if push notification processing fails
- Return errors to trigger connection retry mechanisms
- Maintain connection pool health and reliability
- Prevent returning connections with unprocessed notifications
Implementation Details:
- processPushNotifications() checks protocol and processor availability
- Uses cn.WithReader() to safely access the connection reader
- Calls pushProcessor.ProcessPendingNotifications() for actual processing
- Applied to both pooled connections and newly initialized connections
- Consistent error handling across all connection retrieval paths
Flow Enhancement:
1. Connection requested via _getConn()
2. Connection retrieved from pool (existing or new)
3. Connection initialization (if new)
4. Push notification processing (NEW)
5. Connection returned to caller
6. Commands executed with up-to-date cluster state
Benefits:
- Immediate cluster topology awareness before command execution
- Enhanced hitless upgrade reliability with real-time notifications
- Reduced command failures during cluster topology changes
- Consistent push notification handling across all connection types
- Better integration with Redis cluster operations
This ensures that Redis cluster topology changes (MOVING, MIGRATING,
MIGRATED, FAILING_OVER, FAILED_OVER) are always processed before
connections are used, providing the foundation for reliable hitless
upgrades and seamless cluster operations.1 parent f4ff2d6 commit cb8a4e5
1 file changed
+30
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
276 | 283 | | |
277 | 284 | | |
278 | 285 | | |
| |||
284 | 291 | | |
285 | 292 | | |
286 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
287 | 302 | | |
288 | 303 | | |
289 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
290 | 320 | | |
291 | 321 | | |
292 | 322 | | |
| |||
0 commit comments