denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.15k stars 5.36k forks source link

[KV] Provide more feedback for atomic check failures #21493

Open cknight opened 10 months ago

cknight commented 10 months ago

At the moment if an atomic check fails, the only feedback you get is that the transaction failed. If possible it would be good to get more feedback. E.g.

const result = await kv.atomic()
        .check({ key: ["asdf"], versionstamp: "0000000000002e990000" })
        .set(["asdf"], "2")
        .commit();
console.log(result);

If the check above fails, the response is { ok: false }. This works fine in the above scenario where you have a single check. However, imagine you are committing 100 keys of data with corresponding 100 checks, one for each key being committed. If only 1 of the 100 checks fails you still only get the feedback { ok: false } without knowing which check(s) failed (or if it was even the check which caused the failure?).

Suggestion: If one or more checks fail, add the failed key(s) to the response under failedChecks property so the user can take more targeted action afterwards (e.g. in the example above retrying with the other 99 keys, handling the one failed key separately).

pubkey commented 6 months ago

@cknight any update on this?

cknight commented 6 months ago

@pubkey None that I'm aware of.