FINERACT-1420: Improve idempotency fallback using deterministic key generation#5674
FINERACT-1420: Improve idempotency fallback using deterministic key generation#5674elnafateh wants to merge 1 commit intoapache:developfrom
Conversation
...src/main/java/org/apache/fineract/commands/service/DeterministicIdempotencyKeyGenerator.java
Show resolved
Hide resolved
...src/main/java/org/apache/fineract/commands/service/DeterministicIdempotencyKeyGenerator.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/fineract/commands/service/DeterministicIdempotencyKeyGenerator.java
Outdated
Show resolved
Hide resolved
|
Also: 2 commits... please squash into 1 according to rules. No reference to a ticket in the PR title... please follow the rules (there are not many). |
|
I see nothing related to the "DB-level uniqueness constraint"... there is nothing mentioning the existing idempotency solution, possible side effects with this implementation, how we should migrate from one to the other, do we have to migrate at all? Looks incomplete. |
I’ve made required update and then quash the commits into a single one and I’ve also added the ticket number. |
Fair point — the PR description needs to be clearer. This change does not replace the existing idempotency mechanism but enhances it by providing a fallback when no idempotency key is supplied.
I will update the PR description to reflect these aspects clearly. |
Introduce deterministic idempotency key generation when a client-provided key is absent. The key is derived from canonical request payload with a time window to support safe retries. Enhancements: - deterministic retry behavior without client-provided keys - proper JSON canonicalization (ordering, nested objects, null handling) This change extends the existing idempotency mechanism without replacing it.
Description
This PR improves the existing idempotency mechanism by enhancing the fallback behavior when no idempotency key is provided by the client.
Currently, when a request is sent without an idempotency key, the system generates a random key, which breaks retry safety in real-world scenarios (e.g. network failures). Retried requests are treated as new operations, leading to potential duplicate processing.
This change introduces deterministic idempotency key generation based on a canonical representation of the request payload combined with a time window.
Key Points
Trade-offs
Semantically identical requests within the same time window may be deduplicated unintentionally. This is a design trade-off to ensure retry safety.
Scope
This change aligns with FINERACT-1420 by improving API fault tolerance and preventing duplicate request execution.
This contribution is part of my preparation for Google Summer of Code and aims to improve reliability in Fineract's command processing pipeline.
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.