spinframework / spinframework/spin
WASI key-value store `increment` operations are not strictly idempotent across multiple backends
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6.5k
- Forks
- 310
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 24
Description
The WASI wasi:keyvalue/atomics interface describes atomic operations as all-or-nothing: if a fault causes an atomic operation to fail, the caller should observe either that it completed successfully or that it did nothing.
Spin’s remote KV backends rely on each service’s native update primitive. This can leave ambiguous outcomes:
- Azure Cosmos DB uses PATCH
increment; if Cosmos commits the PATCH but the response is lost, retrying may apply the increment again because PATCHincrementhas no native idempotency token. - Redis uses
INCR; if Redis applies the increment but the response is lost, retrying the command may also apply the increment again. - Avoiding retries prevents duplicate application, but Spin may still return an error even though the value changed.
This leaves a gap between the strict WASI fault semantics and what Spin can currently guarantee for remote KV stores. Fully closing it would likely require an internal exactly-once protocol, such as recording an operation id/result atomically with the counter update and reconciling ambiguous outcomes before returning. This is indeed not easy to implement, so I am documenting it as an issue for now.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the WASI wasi:keyvalue/atomics interface and Spin’s remote KV handling for Azure Cosmos DB and Redis. Assess whether an exactly-once operation-id/result protocol can resolve ambiguous retries without duplicate increments; done would require closing that semantic gap or documenting the remaining limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, redis, rust, wasm
- Domain
- backend, databases, distributed-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100