-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for standard Idempotency-Key
header
#2998
Comments
The above looks wrong, the RFC recommends:
I think we need the checksum for this to work. Also considering the request path. |
The two generated queries are not equivalent. This part is missing:
I.e. you need to select the right columns for the SELECT-only query. + you need a WHERE condition to filter only the same row that was inserted earlier. This will only work reliably, if:
|
That sounds good, that way we don't have to parse the request body. We could just get the id with Seems this should work for batch inserts too? We'd do a checksum of all the pks in the payload + idempotency-key plus cache it. This should guarantee enough uniqueness I believe, so we don't need to use the JWT. |
I don't think a checksum of PKs would help at all. You need the actual PKs to run the SELECT query, not a checksum.
I think you are confusing what the "idempotency fingerprint" is about. You can't use any of the PKs - because you don't know them before, when sending the request. Whatever you use as a fingerprint needs to come from the request itself, there is no way around that. Using something from the JWT (either the JWT itself or just the role claim) would at least make sure that different users can't collide with the same idempotency key. When using UUID this is not a problem, but UUID is just a recommendation, not a requirement. Using a checksum of the full payload makes the most sense, imho. |
Problem
Currently idempotent requests (GET, HEAD) are retryable but not non-idempotent requests like POST or PATCH are not. This makes those requests fault intolerant in case of network errors.
Solution
Add support for specifying the standard
Idempotency-Key
header. The RFC is currently in draft but some services already support it:The main idea:
Under error it should cache the error:
In this case there's no need to change the query.
Implementation Notes
exp
(expiration) claim in the JWT or thejwt-cache-max-lifetime
(introduced on feat: implement JWT caching #2928).exp
, and Stripe also has a 24 hour limit for the idempotency key caching (ref).Open Questions
The text was updated successfully, but these errors were encountered: