lasdf1234 commented on code in PR #14972:
URL: https://github.com/apache/gravitino/pull/14972#discussion_r4657809696
##########
design-docs/iceberg-idempotency-key.md:
##########
@@ -292,26 +294,30 @@ CREATE TABLE IF NOT EXISTS `iceberg_idempotency_key_meta`
(
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'Iceberg
REST idempotency key records';
```
Review Comment:
CREATE TABLE IF NOT EXISTS `iceberg_idempotency_meta` (
`idempotency_key` VARCHAR(36) NOT NULL COMMENT 'client-provided
UUIDv7 idempotency key',
`http_method` VARCHAR(16) NOT NULL COMMENT 'HTTP method of
the request',
`request_uri` TEXT NOT NULL COMMENT 'request path and
sorted query string',
`generation` BIGINT(20) UNSIGNED NOT NULL DEFAULT 1 COMMENT
'reservation generation, starts at 1, increments on re-reserve',
`http_status` INT(10) UNSIGNED DEFAULT NULL COMMENT 'HTTP status
of finalized response, NULL while reserved',
`response_summary` MEDIUMTEXT DEFAULT NULL COMMENT 'serialized
response body (JSON) for replay',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'idempotency
record audit info',
`created_at` BIGINT(20) UNSIGNED NOT NULL COMMENT 'record created at
(unix epoch millis)',
`expires_at` BIGINT(20) UNSIGNED NOT NULL COMMENT 'record expires at
(unix epoch millis)',
PRIMARY KEY (`idempotency_key`),
KEY `idx_iim_expires` (`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'Iceberg
REST idempotency records';
Suggested schema tweaks and rationale
Rename table to iceberg_idempotency_meta
Drop key from the table name. The key is already the primary-key column. A
*_meta name matches Gravitino’s naming, and reads as “idempotency records,”
similar in spirit to Polaris’s former idempotency_records.
Replace hashed operation_binding with http_method + request_uri (plaintext)
Hashing was justified when the column was bounded (VARCHAR(512)) so a long
method+path+query would not be truncated into collisions. The column is now
TEXT, so the digest is unnecessary and hurts operability (you cannot see which
API a row belongs to). Storing plaintext method and URI keeps request identity
clear and debuggable. We do not need a user/realm column: the Iceberg REST spec
requires the Idempotency-Key to be globally unique.
Replace claim (ThreadLocalRandom.nextLong()) with monotonic generation
A random long is only probabilistically unique. After expiry, another
request may re-reserve the same key; if it happened to draw the same claim, a
late finalize/release from the old attempt could touch the new row. A per-key
monotonic generation (first reserve = 1, aligned with Gravitino’s
current_version default; on re-reserve atomically generation = generation + 1)
provides real fencing. The name generation fits values 1,2,3… better than claim.
--
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]