Repository navigation
feat(catalog/rest): send Idempotency-Key on mutations when the server advertises it - #2492
Conversation
… advertises it Signed-off-by: Ayaan <ayaansiddiqui68@gmail.com>
a2274d0 to
b382f48
Compare
zeroshade
left a comment
There was a problem hiding this comment.
Thanks @AynSiddiqui — keying off a present idempotency-key-lifetime matches Java's apache/iceberg#14740, every listed mutation gets a fresh UUIDv7 while reads and the config call get none, and dropping a static default key once support is advertised avoids reusing one key across calls. The docs and release note are upfront that net/http may now replay keyed requests on a reused connection (Request.isReplayable honours Idempotency-Key) and that the lifetime isn't enforced yet; that's the right scope for this first step. Merged with current main, go vet ./... is clean and ./catalog/rest passes under -race.
This review was drafted by an AI-assisted tool and confirmed by an Apache Iceberg Go maintainer. The findings below are observations, not blockers; an Apache Iceberg Go maintainer — a real person — will take the next look at the PR. If you think a finding is mis-applied, please reply on the PR and a maintainer will weigh in.
More on how Apache Iceberg Go handles maintainer review: CONTRIBUTING.md.
Refs #2443
What
idempotency-key-lifetimefromGET /v1/config. When it is a non-null string, send a fresh UUIDv7Idempotency-Keyon create/drop namespace, update namespace properties, create/register/update/commit/drop/purge/rename table, commit transaction, create/replace/drop/rename/register view, and cancel planning. BothUpdateTableandCommitTableare covered.Idempotency-Keyheader is dropped from every later request, so one static key is never shared across different calls. The initialGET /v1/configcan still carry it, because support isn't known yet. Without advertisement, default headers behave as before.Why
The REST spec lets a server advertise idempotency support so clients can resend a mutation that may already have been applied. Java has sent the header since apache/iceberg#14740, and PyIceberg since apache/iceberg-python#4310.
Scope
This is the first of two PRs, following Java's sequence: apache/iceberg#14740 for headers, then apache/iceberg#17947 and apache/iceberg#18070 for retries and lifetime bounds. It follows decisions 3 and 4 in #2443 (comment); decisions 1 and 2 (key scope for resends, lifetime limit) belong to the follow-up. This PR adds no explicit HTTP-status retry loop. Scan plan/task POSTs already generate and retry keys independently of lifetime advertisement and are unchanged here; the follow-up will bring them under the same rules.
With the header set, Go's standard
net/httptransport may replay certain failed requests on reused connections with the same key. The advertised lifetime is not yet enforced, includingPT0Sor malformed values. This behavior is documented inwebsite/src/configuration.mdandwebsite/src/releases.md.Tests
TestMutationIdempotencyHeaders: when advertised, every covered method, including create view, sends a canonical UUIDv7 and two calls get different keys. The tested reads get no generated key. Absent or null lifetime disables automatic keys; empty and malformed strings enable them, matching Java's Core: Send Idempotency-Key on mutation requests when advertised iceberg#14740 presence check.TestDefaultIdempotencyHeader: a static defaultIdempotency-Keyis sent unchanged without advertisement; with advertisement it is dropped on reads and replaced by a generated key on mutations.TestMutationTransportReplay: after the server reads the first POST body and drops the reused connection, the advertised andPT0Scases resend once with the same key and body. Without advertisement, the client returns an error after one attempt.go test -race -count=1 ./catalog/rest/...,go test -race -count=20 ./catalog/rest -run '^TestMutationTransportReplay$',go vet ./catalog/rest/..., fullmake lintandgit diff --check origin/main HEADpass, plusgo test ./catalog/... ./table/.... Fullmake test, integration tests anddev/check-api-compat.shweren't run. No exported API changed.