@@ -128,7 +128,7 @@ negotiated, the node will always use the compressed version of the cluster confi
128
128
to ` JSON | SNAPPY ` (` 0x03 ` ).
129
129
130
130
Note, that the meaning of the flag ` SnappyEverywhere ` is that SDK expects and properly handles compression for ** ANY**
131
- operation during communication with the KV engine, this is why the flag called "SnappyEverywhere", and "SnappyConfig".
131
+ operation during communication with the KV engine, this is why the flag called "SnappyEverywhere", and not "SnappyConfig".
132
132
133
133
### ` GetClusterConfig ` and Out-of-Order Execution
134
134
@@ -157,7 +157,7 @@ drawbacks, such as:
157
157
updates on all sockets. This process takes unnecessary time, unlike when the SDK polls every 2.5 seconds.
158
158
159
159
The SDK is not supposed to negotiate ` ClustermapChangeNotification ` (` 0x0d ` ), and must use polling mechanism if brief
160
- version is not available.
160
+ version is not available. ` ClustermapChangeNotification ` still available in post-7.6 versions.
161
161
162
162
Since version 7.6, the KV engine introduces the HELLO flag ` ClustermapChangeNotificationBrief ` (` 0x1f ` ). This flag
163
163
instructs the KV engine to exclude the cluster configuration content from the notification. In this case, the data type
@@ -245,37 +245,57 @@ configuration will be received.t
245
245
246
246
### Enhancements in Handling the ` NotMyVbucket ` Status
247
247
248
- Combination of ` DedupeNotMyVbucketClustermap ` and ` ClustermapChangeNotificationBrief ` allows to save traffic by not
249
- sending configuration, if SDK already seen the same revision, and also sends only pair of ` Epoch ` /` Revision ` . So it is
250
- up to SDK to initiate configuration update once the non-empty payload returned along with ` NotMyVbucket ` status code.
248
+ ` DedupeNotMyVbucketClustermap ` feature allows to save traffic by not sending configuration, if SDK already seen the same
249
+ revision.
251
250
252
251
Several modifications are required in the SDK:
253
- 1 . The retry orchestrator should be able to retry an operation based on configuration updates rather than the timer signal.
254
- 2 . The configuration monitor should have the ability to throttle configuration requests due to the following reasons:
255
- 1 . During rebalance, multiple operations may return a ` NotMyVbucket ` status, triggering a configuration refresh.
256
- 2 . Since ` ClustermapChangeNotificationBrief ` will cause all connections to subscribe to updates and receive them, it is
257
- necessary to account for potential high volumes of updates.
258
-
259
- Below is a diagram that illustrates an example of the SDK workflow, where the GET request is waiting for the arrival of
260
- a new configuration.
252
+ 1 . Response handler should tolerate empty response with ` NotMyVbucket ` status, as the KV engine assumes that the SDK
253
+ already seen configuration, and there is no newer configuration available. In this case SDK should just retry the
254
+ operation.
255
+
256
+ 2 . If the reponse payload contains body, it contains current configuration, which should be sent to configuration
257
+ monitor (manager). The SDK should either synchronously apply configuration, create waiting queue for given
258
+ ` epoch ` /` revision ` pair.
259
+ Once configuration applied, the SDK must check if new configuration routes the operation to new endpoint or new
260
+ vbucket on the old endpoint, and * immediately* dispatch operation to new endpoint (or same endpoint in case vbucketID
261
+ has changed). In any other case, the SDK should send operation to retry orchestrator.
262
+ ``` mermaid
263
+ flowchart
264
+ A(NotMyVbucket) --> B(Apply Configuration)
265
+ B --> C{Route Operation}
266
+ C -->|Endpoint Changed| D[Dispatch To<br>New Endpoint]
267
+ C -->|VBucketID Changed| E[Update VBucketID]
268
+ E --> F[Dispatch To<br>Same Endpoint]
269
+ C -->|Everything Else| G[Send To Retry<br>Orchestrator]
270
+ ```
271
+
272
+
273
+ Below is a diagram that illustrates an example of the SDK workflow
261
274
262
275
``` mermaid
263
276
sequenceDiagram
264
277
autonumber
265
- conn_1 ->>+ kv_node_1: get("foo", vb=115)
266
- kv_node_1 ->>- conn_1: NotMyVbucket(epoch=1, rev=11)
267
- conn_1 -->>+ retry_orchestrator: pending(get, "foo", epoch=1, rev=11)
268
- retry_orchestrator --> retry_orchestrator: put operation to wating queue
269
- conn_1 -->>+ config_monitor: refresh configuration
270
- config_monitor --> config_monitor: wait to throttle config requests
271
- config_monitor ->>+ conn_2: get_config()
272
- conn_2 ->>+ kv_node_2: get_config()
273
- kv_node_2 ->>- conn_2: configuration(epoch=1, rev=11)
274
- conn_2 ->>- config_monitor: apply new configuration
275
- config_monitor ->> retry_orchestrator: purge waiting queue(epoch=1, rev=11)
276
- retry_orchestrator ->> conn_1: retry get("foo")
277
- conn_1 ->>+ kv_node_2: get("foo", vb=115)
278
- kv_node_2 ->>- conn_1: Success()
278
+
279
+ participant conn_1
280
+ participant kv_node_1
281
+ participant retry_orchestrator
282
+ participant config_monitor
283
+
284
+ conn_1 ->>+ kv_node_1: get("foo", vb=115)
285
+ kv_node_1 ->>- conn_1: NotMyVbucket(config={epoch=1, rev=11, ...})
286
+
287
+ conn_1 -->>+ config_monitor: propose confg={epoch=1, rev=11}
288
+
289
+
290
+ critical Check if config route operation to different node of vbucket
291
+
292
+ option "foo" still maps to kv_node_1
293
+ conn_1 -->>+ retry_orchestrator: retry(get, "foo", reason=NotMyVbucket, epoch=1, rev=11)
294
+
295
+ option "foo" does not map to kv_node_1, or vbucket has changed
296
+ conn_1 -->+ kv_node_1: get("foo", vb=new_vbucket)
297
+ kv_node_1 ->>- conn_1: Success()
298
+ end
279
299
```
280
300
281
301
# Language Specifics
@@ -294,10 +314,9 @@ sequenceDiagram
294
314
4 . ` ClustermapChangeNotificationBrief ` (` 0x1f ` ). The SDK should always subscribe for configuration notifications, if the
295
315
server supports it, and fallback to polling if it does not.
296
316
297
- 5 . SDK-side deduplication.
298
- SDK should track which revision was used when last ` GET_CLUSTER_CONFIG ` was sent. So that if new request comes with
299
- the same revision or older, it should be ** ignored** . This should be independent of the source of the signal, as it might
300
- come from all the nodes during rebalance when the configuration push is enabled, or from ` NotMyVbucket ` responses.
317
+ 5 . SDK-side deduplication of push notifications. SDK should track which revision was used when last ` GET_CLUSTER_CONFIG `
318
+ was sent. So that if new notification comes with the same revision or older, it should be ** ignored** . It should also
319
+ ignore notifications which ` epoch ` /` revision ` are not newer than effective configuration that is used by the SDK.
301
320
302
321
6 . [ OPTIONAL] ` SnappyEverywhere ` (` 0x13 ` ). The SDK should be ready that KV engine might send Snappy-compressed payload with any
303
322
of the response types (including push notifications). Check datatype ` SNAPPY ` (` 0x02 ` ).
0 commit comments