spinframework / spinframework/spin

WASI key-value store `increment` operations are not strictly idempotent across multiple backends

Open
#3,563 0 comments 0 reactions 0 assignees View on GitHub

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 PATCH increment has 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.