google / google/tensorstore

tsgrpc_kvstore driver - how to signal `generation_if_equal` mismatch on write?

Open
#251 13 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.5k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to implement a gRPC service for the tsgrpc_kvstore driver, and trying to understand how to correctly support the `generation_if_equal` option for `WriteRequest`. In particular, how to handle the case where the generation does not match - the comment in the proto says "the write is aborted" on a mismatch, what exactly does this mean?

Both returning an error from the RPC and returning an error in the `WriteResponse.status` field leads to the TensorStore write to fail immediately, which leads me to believe this is not what I should do?

Looking at [PerformWriteback](https://github.com/google/tensorstore/blob/933712f0628f9170ed00eafdd561402eb6fb77fe/tensorstore/kvstore/transaction.cc#L134) I see that the transaction is re-tried if the returned generation is "unknown" (== empty). However if I try this, TensorStore just sends writes with `generation_if_equal=StorageGeneration::NoValue()` in a loop, instead of what I would expect:
1. Attempt a write with an old generation, receive StorageGeneration::Unknown
2. Issue a read to obtain the current value of the file
3. Issue a new write, with the update generation and value

thank you!

PS: I'm also a bit unclear what I should use for the `timestamp` value of `GenerationAndTimestamp` - is this intended to be the current time of the gRPC server? The last modified time of the file?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.