laserninja opened a new pull request, #12470: URL: https://github.com/apache/gravitino/pull/12470
> Split out of the original single PR per review feedback: this one is the storage seam only (~1000 lines), the endpoint wiring follows in a stacked PR. ### What changes were proposed in this pull request? First half of phase 1 of the Idempotency-Key design (`design-docs/iceberg-idempotency-key.md`): the pluggable storage seam and its node-local implementation. No endpoint is wired yet, so this change has no runtime effect on its own. - **`IdempotencyStore`** SPI built around reserve, execute, finalize. An implementation only has to make `reserve` atomic across the callers that share its storage; that single guarantee is what keeps a retried request from re-running a mutation. `release` hands a key back after a retryable failure, and `purgeExpired` drops records whose reuse window has elapsed. - **`IdempotencyRecord`**, immutable, carrying the operation binding and the response replayed to retries. Timestamps are epoch millis so a database-backed store maps them onto `BIGINT` columns like Gravitino's other metadata tables. - **`IdempotencyKeys`** validates the header as an RFC 9562 UUIDv7, rejecting malformed keys before they reach storage. - **`InMemoryIdempotencyStore`**, a Caffeine cache bounded by the key lifetime and a max entry count. Its Javadoc is explicit that it is best-effort and single-node, and it warns when the size bound evicts a record before its window elapses. - **`IdempotencyStoreFactory`** resolves the configured store, by short name or by class name. - Config entries for enablement, key lifetime, store type, and capacity, all inert until the endpoints are wired. Follow-ups, each its own PR: 1. The manager and endpoint wiring, which turns this into a working feature. Already prepared and stacked on this branch. 2. The durable, multi-node JDBC store on Gravitino's relational backend (phase 2 of the design). ### Why are the changes needed? Epic #12049. Without idempotency support, a client retry after a network failure re-executes the mutation and produces duplicate table/namespace/view creates and drops. Splitting the storage seam out first keeps each change small enough to review properly, and it is the interface the JDBC store in phase 2 plugs into. Supersedes #10751, which used a node-local Caffeine cache with no storage seam. Fix: #12049 ### Does this PR introduce _any_ user-facing change? No behavior change. It adds four properties that do nothing until the endpoints are wired in the follow-up: `gravitino.iceberg-rest.idempotency-enabled` (`false`), `idempotency-key-lifetime` (`PT30M`), `idempotency-store-type` (`in-memory`), `idempotency-max-entries` (`10000`). They are documented alongside the feature in the follow-up PR. ### How was this patch tested? New unit tests: - `TestIdempotencyKeys` - accepts UUIDv7 in both cases and across the RFC 9562 variant range; rejects UUIDv1/v4, the NCS and Microsoft variants, the nil UUID, non-canonical lengths, and non-hex input. - `TestInMemoryIdempotencyStore` - single-winner `reserve` under 16 concurrent threads, `load` empty until finalized, `release` freeing a reservation but preserving a finalized record, no resurrection of a record purged while its mutation ran, `purgeExpired` removing only elapsed rows, size-bound eviction. - `TestIdempotencyStoreFactory` - default and short-name resolution, a store loaded by class name and initialized, and a clear failure for an unknown store. `iceberg-common` suite passes on JDK 17: 95 tests, 0 failures. ```bash ./gradlew :iceberg:iceberg-common:test -PskipITs ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
