@@ -128,7 +128,7 @@ negotiated, the node will always use the compressed version of the cluster confi
128128to ` JSON | SNAPPY ` (` 0x03 ` ).
129129
130130Note, 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".
132132
133133### ` GetClusterConfig ` and Out-of-Order Execution
134134
@@ -157,7 +157,7 @@ drawbacks, such as:
157157 updates on all sockets. This process takes unnecessary time, unlike when the SDK polls every 2.5 seconds.
158158
159159The 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.
161161
162162Since version 7.6, the KV engine introduces the HELLO flag ` ClustermapChangeNotificationBrief ` (` 0x1f ` ). This flag
163163instructs the KV engine to exclude the cluster configuration content from the notification. In this case, the data type
@@ -245,37 +245,59 @@ configuration will be received.t
245245
246246### Enhancements in Handling the ` NotMyVbucket ` Status
247247
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.
251250
252251Several 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{Empty Body?}
265+ B -->|No|C(Apply Configuration)
266+ C --> D{Route Operation}
267+ D -->|Endpoint Changed| E[Dispatch To<br>New Endpoint]
268+ D -->|VBucketID Changed| F[Update VBucketID]
269+ F --> G[Dispatch To<br>Same Endpoint]
270+ D -->|Everything Else| H[Send To Retry<br>Orchestrator]
271+ B -->|Yes|H[Send To Retry<br>Orchestrator]
272+ ```
273+
274+
275+ Below is a diagram that illustrates an example of the SDK workflow
261276
262277``` mermaid
263278sequenceDiagram
264279 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()
280+
281+ participant conn_1
282+ participant kv_node_1
283+ participant retry_orchestrator
284+ participant config_monitor
285+
286+ conn_1 ->>+ kv_node_1: get("foo", vb=115)
287+ kv_node_1 ->>- conn_1: NotMyVbucket(config={epoch=1, rev=11, ...})
288+
289+ conn_1 -->>+ config_monitor: propose confg={epoch=1, rev=11}
290+
291+
292+ critical Check if config route operation to different node of vbucket
293+
294+ option "foo" still maps to kv_node_1
295+ conn_1 -->>+ retry_orchestrator: retry(get, "foo", reason=NotMyVbucket, epoch=1, rev=11)
296+
297+ option "foo" does not map to kv_node_1, or vbucket has changed
298+ conn_1 -->+ kv_node_1: get("foo", vb=new_vbucket)
299+ kv_node_1 ->>- conn_1: Success()
300+ end
279301```
280302
281303# Language Specifics
@@ -294,10 +316,9 @@ sequenceDiagram
2943164 . ` ClustermapChangeNotificationBrief ` (` 0x1f ` ). The SDK should always subscribe for configuration notifications, if the
295317 server supports it, and fallback to polling if it does not.
296318
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.
319+ 5 . SDK-side deduplication of push notifications. SDK should track which revision was used when last ` GET_CLUSTER_CONFIG `
320+ was sent. So that if new notification comes with the same revision or older, it should be ** ignored** . It should also
321+ ignore notifications which ` epoch ` /` revision ` are not newer than effective configuration that is used by the SDK.
301322
3023236 . [ OPTIONAL] ` SnappyEverywhere ` (` 0x13 ` ). The SDK should be ready that KV engine might send Snappy-compressed payload with any
303324 of the response types (including push notifications). Check datatype ` SNAPPY ` (` 0x02 ` ).
0 commit comments