This is an automated email from the ASF dual-hosted git repository.

roryqi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c78d0423f [#12049] feat(iceberg-rest-server): honor Idempotency-Key 
on mutation endpoints (#12474)
4c78d0423f is described below

commit 4c78d0423f5d6d30d330d9f7e5e5680b5debb95c
Author: Akshay Thorat <[email protected]>
AuthorDate: Sun Nov 15 18:17:55 2026 -0800

    [#12049] feat(iceberg-rest-server): honor Idempotency-Key on mutation 
endpoints (#12474)
    
    > Second half of the split. Stacked on #12470 - the first commit here
    belongs to that PR, so review the second commit (`+1143/-32`) only. I'll
    rebase onto main and undraft once #12470 merges.
    
    ### What changes were proposed in this pull request?
    
    Puts the storage seam from #12470 behind the REST endpoints.
    
    - **`IcebergIdempotencyManager`** runs reserve, execute, finalize around
    a mutation. Retries replay the stored response; a key reused for another
    operation, or one whose first request is still in flight, gets `409
    Conflict` (the latter with `Retry-After`); `5xx` releases the key so the
    client can retry with it.
    - **Endpoint wiring** for create, update, drop, register, and rename
    across tables, namespaces, and views (13 endpoints). Each endpoint
    delegates to a private method holding its original body, so the
    idempotency seam is visible at the call site and the mutation itself
    reads unchanged.
    - **`GET /v1/config`** advertises `idempotency-key-lifetime` as the
    top-level `CatalogConfig` field the spec defines, not a `defaults` entry
    as the design document's example showed, and only when enabled, since
    the spec reads its absence as no support. Iceberg 1.11's
    `ConfigResponse.Builder.withIdempotencyKeyLifetime()` already supports
    it.
    
    One deliberate deviation from the spec: `401`, `403`, and `419`
    **release** the key rather than finalizing it. The spec finalizes
    deterministic terminal `4xx`, but auth outcomes depend on the caller's
    credentials rather than catalog state, so replaying them would keep
    failing a retry that has since obtained a valid token.
    
    Known limitation, documented in the manager's Javadoc: a replayed
    response carries the original status and body but not headers, so a
    replayed create/update does not carry the `ETag` the first response did.
    
    ### Why are the changes needed?
    
    Epic #12049. Completes phase 1 of the design. Phase 2, the durable
    multi-node JDBC store, follows separately.
    
    Fix: #12049
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes. Clients can send `Idempotency-Key: <UUIDv7>` on mutation requests
    for safe retries, and `GET /v1/config` includes
    `idempotency-key-lifetime` when enabled. Documents the four properties
    added in #12470. Off by default, so default behavior is unchanged.
    
    ### How was this patch tested?
    
    - `TestIcebergIdempotencyManager` - replay, distinct keys, bodiless
    `204` replay, terminal `4xx` replay, `5xx`/`401`/thrown-exception
    release, invalid key rejected without executing, operation-binding
    mismatch, in-flight `409` with `Retry-After`, query-parameter-sorted
    bindings.
    - `TestIcebergIdempotencyKey` - end-to-end through Jersey: a replayed
    create fires no second `IcebergCreateTableEvent`, a fresh key
    re-executes into `409 AlreadyExists`, a stored `409` replays, a key
    reused on `DELETE` is rejected and the table survives, a drop replays
    `204` where a retry would otherwise `404`, and `GET /v1/config` carries
    `PT30M`.
    - `TestIcebergConfig` - the lifetime is absent when disabled.
    
    `iceberg-rest-server` suite passes on JDK 17: 418 tests, 0 failures.
    
    ```bash
    ./gradlew :iceberg:iceberg-rest-server:test -PskipITs
    ```
---
 docs/iceberg-rest-service.md                       |  26 ++
 .../org/apache/gravitino/iceberg/RESTService.java  |   8 +
 .../idempotency/IcebergIdempotencyManager.java     | 327 ++++++++++++++++++
 .../service/rest/IcebergConfigOperations.java      |  10 +-
 .../service/rest/IcebergNamespaceOperations.java   |  73 ++++-
 .../service/rest/IcebergTableOperations.java       |  45 ++-
 .../service/rest/IcebergTableRenameOperations.java |  21 +-
 .../service/rest/IcebergViewOperations.java        |  45 ++-
 .../service/rest/IcebergViewRenameOperations.java  |  21 +-
 .../idempotency/TestIcebergIdempotencyManager.java | 365 +++++++++++++++++++++
 .../iceberg/service/rest/IcebergRestTestUtil.java  |  50 ++-
 .../rest/MockIcebergNamespaceOperations.java       |   6 +-
 .../service/rest/MockIcebergTableOperations.java   |   5 +-
 .../rest/MockIcebergTableRenameOperations.java     |   6 +-
 .../service/rest/MockIcebergViewOperations.java    |   7 +-
 .../rest/MockIcebergViewRenameOperations.java      |   7 +-
 .../iceberg/service/rest/TestIcebergConfig.java    |   9 +
 .../service/rest/TestIcebergIdempotencyConfig.java |  55 ++++
 .../TestIcebergIdempotencyFinalizeFailure.java     | 108 ++++++
 .../service/rest/TestIcebergIdempotencyKey.java    | 279 ++++++++++++++++
 .../TestIcebergNamespaceAuthorizationPaths.java    |   4 +
 .../service/rest/TestIcebergTableOperations.java   |   7 +-
 .../TestIcebergViewAuthorizationExpression.java    |  21 +-
 ...bergMetadataAuthorizationMethodInterceptor.java |  40 ++-
 .../TestIcebergRequestBodyAuthzHandlers.java       |   9 +-
 .../web/filter/TestRegisterTableAuthzHandler.java  |  12 +-
 .../web/filter/TestUpdateTableAuthzHandler.java    |  12 +-
 27 files changed, 1526 insertions(+), 52 deletions(-)

diff --git a/docs/iceberg-rest-service.md b/docs/iceberg-rest-service.md
index dca337ab5d..34bc8860f9 100644
--- a/docs/iceberg-rest-service.md
+++ b/docs/iceberg-rest-service.md
@@ -178,6 +178,32 @@ The settings below tune the background workers and are 
optional.
 | `gravitino.iceberg-rest.async-cleanup.max-attempts`           | Number of 
failed attempts before a cleanup job is marked `FAILED`.                        
           | `5`           | No       |
 | `gravitino.iceberg-rest.async-cleanup.retention-hours`        | Retention 
time for terminal `SUCCEEDED` or `FAILED` cleanup rows before pruning.          
           | `720`         | No       |
 
+#### Idempotency Key
+
+The Iceberg REST spec defines an optional `Idempotency-Key` header on mutation 
endpoints so that a client can safely retry a request whose response it never 
saw. When enabled and the header is present, the server reserves the key, 
executes the mutation, and stores the response for replay while the record 
remains available.
+
+Support is disabled by default. Once enabled, the reuse window is advertised 
as `idempotency-key-lifetime` in `GET /v1/config`; per the spec, clients must 
assume idempotency is unsupported when that field is absent.
+
+The header applies to the create, update, drop, register, and rename endpoints 
for tables, namespaces, and views. Its value must be a UUIDv7 in string form 
([RFC 9562](https://www.rfc-editor.org/rfc/rfc9562)); anything else returns 
`400 Bad Request`. Keys must be globally unique: reusing one with a different 
HTTP method, path, or query returns `409 Conflict`, and so does a retry that 
arrives while the first request is still running (with a `Retry-After` header). 
Successful and determinis [...]
+
+| Configuration item                                | Description              
                                                                                
                                                                    | Default 
value | Required |
+|---------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|
+| `gravitino.iceberg-rest.idempotency-enabled`      | Whether to honor the 
`Idempotency-Key` header. When `false`, the header is ignored and no lifetime 
is advertised.                                                             | 
`false`       | No       |
+| `gravitino.iceberg-rest.idempotency-key-lifetime` | The client reuse window 
for a key, an ISO-8601 duration such as `PT30M`. Advertised to clients as 
`idempotency-key-lifetime`.                                                 | 
`PT30M`       | No       |
+| `gravitino.iceberg-rest.idempotency-store-type`   | The store holding 
idempotency records, either the `in-memory` short name or the fully-qualified 
class name of an `IdempotencyStore` implementation.                           | 
`in-memory`   | No       |
+| `gravitino.iceberg-rest.idempotency-max-entries`  | The maximum number of 
records retained by the in-memory store. Records beyond it are evicted before 
their reuse window elapses.                                               | 
`10000`       | No       |
+
+Phase-1 limitations:
+
+- Request identity covers the HTTP method, path, and query parameters. It does 
**not** compare request bodies or behavior-changing headers such as 
`X-Iceberg-Access-Delegation`. Reusing a key on the same URL with a changed 
body or header replays the first response; it does not apply the changed 
request. Always generate a new key for a different logical operation. Request 
validation runs before replay, so a retry with an invalid body can return `400 
Bad Request` even if the key already ha [...]
+- Replay preserves the status and JSON body but omits response headers such as 
`ETag`. Load the table again if the client needs its current ETag.
+- The catalog mutation and response persistence are not one transaction. A 
crash, serialization failure, lost reservation, or post-commit failure can 
leave a successful mutation without a replayable response. A retry can then 
execute again. Claim fencing protects replacement records, but cannot undo or 
fence catalog side effects.
+- This phase does not schedule `IdempotencyStore.purgeExpired`. The in-memory 
store reclaims expired entries through Caffeine. Custom stores must enforce 
expiry on reads/reservations and arrange their own cleanup; durable-store purge 
scheduling belongs to the JDBC follow-up.
+
+:::caution
+Enabling `idempotency-enabled=true` with the default 
`idempotency-store-type=in-memory` on more than one replica does **not** 
provide cluster-wide deduplication: retries can execute a mutation twice. The 
`in-memory` store is node-local and not durable. A retry routed to another 
replica, or to a replica that restarted, finds no record and re-executes the 
mutation, and its size bound can evict a record before its reuse window 
elapses, including an in-flight reservation. A retry can then ru [...]
+:::
+
 ### Catalog Backend Configuration
 
 :::info
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java
index 47a1344de3..645ce50897 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java
@@ -51,6 +51,7 @@ import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewEventDispatche
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewHookDispatcher;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationExecutor;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.iceberg.service.metrics.IcebergMetricsManager;
 import org.apache.gravitino.iceberg.service.provider.IcebergConfigProvider;
 import 
org.apache.gravitino.iceberg.service.provider.IcebergConfigProviderFactory;
@@ -90,6 +91,7 @@ public class RESTService implements GravitinoAuxiliaryService 
{
 
   private IcebergCatalogWrapperManager icebergCatalogWrapperManager;
   private IcebergMetricsManager icebergMetricsManager;
+  private IcebergIdempotencyManager icebergIdempotencyManager;
   private Optional<IcebergCleanupManager> cleanupManager;
   private IcebergConfigProvider configProvider;
   private boolean auxMode;
@@ -150,6 +152,7 @@ public class RESTService implements 
GravitinoAuxiliaryService {
             skipAuthorizationForRestBackend,
             icebergCatalogWrapperManager);
     this.icebergMetricsManager = new IcebergMetricsManager(icebergConfig);
+    this.icebergIdempotencyManager = new 
IcebergIdempotencyManager(icebergConfig);
     if (auxMode) {
       // Async cleanup reuses the entity store's shared relational backend 
(connection pool +
       // per-backend SQL), which is only available when running embedded in 
the Gravitino server
@@ -213,6 +216,7 @@ public class RESTService implements 
GravitinoAuxiliaryService {
             }
             
bind(icebergCatalogWrapperManager).to(IcebergCatalogWrapperManager.class).ranked(1);
             
bind(icebergMetricsManager).to(IcebergMetricsManager.class).ranked(1);
+            
bind(icebergIdempotencyManager).to(IcebergIdempotencyManager.class).ranked(1);
             cleanupManager.ifPresent(
                 manager -> 
bind(manager).to(IcebergCleanupManager.class).ranked(1));
             
bind(icebergTableDispatcher).to(IcebergTableOperationDispatcher.class).ranked(1);
@@ -300,6 +304,7 @@ public class RESTService implements 
GravitinoAuxiliaryService {
         // Stop the components we already started so they don't outlive a 
failed startup.
         cleanupManager.ifPresent(IcebergCleanupManager::close);
         icebergMetricsManager.close();
+        icebergIdempotencyManager.close();
         throw new RuntimeException(e);
       }
     }
@@ -320,6 +325,9 @@ public class RESTService implements 
GravitinoAuxiliaryService {
     if (icebergMetricsManager != null) {
       icebergMetricsManager.close();
     }
+    if (icebergIdempotencyManager != null) {
+      icebergIdempotencyManager.close();
+    }
     cleanupManager.ifPresent(IcebergCleanupManager::close);
   }
 
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/idempotency/IcebergIdempotencyManager.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/idempotency/IcebergIdempotencyManager.java
new file mode 100644
index 0000000000..75b71c92a7
--- /dev/null
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/idempotency/IcebergIdempotencyManager.java
@@ -0,0 +1,327 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.iceberg.service.idempotency;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.hash.Hashing;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.StringJoiner;
+import java.util.TreeMap;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.apache.gravitino.iceberg.common.idempotency.IdempotencyKeys;
+import org.apache.gravitino.iceberg.common.idempotency.IdempotencyRecord;
+import org.apache.gravitino.iceberg.common.idempotency.IdempotencyStore;
+import 
org.apache.gravitino.iceberg.common.idempotency.IdempotencyStore.ReserveResult;
+import org.apache.gravitino.iceberg.common.idempotency.IdempotencyStoreFactory;
+import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;
+import org.apache.gravitino.iceberg.service.IcebergObjectMapper;
+import org.apache.gravitino.iceberg.service.IcebergRESTUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Applies {@code Idempotency-Key} semantics to Iceberg REST mutation 
endpoints.
+ *
+ * <p>Each mutation runs through {@link #replayOrExecute}, which claims the 
key, executes the
+ * mutation, and stores its response. While that record remains available, 
retries carrying the same
+ * key get the original answer back instead of a second mutation. Idempotency 
is off by default;
+ * when it is off, or when a request carries no key, the mutation runs 
directly and nothing is
+ * stored.
+ *
+ * <p>A replayed response carries the original status and body. Response 
headers are not stored, so
+ * a replayed create or update does not carry the {@code ETag} the first 
response did; clients that
+ * rely on it simply load the table again.
+ *
+ * <p>Request bodies and behavior-changing headers are not compared. Reusing a 
key on the same URL
+ * with different body/header values replays the first response; clients must 
use a new key for a
+ * different logical operation. The catalog mutation and response storage are 
not transactional:
+ * eviction, a crash, serialization failure, or a post-commit exception can 
permit re-execution.
+ *
+ * <p>This phase does not schedule {@link IdempotencyStore#purgeExpired}. The 
in-memory store uses
+ * Caffeine for reclamation. Custom stores must enforce deadlines and arrange 
their own cleanup;
+ * scheduling durable cleanup belongs to the JDBC-store integration.
+ */
+public class IcebergIdempotencyManager {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(IcebergIdempotencyManager.class);
+
+  /** The idempotency key header defined by the Iceberg REST spec. */
+  public static final String IDEMPOTENCY_KEY = "Idempotency-Key";
+
+  /** Seconds a client should wait before retrying a request whose key is 
still in flight. */
+  private static final int RETRY_AFTER_SECONDS = 1;
+
+  /**
+   * Statuses that are terminal for the request but not for the key. 
Authentication and
+   * authorization outcomes depend on the caller's credentials rather than on 
catalog state, so
+   * replaying them would keep failing a retry that has since obtained valid 
credentials.
+   */
+  private static final Set<Integer> NON_FINALIZABLE_STATUSES = 
ImmutableSet.of(401, 403, 419);
+
+  private final boolean enabled;
+  private final Duration keyLifetime;
+  private final ObjectMapper icebergObjectMapper;
+  private final Optional<IdempotencyStore> store;
+
+  /**
+   * Creates a manager, loading the configured store when idempotency is 
enabled.
+   *
+   * @param icebergConfig the Iceberg REST server configuration
+   */
+  public IcebergIdempotencyManager(IcebergConfig icebergConfig) {
+    this(
+        icebergConfig,
+        icebergConfig.get(IcebergConfig.ICEBERG_IDEMPOTENCY_ENABLED)
+            ? Optional.of(IdempotencyStoreFactory.create(icebergConfig))
+            : Optional.empty());
+  }
+
+  @VisibleForTesting
+  IcebergIdempotencyManager(IcebergConfig icebergConfig, 
Optional<IdempotencyStore> store) {
+    this.enabled = 
icebergConfig.get(IcebergConfig.ICEBERG_IDEMPOTENCY_ENABLED);
+    this.keyLifetime =
+        
Duration.parse(icebergConfig.get(IcebergConfig.ICEBERG_IDEMPOTENCY_KEY_LIFETIME));
+    this.icebergObjectMapper = IcebergObjectMapper.getInstance();
+    this.store = store;
+  }
+
+  /**
+   * Returns the key reuse window to advertise to clients.
+   *
+   * @return the lifetime as an ISO-8601 duration, or {@link Optional#empty()} 
when idempotency is
+   *     disabled. The Iceberg REST spec reads the absence of {@code 
idempotency-key-lifetime} in
+   *     the config response as "this server does not support idempotency".
+   */
+  public Optional<String> advertisedKeyLifetime() {
+    return enabled ? Optional.of(keyLifetime.toString()) : Optional.empty();
+  }
+
+  /**
+   * Runs a mutation under the given idempotency key.
+   *
+   * <p>Without a key, or with idempotency disabled, this just runs {@code 
action}. With a key, the
+   * first request claims it and stores the response; retries carrying the 
same key replay that
+   * response. A retry that arrives while the first request is still running, 
or that reuses a key
+   * already spent on a different operation, gets {@code 409 Conflict}.
+   *
+   * @param idempotencyKey the raw {@code Idempotency-Key} header value, may 
be {@code null}
+   * @param operationBinding request identity, see {@link 
#operationBinding(String, UriInfo)}
+   * @param action the mutation, which is expected to return its own error 
responses rather than
+   *     throw
+   * @return the response to send to the client
+   */
+  public Response replayOrExecute(
+      @Nullable String idempotencyKey, String operationBinding, 
Supplier<Response> action) {
+    if (!enabled || StringUtils.isBlank(idempotencyKey) || !store.isPresent()) 
{
+      return action.get();
+    }
+
+    String key;
+    try {
+      key = IdempotencyKeys.canonicalize(idempotencyKey);
+    } catch (IllegalArgumentException e) {
+      return IcebergExceptionMapper.toRESTResponse(e);
+    }
+
+    IdempotencyStore idempotencyStore = store.get();
+    String binding =
+        Hashing.sha256().hashString(operationBinding, 
StandardCharsets.UTF_8).toString();
+    long expiresAtMs = System.currentTimeMillis() + keyLifetime.toMillis();
+    // A fresh claim per attempt, so that if this reservation is dropped 
underneath us and another
+    // request takes the key, our finalize or release lands on nothing instead 
of on its record.
+    long claim = ThreadLocalRandom.current().nextLong();
+    if (idempotencyStore.reserve(key, binding, claim, expiresAtMs) == 
ReserveResult.DUPLICATE) {
+      return replay(idempotencyStore, key, binding);
+    }
+
+    boolean finalized = false;
+    try {
+      Response response = action.get();
+      int status = response.getStatus();
+      // Store successful and terminal client responses. Release 5xx and auth 
outcomes so retries
+      // can re-evaluate them; serialization/finalization failure also 
releases only our claim.
+      if (status < Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()
+          && !NON_FINALIZABLE_STATUSES.contains(status)) {
+        finalized = tryFinalize(idempotencyStore, key, claim, response);
+      }
+      return response;
+    } finally {
+      if (!finalized) {
+        // Only release this attempt's claim when the response is retryable or 
was not retained.
+        // A replacement owner's reservation must remain untouched.
+        idempotencyStore.release(key, claim);
+      }
+    }
+  }
+
+  /**
+   * Builds the request identity stored alongside a key. Retries of the same 
logical operation
+   * produce the same binding, while a key reused for a different request does 
not.
+   *
+   * <p>The identity covers the method, encoded path, and sorted, encoded 
query parameters. Bodies
+   * and behavior-changing headers are not compared; clients must use a fresh 
key for a different
+   * logical operation. The manager stores a SHA-256 digest of the complete 
identity to fit the
+   * store's bounded binding column without truncating distinct requests.
+   *
+   * @param httpMethod the HTTP method of the endpoint
+   * @param uriInfo the request URI, may be {@code null} outside a request 
context
+   * @return the operation binding, for example {@code POST 
/v1/cat1/namespaces/ns1/tables}
+   */
+  public static String operationBinding(String httpMethod, @Nullable UriInfo 
uriInfo) {
+    if (uriInfo == null) {
+      return httpMethod;
+    }
+    StringBuilder binding =
+        new StringBuilder(httpMethod).append(" 
/").append(uriInfo.getPath(false));
+    MultivaluedMap<String, String> queryParameters = 
uriInfo.getQueryParameters();
+    if (queryParameters != null && !queryParameters.isEmpty()) {
+      // Sorted, so that clients that order query parameters differently 
between a request and its
+      // retry still land on the same binding.
+      StringJoiner query = new StringJoiner("&", "?", "");
+      for (Map.Entry<String, List<String>> parameter : new 
TreeMap<>(queryParameters).entrySet()) {
+        for (String value : 
parameter.getValue().stream().sorted().collect(Collectors.toList())) {
+          query.add(
+              URLEncoder.encode(parameter.getKey(), StandardCharsets.UTF_8)
+                  + "="
+                  + URLEncoder.encode(value, StandardCharsets.UTF_8));
+        }
+      }
+      binding.append(query);
+    }
+    return binding.toString();
+  }
+
+  /** Closes the underlying store. */
+  public void close() {
+    store.ifPresent(
+        idempotencyStore -> {
+          try {
+            idempotencyStore.close();
+          } catch (IOException e) {
+            LOG.warn("Close Iceberg idempotency store failed.", e);
+          }
+        });
+  }
+
+  private Response replay(
+      IdempotencyStore idempotencyStore, String idempotencyKey, String 
binding) {
+    Optional<IdempotencyRecord> record = idempotencyStore.load(idempotencyKey);
+    if (!record.isPresent()) {
+      // Reserved but not finalized: the first request is still running, here 
or on another node.
+      return conflict(
+          "Idempotency-Key: "
+              + idempotencyKey
+              + " is being processed by another request, retry later",
+          true);
+    }
+
+    IdempotencyRecord found = record.get();
+    if (!found.operationBinding().equals(binding)) {
+      // Replaying here would hand the client the response of an unrelated 
operation.
+      return conflict(
+          "Idempotency-Key: "
+              + idempotencyKey
+              + " was already used for a different operation; use a new key",
+          false);
+    }
+
+    LOG.info(
+        "Replaying the stored response for Idempotency-Key: {}, operation: {}, 
http status: {}.",
+        idempotencyKey,
+        binding,
+        found.httpStatus());
+    Response.ResponseBuilder builder = Response.status(found.httpStatus());
+    if (found.responseSummary() != null) {
+      builder.entity(found.responseSummary()).type(MediaType.APPLICATION_JSON);
+    }
+    return builder.build();
+  }
+
+  private boolean tryFinalize(
+      IdempotencyStore idempotencyStore, String idempotencyKey, long claim, 
Response response) {
+    String responseSummary;
+    try {
+      Object entity = response.getEntity();
+      if (entity == null) {
+        responseSummary = null;
+      } else if (entity instanceof String) {
+        responseSummary = (String) entity;
+      } else {
+        responseSummary = icebergObjectMapper.writeValueAsString(entity);
+      }
+    } catch (JsonProcessingException e) {
+      LOG.warn(
+          "Failed to serialize the response for Idempotency-Key: {}, it will 
not be replayed.",
+          idempotencyKey,
+          e);
+      return false;
+    }
+    idempotencyStore.finalizeRecord(idempotencyKey, claim, 
response.getStatus(), responseSummary);
+    boolean finalized =
+        idempotencyStore
+            .load(idempotencyKey)
+            .filter(record -> record.isFinalized() && record.claim() == claim)
+            .isPresent();
+    if (!finalized) {
+      LOG.warn(
+          "Response for Idempotency-Key: {} was not retained under this 
claim", idempotencyKey);
+    }
+    // Keep the actual mutation response: returning a synthetic 5xx could 
encourage clients to
+    // retry an operation that already committed. Release is fenced to our 
claim in the caller.
+    return finalized;
+  }
+
+  private static Response conflict(String message, boolean retryable) {
+    Response response =
+        Response.status(Response.Status.CONFLICT)
+            .entity(
+                IcebergRESTUtils.errorResponse(
+                    Response.Status.CONFLICT.getStatusCode(),
+                    "IdempotencyConflictException",
+                    message))
+            .type(MediaType.APPLICATION_JSON)
+            .build();
+    if (!retryable) {
+      return response;
+    }
+    return Response.fromResponse(response)
+        .header(HttpHeaders.RETRY_AFTER, RETRY_AFTER_SECONDS)
+        .build();
+  }
+}
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.java
index d115fd175b..befafc71ce 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.java
@@ -43,6 +43,7 @@ import org.apache.gravitino.MetadataObject;
 import org.apache.gravitino.iceberg.service.CatalogWrapperForREST;
 import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;
 import org.apache.gravitino.iceberg.service.IcebergRESTUtils;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.metrics.MetricNames;
 import 
org.apache.gravitino.server.authorization.annotations.AuthorizationExpression;
 import 
org.apache.gravitino.server.authorization.annotations.AuthorizationMetadata;
@@ -60,6 +61,7 @@ public class IcebergConfigOperations {
   private HttpServletRequest httpRequest;
 
   private final IcebergCatalogWrapperManager catalogWrapperManager;
+  private final IcebergIdempotencyManager idempotencyManager;
 
   private static final List<Endpoint> DEFAULT_ENDPOINTS =
       ImmutableList.<Endpoint>builder()
@@ -97,8 +99,11 @@ public class IcebergConfigOperations {
           .build();
 
   @Inject
-  public IcebergConfigOperations(IcebergCatalogWrapperManager 
catalogWrapperManager) {
+  public IcebergConfigOperations(
+      IcebergCatalogWrapperManager catalogWrapperManager,
+      IcebergIdempotencyManager idempotencyManager) {
     this.catalogWrapperManager = catalogWrapperManager;
+    this.idempotencyManager = idempotencyManager;
   }
 
   @GET
@@ -124,6 +129,9 @@ public class IcebergConfigOperations {
     if (StringUtils.isNotBlank(warehouse)) {
       builder.withDefault("prefix", warehouse);
     }
+    // Advertised only when idempotency is enabled: the Iceberg REST spec 
reads the absence of this
+    // field as "the server does not support Idempotency-Key semantics".
+    
idempotencyManager.advertisedKeyLifetime().ifPresent(builder::withIdempotencyKeyLifetime);
     return IcebergRESTUtils.ok(builder.build());
   }
 
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java
index 74968e6c0a..1bd4f2e5ba 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java
@@ -35,6 +35,7 @@ import javax.ws.rs.Encoded;
 import javax.ws.rs.GET;
 import javax.ws.rs.HEAD;
 import javax.ws.rs.HeaderParam;
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -43,6 +44,7 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import org.apache.gravitino.Entity;
 import org.apache.gravitino.MetadataObject;
 import org.apache.gravitino.NameIdentifier;
@@ -51,6 +53,7 @@ import 
org.apache.gravitino.iceberg.service.IcebergObjectMapper;
 import org.apache.gravitino.iceberg.service.IcebergRESTUtils;
 import 
org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.listener.api.event.IcebergRequestContext;
 import org.apache.gravitino.metrics.MetricNames;
 import org.apache.gravitino.server.authorization.MetadataAuthzHelper;
@@ -84,13 +87,16 @@ public class IcebergNamespaceOperations {
 
   private ObjectMapper icebergObjectMapper;
   private IcebergNamespaceOperationDispatcher namespaceOperationDispatcher;
+  private IcebergIdempotencyManager idempotencyManager;
 
   @Context private HttpServletRequest httpRequest;
 
   @Inject
   public IcebergNamespaceOperations(
-      IcebergNamespaceOperationDispatcher namespaceOperationDispatcher) {
+      IcebergNamespaceOperationDispatcher namespaceOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager) {
     this.namespaceOperationDispatcher = namespaceOperationDispatcher;
+    this.idempotencyManager = idempotencyManager;
     this.icebergObjectMapper = IcebergObjectMapper.getInstance();
   }
 
@@ -215,7 +221,16 @@ public class IcebergNamespaceOperations {
   public Response dropNamespace(
       @AuthorizationMetadata(type = Entity.EntityType.CATALOG) 
@PathParam("prefix") String prefix,
       @AuthorizationMetadata(type = Entity.EntityType.SCHEMA) @Encoded() 
@PathParam("namespace")
-          String namespace) {
+          String namespace,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.DELETE, uriInfo),
+        () -> doDropNamespace(prefix, namespace));
+  }
+
+  private Response doDropNamespace(String prefix, String namespace) {
     // todo check if table exists in namespace after table ops is added
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
@@ -246,8 +261,17 @@ public class IcebergNamespaceOperations {
       @AuthorizationMetadata(type = Entity.EntityType.CATALOG) 
@PathParam("prefix") String prefix,
       @IcebergAuthorizationMetadata(
               type = IcebergAuthorizationMetadata.RequestType.CREATE_NAMESPACE)
-          CreateNamespaceRequest createNamespaceRequest) {
+          CreateNamespaceRequest createNamespaceRequest,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(createNamespaceRequest, 
"CreateNamespaceRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doCreateNamespace(prefix, createNamespaceRequest));
+  }
+
+  private Response doCreateNamespace(String prefix, CreateNamespaceRequest 
createNamespaceRequest) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     LOG.info(
         "Create Iceberg namespace, catalog: {}, createNamespaceRequest: {}",
@@ -280,9 +304,21 @@ public class IcebergNamespaceOperations {
       @AuthorizationMetadata(type = Entity.EntityType.CATALOG) 
@PathParam("prefix") String prefix,
       @AuthorizationMetadata(type = Entity.EntityType.SCHEMA) @Encoded() 
@PathParam("namespace")
           String namespace,
-      UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest) {
+      UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(
         updateNamespacePropertiesRequest, "UpdateNamespacePropertiesRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doUpdateNamespace(prefix, namespace, 
updateNamespacePropertiesRequest));
+  }
+
+  private Response doUpdateNamespace(
+      String prefix,
+      String namespace,
+      UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
         RESTUtil.decodeNamespace(namespace, 
IcebergRESTUtils.NAMESPACE_SEPARATOR_URLENCODED_UTF_8);
@@ -324,8 +360,21 @@ public class IcebergNamespaceOperations {
           String namespace,
       @IcebergAuthorizationMetadata(type = 
IcebergAuthorizationMetadata.RequestType.REGISTER_TABLE)
           RegisterTableRequest registerTableRequest,
-      @HeaderParam(IcebergTableOperations.X_ICEBERG_ACCESS_DELEGATION) String 
accessDelegation) {
+      @HeaderParam(IcebergTableOperations.X_ICEBERG_ACCESS_DELEGATION) String 
accessDelegation,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(registerTableRequest, 
"RegisterTableRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doRegisterTable(prefix, namespace, registerTableRequest, 
accessDelegation));
+  }
+
+  private Response doRegisterTable(
+      String prefix,
+      String namespace,
+      RegisterTableRequest registerTableRequest,
+      String accessDelegation) {
     boolean isCredentialVending = 
IcebergTableOperations.isCredentialVending(accessDelegation);
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
@@ -366,8 +415,18 @@ public class IcebergNamespaceOperations {
       @AuthorizationMetadata(type = Entity.EntityType.CATALOG) 
@PathParam("prefix") String prefix,
       @AuthorizationMetadata(type = Entity.EntityType.SCHEMA) @Encoded() 
@PathParam("namespace")
           String namespace,
-      RegisterViewRequest registerViewRequest) {
+      RegisterViewRequest registerViewRequest,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(registerViewRequest, 
"RegisterViewRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doRegisterView(prefix, namespace, registerViewRequest));
+  }
+
+  private Response doRegisterView(
+      String prefix, String namespace, RegisterViewRequest 
registerViewRequest) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
         RESTUtil.decodeNamespace(namespace, 
IcebergRESTUtils.NAMESPACE_SEPARATOR_URLENCODED_UTF_8);
@@ -430,8 +489,6 @@ public class IcebergNamespaceOperations {
 
   private String SerializeUpdateNamespacePropertiesRequest(
       UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest) {
-    IcebergRESTUtils.validateRequest(
-        updateNamespacePropertiesRequest, "UpdateNamespacePropertiesRequest");
     try {
       return 
icebergObjectMapper.writeValueAsString(updateNamespacePropertiesRequest);
     } catch (JsonProcessingException e) {
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
index 797d8a67bd..42239ca17f 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
@@ -42,6 +42,7 @@ import javax.ws.rs.Encoded;
 import javax.ws.rs.GET;
 import javax.ws.rs.HEAD;
 import javax.ws.rs.HeaderParam;
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -51,6 +52,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.gravitino.Entity;
 import org.apache.gravitino.Entity.EntityType;
@@ -62,6 +64,7 @@ import 
org.apache.gravitino.iceberg.service.IcebergObjectMapper;
 import org.apache.gravitino.iceberg.service.IcebergRESTUtils;
 import 
org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.iceberg.service.metrics.IcebergMetricsManager;
 import 
org.apache.gravitino.iceberg.service.restriction.IcebergReadRestrictionLoader;
 import org.apache.gravitino.listener.api.event.IcebergRequestContext;
@@ -109,6 +112,7 @@ public class IcebergTableOperations {
 
   private ObjectMapper icebergObjectMapper;
   private IcebergTableOperationDispatcher tableOperationDispatcher;
+  private IcebergIdempotencyManager idempotencyManager;
   private IcebergReadRestrictionLoader readRestrictionLoader;
 
   @Context private HttpServletRequest httpRequest;
@@ -117,9 +121,11 @@ public class IcebergTableOperations {
   public IcebergTableOperations(
       IcebergMetricsManager icebergMetricsManager,
       IcebergTableOperationDispatcher tableOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager,
       IcebergReadRestrictionLoader readRestrictionLoader) {
     this.icebergMetricsManager = icebergMetricsManager;
     this.tableOperationDispatcher = tableOperationDispatcher;
+    this.idempotencyManager = idempotencyManager;
     this.icebergObjectMapper = IcebergObjectMapper.getInstance();
     this.readRestrictionLoader = readRestrictionLoader;
   }
@@ -180,8 +186,21 @@ public class IcebergTableOperations {
       @AuthorizationMetadata(type = Entity.EntityType.SCHEMA) @Encoded() 
@PathParam("namespace")
           String namespace,
       CreateTableRequest createTableRequest,
-      @HeaderParam(X_ICEBERG_ACCESS_DELEGATION) String accessDelegation) {
+      @HeaderParam(X_ICEBERG_ACCESS_DELEGATION) String accessDelegation,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(createTableRequest, "CreateTableRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doCreateTable(prefix, namespace, createTableRequest, 
accessDelegation));
+  }
+
+  private Response doCreateTable(
+      String prefix,
+      String namespace,
+      CreateTableRequest createTableRequest,
+      String accessDelegation) {
     boolean isCredentialVending = isCredentialVending(accessDelegation);
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
@@ -224,8 +243,18 @@ public class IcebergTableOperations {
       @AuthorizationMetadata(type = Entity.EntityType.TABLE) @Encoded() 
@PathParam("table")
           String table,
       @IcebergAuthorizationMetadata(type = 
IcebergAuthorizationMetadata.RequestType.UPDATE_TABLE)
-          UpdateTableRequest updateTableRequest) {
+          UpdateTableRequest updateTableRequest,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(updateTableRequest, "UpdateTableRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doUpdateTable(prefix, namespace, table, updateTableRequest));
+  }
+
+  private Response doUpdateTable(
+      String prefix, String namespace, String table, UpdateTableRequest 
updateTableRequest) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
         RESTUtil.decodeNamespace(namespace, 
IcebergRESTUtils.NAMESPACE_SEPARATOR_URLENCODED_UTF_8);
@@ -268,7 +297,17 @@ public class IcebergTableOperations {
           String namespace,
       @AuthorizationMetadata(type = Entity.EntityType.TABLE) @Encoded() 
@PathParam("table")
           String table,
-      @DefaultValue("false") @QueryParam("purgeRequested") boolean 
purgeRequested) {
+      @DefaultValue("false") @QueryParam("purgeRequested") boolean 
purgeRequested,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.DELETE, uriInfo),
+        () -> doDropTable(prefix, namespace, table, purgeRequested));
+  }
+
+  private Response doDropTable(
+      String prefix, String namespace, String table, boolean purgeRequested) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
         RESTUtil.decodeNamespace(namespace, 
IcebergRESTUtils.NAMESPACE_SEPARATOR_URLENCODED_UTF_8);
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java
index 830b21daa8..810c5a66a2 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java
@@ -26,6 +26,8 @@ import com.google.common.annotations.VisibleForTesting;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -33,11 +35,13 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import org.apache.gravitino.Entity;
 import org.apache.gravitino.MetadataObject;
 import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;
 import org.apache.gravitino.iceberg.service.IcebergRESTUtils;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.listener.api.event.IcebergRequestContext;
 import org.apache.gravitino.metrics.MetricNames;
 import 
org.apache.gravitino.server.authorization.annotations.AuthorizationExpression;
@@ -58,10 +62,14 @@ public class IcebergTableRenameOperations {
   @Context private HttpServletRequest httpRequest;
 
   private IcebergTableOperationDispatcher tableOperationDispatcher;
+  private IcebergIdempotencyManager idempotencyManager;
 
   @Inject
-  public IcebergTableRenameOperations(IcebergTableOperationDispatcher 
tableOperationDispatcher) {
+  public IcebergTableRenameOperations(
+      IcebergTableOperationDispatcher tableOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager) {
     this.tableOperationDispatcher = tableOperationDispatcher;
+    this.idempotencyManager = idempotencyManager;
   }
 
   @POST
@@ -74,8 +82,17 @@ public class IcebergTableRenameOperations {
   public Response renameTable(
       @AuthorizationMetadata(type = Entity.EntityType.CATALOG) 
@PathParam("prefix") String prefix,
       @IcebergAuthorizationMetadata(type = RequestType.RENAME_TABLE)
-          RenameTableRequest renameTableRequest) {
+          RenameTableRequest renameTableRequest,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(renameTableRequest, "RenameTableRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doRenameTable(prefix, renameTableRequest));
+  }
+
+  private Response doRenameTable(String prefix, RenameTableRequest 
renameTableRequest) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     LOG.info(
         "Rename Iceberg tables, catalog: {}, source: {}, destination: {}.",
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java
index f4900cd658..6b06aa4eb2 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java
@@ -33,6 +33,8 @@ import javax.ws.rs.DELETE;
 import javax.ws.rs.Encoded;
 import javax.ws.rs.GET;
 import javax.ws.rs.HEAD;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -41,6 +43,7 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import org.apache.gravitino.Entity;
 import org.apache.gravitino.Entity.EntityType;
 import org.apache.gravitino.MetadataObject;
@@ -51,6 +54,7 @@ import 
org.apache.gravitino.iceberg.service.IcebergObjectMapper;
 import org.apache.gravitino.iceberg.service.IcebergRESTUtils;
 import 
org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.listener.api.event.IcebergRequestContext;
 import org.apache.gravitino.metrics.MetricNames;
 import org.apache.gravitino.server.authorization.MetadataAuthzHelper;
@@ -80,12 +84,16 @@ public class IcebergViewOperations {
 
   private ObjectMapper icebergObjectMapper;
   private IcebergViewOperationDispatcher viewOperationDispatcher;
+  private IcebergIdempotencyManager idempotencyManager;
 
   @Context private HttpServletRequest httpRequest;
 
   @Inject
-  public IcebergViewOperations(IcebergViewOperationDispatcher 
viewOperationDispatcher) {
+  public IcebergViewOperations(
+      IcebergViewOperationDispatcher viewOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager) {
     this.viewOperationDispatcher = viewOperationDispatcher;
+    this.idempotencyManager = idempotencyManager;
     this.icebergObjectMapper = IcebergObjectMapper.getInstance();
   }
 
@@ -144,8 +152,18 @@ public class IcebergViewOperations {
       @AuthorizationMetadata(type = Entity.EntityType.CATALOG) 
@PathParam("prefix") String prefix,
       @AuthorizationMetadata(type = Entity.EntityType.SCHEMA) @Encoded() 
@PathParam("namespace")
           String namespace,
-      CreateViewRequest createViewRequest) {
+      CreateViewRequest createViewRequest,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(createViewRequest, "CreateViewRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doCreateView(prefix, namespace, createViewRequest));
+  }
+
+  private Response doCreateView(
+      String prefix, String namespace, CreateViewRequest createViewRequest) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
         RESTUtil.decodeNamespace(namespace, 
IcebergRESTUtils.NAMESPACE_SEPARATOR_URLENCODED_UTF_8);
@@ -227,8 +245,18 @@ public class IcebergViewOperations {
       @AuthorizationMetadata(type = EntityType.SCHEMA) @Encoded() 
@PathParam("namespace")
           String namespace,
       @AuthorizationMetadata(type = EntityType.VIEW) @Encoded() 
@PathParam("view") String view,
-      UpdateTableRequest replaceViewRequest) {
+      UpdateTableRequest replaceViewRequest,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(replaceViewRequest, "UpdateTableRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doReplaceView(prefix, namespace, view, replaceViewRequest));
+  }
+
+  private Response doReplaceView(
+      String prefix, String namespace, String view, UpdateTableRequest 
replaceViewRequest) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
         RESTUtil.decodeNamespace(namespace, 
IcebergRESTUtils.NAMESPACE_SEPARATOR_URLENCODED_UTF_8);
@@ -267,7 +295,16 @@ public class IcebergViewOperations {
       @AuthorizationMetadata(type = Entity.EntityType.CATALOG) 
@PathParam("prefix") String prefix,
       @AuthorizationMetadata(type = EntityType.SCHEMA) @Encoded() 
@PathParam("namespace")
           String namespace,
-      @AuthorizationMetadata(type = EntityType.VIEW) @Encoded() 
@PathParam("view") String view) {
+      @AuthorizationMetadata(type = EntityType.VIEW) @Encoded() 
@PathParam("view") String view,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.DELETE, uriInfo),
+        () -> doDropView(prefix, namespace, view));
+  }
+
+  private Response doDropView(String prefix, String namespace, String view) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     Namespace icebergNS =
         RESTUtil.decodeNamespace(namespace, 
IcebergRESTUtils.NAMESPACE_SEPARATOR_URLENCODED_UTF_8);
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.java
index a5b4dc5f12..e64285b588 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.java
@@ -24,6 +24,8 @@ import com.google.common.annotations.VisibleForTesting;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -31,11 +33,13 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import org.apache.gravitino.Entity;
 import org.apache.gravitino.MetadataObject;
 import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;
 import org.apache.gravitino.iceberg.service.IcebergRESTUtils;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.listener.api.event.IcebergRequestContext;
 import org.apache.gravitino.metrics.MetricNames;
 import 
org.apache.gravitino.server.authorization.annotations.AuthorizationExpression;
@@ -57,10 +61,14 @@ public class IcebergViewRenameOperations {
   @Context private HttpServletRequest httpRequest;
 
   private IcebergViewOperationDispatcher viewOperationDispatcher;
+  private IcebergIdempotencyManager idempotencyManager;
 
   @Inject
-  public IcebergViewRenameOperations(IcebergViewOperationDispatcher 
viewOperationDispatcher) {
+  public IcebergViewRenameOperations(
+      IcebergViewOperationDispatcher viewOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager) {
     this.viewOperationDispatcher = viewOperationDispatcher;
+    this.idempotencyManager = idempotencyManager;
   }
 
   @POST
@@ -73,8 +81,17 @@ public class IcebergViewRenameOperations {
   public Response renameView(
       @AuthorizationMetadata(type = Entity.EntityType.CATALOG) 
@PathParam("prefix") String prefix,
       @IcebergAuthorizationMetadata(type = RequestType.RENAME_VIEW)
-          RenameTableRequest renameViewRequest) {
+          RenameTableRequest renameViewRequest,
+      @HeaderParam(IcebergIdempotencyManager.IDEMPOTENCY_KEY) String 
idempotencyKey,
+      @Context UriInfo uriInfo) {
     IcebergRESTUtils.validateRequest(renameViewRequest, "RenameTableRequest");
+    return idempotencyManager.replayOrExecute(
+        idempotencyKey,
+        IcebergIdempotencyManager.operationBinding(HttpMethod.POST, uriInfo),
+        () -> doRenameView(prefix, renameViewRequest));
+  }
+
+  private Response doRenameView(String prefix, RenameTableRequest 
renameViewRequest) {
     String catalogName = IcebergRESTUtils.getCatalogName(prefix);
     LOG.info(
         "Rename Iceberg view, catalog: {}, source: {}, destination: {}.",
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/idempotency/TestIcebergIdempotencyManager.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/idempotency/TestIcebergIdempotencyManager.java
new file mode 100644
index 0000000000..b167057260
--- /dev/null
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/idempotency/TestIcebergIdempotencyManager.java
@@ -0,0 +1,365 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.iceberg.service.idempotency;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
+import org.apache.gravitino.iceberg.common.idempotency.IdempotencyRecord;
+import org.apache.gravitino.iceberg.common.idempotency.IdempotencyStore;
+import 
org.apache.gravitino.iceberg.common.idempotency.IdempotencyStore.ReserveResult;
+import 
org.apache.gravitino.iceberg.common.idempotency.InMemoryIdempotencyStore;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+
+public class TestIcebergIdempotencyManager {
+
+  private static final String KEY = "017f22e2-79b0-7cc3-98c4-dc0c0c07398f";
+  private static final String KEY_UPPER = 
"017F22E2-79B0-7CC3-98C4-DC0C0C07398F";
+  private static final String OTHER_KEY = 
"017f22e2-79b0-7cc3-98c4-dc0c0c073990";
+  private static final String BINDING = "POST v1/cat1/namespaces/ns1/tables";
+
+  @Test
+  void testDisabledManagerRunsEveryRequest() {
+    IcebergIdempotencyManager manager = newDisabledManager();
+    AtomicInteger executions = new AtomicInteger();
+
+    Assertions.assertEquals(200, execute(manager, KEY, 
executions).getStatus());
+    Assertions.assertEquals(200, execute(manager, KEY, 
executions).getStatus());
+
+    Assertions.assertEquals(2, executions.get());
+    Assertions.assertEquals(Optional.empty(), manager.advertisedKeyLifetime());
+  }
+
+  @Test
+  void testEnabledManagerAdvertisesTheConfiguredLifetime() {
+    IcebergIdempotencyManager manager =
+        
newManager(ImmutableMap.of(IcebergConstants.ICEBERG_IDEMPOTENCY_KEY_LIFETIME, 
"PT2H"));
+    Assertions.assertEquals(Optional.of("PT2H"), 
manager.advertisedKeyLifetime());
+  }
+
+  @Test
+  void testRequestWithoutKeyIsNotDeduplicated() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    execute(manager, null, executions);
+    execute(manager, "", executions);
+
+    Assertions.assertEquals(2, executions.get());
+  }
+
+  @Test
+  void testRetryReplaysTheStoredResponse() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    Response first = execute(manager, KEY, executions);
+    Response replayed = execute(manager, KEY, executions);
+
+    Assertions.assertEquals(1, executions.get(), "the mutation must run 
exactly once");
+    Assertions.assertEquals(first.getStatus(), replayed.getStatus());
+    Assertions.assertEquals("{\"payload\":1}", replayed.getEntity());
+    Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE, 
replayed.getMediaType());
+  }
+
+  @Test
+  void testDifferentKeyExecutesAgain() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    execute(manager, KEY, executions);
+    execute(manager, OTHER_KEY, executions);
+
+    Assertions.assertEquals(2, executions.get());
+  }
+
+  @Test
+  void testResponseWithoutBodyIsReplayed() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    manager.replayOrExecute(
+        KEY,
+        BINDING,
+        () -> {
+          executions.incrementAndGet();
+          return Response.noContent().build();
+        });
+    Response replayed =
+        manager.replayOrExecute(
+            KEY,
+            BINDING,
+            () -> {
+              executions.incrementAndGet();
+              return Response.noContent().build();
+            });
+
+    Assertions.assertEquals(1, executions.get());
+    Assertions.assertEquals(204, replayed.getStatus());
+    Assertions.assertNull(replayed.getEntity());
+  }
+
+  @Test
+  void testTerminalClientErrorIsReplayed() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    Response first = respondWith(manager, 409, executions);
+    Response replayed = respondWith(manager, 409, executions);
+
+    Assertions.assertEquals(1, executions.get());
+    Assertions.assertEquals(409, first.getStatus());
+    Assertions.assertEquals(409, replayed.getStatus());
+  }
+
+  @Test
+  void testServerErrorReleasesTheKey() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    Assertions.assertEquals(500, respondWith(manager, 500, 
executions).getStatus());
+    // The spec treats 5xx as retryable, so the same key must be usable again.
+    Assertions.assertEquals(503, respondWith(manager, 503, 
executions).getStatus());
+    Assertions.assertEquals(2, executions.get());
+  }
+
+  @Test
+  void testUnauthorizedResponseReleasesTheKey() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    respondWith(manager, 401, executions);
+    respondWith(manager, 401, executions);
+
+    Assertions.assertEquals(2, executions.get());
+  }
+
+  @Test
+  void testThrownExceptionReleasesTheKey() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    Assertions.assertThrows(
+        IllegalStateException.class,
+        () ->
+            manager.replayOrExecute(
+                KEY,
+                BINDING,
+                () -> {
+                  executions.incrementAndGet();
+                  throw new IllegalStateException("boom");
+                }));
+
+    Assertions.assertEquals(200, execute(manager, KEY, 
executions).getStatus());
+    Assertions.assertEquals(2, executions.get());
+  }
+
+  @Test
+  void testInvalidKeyIsRejectedWithoutExecuting() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    Response response = execute(manager, "not-a-uuid-v7", executions);
+
+    Assertions.assertEquals(400, response.getStatus());
+    Assertions.assertEquals(0, executions.get());
+  }
+
+  @Test
+  void testKeyReusedForAnotherOperationIsRejected() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    execute(manager, KEY, executions);
+    Response response =
+        manager.replayOrExecute(
+            KEY,
+            "DELETE v1/cat1/namespaces/ns1/tables/t1",
+            () -> {
+              executions.incrementAndGet();
+              return Response.ok().build();
+            });
+
+    Assertions.assertEquals(409, response.getStatus());
+    Assertions.assertEquals(1, executions.get(), "the second operation must 
not run");
+    Assertions.assertNull(response.getHeaderString(HttpHeaders.RETRY_AFTER));
+  }
+
+  @Test
+  void testRetryWithADifferentlyCasedKeyReplays() {
+    IcebergIdempotencyManager manager = newManager(ImmutableMap.of());
+    AtomicInteger executions = new AtomicInteger();
+
+    Response first = execute(manager, KEY_UPPER, executions);
+    Response retry = execute(manager, KEY, executions);
+
+    Assertions.assertEquals(200, first.getStatus());
+    Assertions.assertEquals(200, retry.getStatus());
+    Assertions.assertEquals(1, executions.get(), "a case variant is the same 
key, not a new one");
+    Assertions.assertEquals(first.getEntity(), retry.getEntity());
+  }
+
+  @Test
+  void testRetryWhileTheFirstRequestIsRunningIsRetryable() {
+    IdempotencyStore store = Mockito.mock(IdempotencyStore.class);
+    Mockito.when(
+            store.reserve(
+                Mockito.anyString(), Mockito.anyString(), Mockito.anyLong(), 
Mockito.anyLong()))
+        .thenReturn(ReserveResult.DUPLICATE);
+    Mockito.when(store.load(KEY)).thenReturn(Optional.empty());
+    IcebergIdempotencyManager manager =
+        new IcebergIdempotencyManager(enabledConfig(ImmutableMap.of()), 
Optional.of(store));
+    AtomicInteger executions = new AtomicInteger();
+
+    Response response = execute(manager, KEY, executions);
+
+    Assertions.assertEquals(409, response.getStatus());
+    Assertions.assertEquals(0, executions.get());
+    Assertions.assertEquals("1", 
response.getHeaderString(HttpHeaders.RETRY_AFTER));
+  }
+
+  @Test
+  void testOperationBindingIncludesSortedQueryParameters() {
+    MultivaluedMap<String, String> queryParameters = new 
MultivaluedHashMap<>();
+    queryParameters.putSingle("purgeRequested", "true");
+    queryParameters.putSingle("mode", "async");
+    UriInfo uriInfo = Mockito.mock(UriInfo.class);
+    
Mockito.when(uriInfo.getPath(false)).thenReturn("v1/cat1/namespaces/ns1/tables/t1");
+    Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+
+    Assertions.assertEquals(
+        "DELETE 
/v1/cat1/namespaces/ns1/tables/t1?mode=async&purgeRequested=true",
+        IcebergIdempotencyManager.operationBinding("DELETE", uriInfo));
+  }
+
+  @Test
+  void testOperationBindingWithoutUriInfoFallsBackToTheMethod() {
+    Assertions.assertEquals("POST", 
IcebergIdempotencyManager.operationBinding("POST", null));
+  }
+
+  @Test
+  void testNoOpFinalizeReleasesOnlyItsOwnClaim() {
+    IdempotencyStore store = Mockito.mock(IdempotencyStore.class);
+    Mockito.when(
+            store.reserve(
+                Mockito.eq(KEY), Mockito.anyString(), Mockito.anyLong(), 
Mockito.anyLong()))
+        .thenReturn(ReserveResult.RESERVED);
+    IcebergIdempotencyManager manager =
+        new IcebergIdempotencyManager(enabledConfig(ImmutableMap.of()), 
Optional.of(store));
+    Response response = execute(manager, KEY, new AtomicInteger());
+    Assertions.assertEquals(200, response.getStatus());
+    ArgumentCaptor<Long> claim = ArgumentCaptor.forClass(Long.class);
+    Mockito.verify(store)
+        .reserve(Mockito.eq(KEY), Mockito.anyString(), claim.capture(), 
Mockito.anyLong());
+    Mockito.verify(store).release(KEY, claim.getValue());
+  }
+
+  @Test
+  void testFinalizeWithReplacementClaimReleasesOnlyOriginalClaim() {
+    IdempotencyStore store = Mockito.mock(IdempotencyStore.class);
+    Mockito.when(
+            store.reserve(
+                Mockito.eq(KEY), Mockito.anyString(), Mockito.anyLong(), 
Mockito.anyLong()))
+        .thenAnswer(
+            invocation -> {
+              long originalClaim = invocation.getArgument(2);
+              Mockito.when(store.load(KEY))
+                  .thenReturn(
+                      Optional.of(
+                          IdempotencyRecord.reserved(
+                                  KEY, BINDING, originalClaim + 1, 0, 
Long.MAX_VALUE)
+                              .withResponse(200, "replacement")));
+              return ReserveResult.RESERVED;
+            });
+    IcebergIdempotencyManager manager =
+        new IcebergIdempotencyManager(enabledConfig(ImmutableMap.of()), 
Optional.of(store));
+    Assertions.assertEquals(200, execute(manager, KEY, new 
AtomicInteger()).getStatus());
+    ArgumentCaptor<Long> claim = ArgumentCaptor.forClass(Long.class);
+    Mockito.verify(store)
+        .reserve(Mockito.eq(KEY), Mockito.anyString(), claim.capture(), 
Mockito.anyLong());
+    Mockito.verify(store).release(KEY, claim.getValue());
+  }
+
+  @Test
+  void testQueryValuesAreEncodedSortedAndPreserveDuplicates() {
+    UriInfo uri = Mockito.mock(UriInfo.class);
+    
Mockito.when(uri.getPath(false)).thenReturn("v1/namespaces/ns%2Fone/tables");
+    MultivaluedMap<String, String> query = new MultivaluedHashMap<>();
+    query.put("a&b", Arrays.asList("z", "x=y&c", "z"));
+    Mockito.when(uri.getQueryParameters()).thenReturn(query);
+    String binding = IcebergIdempotencyManager.operationBinding("POST", uri);
+    Assertions.assertEquals(
+        "POST /v1/namespaces/ns%2Fone/tables?a%26b=x%3Dy%26c&a%26b=z&a%26b=z", 
binding);
+    query.put("a&b", Arrays.asList("z", "z", "x=y&c"));
+    Assertions.assertEquals(binding, 
IcebergIdempotencyManager.operationBinding("POST", uri));
+  }
+
+  private static Response execute(
+      IcebergIdempotencyManager manager, String idempotencyKey, AtomicInteger 
executions) {
+    return manager.replayOrExecute(
+        idempotencyKey,
+        BINDING,
+        () -> {
+          executions.incrementAndGet();
+          return Response.ok("{\"payload\":1}", 
MediaType.APPLICATION_JSON_TYPE).build();
+        });
+  }
+
+  private static Response respondWith(
+      IcebergIdempotencyManager manager, int status, AtomicInteger executions) 
{
+    return manager.replayOrExecute(
+        KEY,
+        BINDING,
+        () -> {
+          executions.incrementAndGet();
+          return Response.status(status).build();
+        });
+  }
+
+  private static IcebergIdempotencyManager newManager(Map<String, String> 
properties) {
+    IcebergConfig icebergConfig = enabledConfig(properties);
+    InMemoryIdempotencyStore store = new InMemoryIdempotencyStore();
+    store.initialize(icebergConfig.getAllConfig());
+    return new IcebergIdempotencyManager(icebergConfig, Optional.of(store));
+  }
+
+  private static IcebergIdempotencyManager newDisabledManager() {
+    return new IcebergIdempotencyManager(new IcebergConfig(ImmutableMap.of()), 
Optional.empty());
+  }
+
+  private static IcebergConfig enabledConfig(Map<String, String> properties) {
+    Map<String, String> merged = new HashMap<>(properties);
+    merged.put(IcebergConstants.ICEBERG_IDEMPOTENCY_ENABLED, "true");
+    return new IcebergConfig(merged);
+  }
+}
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java
index 8d7015dd0b..7f5a294d1f 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java
@@ -51,6 +51,7 @@ import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewEventDispatche
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationExecutor;
 import org.apache.gravitino.iceberg.service.extension.DummyCredentialProvider;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.iceberg.service.metrics.IcebergMetricsManager;
 import org.apache.gravitino.iceberg.service.provider.IcebergConfigProvider;
 import 
org.apache.gravitino.iceberg.service.provider.IcebergConfigProviderFactory;
@@ -108,14 +109,51 @@ public class IcebergRestTestUtil {
   public static ResourceConfig getIcebergResourceConfig(
       Class c, boolean bindIcebergTableOps, List<EventListenerPlugin> 
eventListenerPlugins) {
     return getIcebergResourceConfig(
-        c, bindIcebergTableOps, eventListenerPlugins, 
IcebergCatalogWrapperManagerForTest::new);
+        c, bindIcebergTableOps, eventListenerPlugins, Collections.emptyMap());
   }
 
+  /**
+   * Builds a test resource config.
+   *
+   * @param c the resource class under test
+   * @param bindIcebergTableOps whether to bind the catalog and dispatcher 
stack
+   * @param eventListenerPlugins event listeners to attach to the event bus
+   * @param serverConf extra Iceberg REST server configuration, for example to 
enable idempotency
+   * @return the configured Jersey resource config
+   */
+  public static ResourceConfig getIcebergResourceConfig(
+      Class c,
+      boolean bindIcebergTableOps,
+      List<EventListenerPlugin> eventListenerPlugins,
+      Map<String, String> serverConf) {
+    return getIcebergResourceConfig(
+        c,
+        bindIcebergTableOps,
+        eventListenerPlugins,
+        serverConf,
+        IcebergCatalogWrapperManagerForTest::new);
+  }
+
+  /** Builds a test resource config with a custom catalog wrapper manager 
factory. */
   public static ResourceConfig getIcebergResourceConfig(
       Class c,
       boolean bindIcebergTableOps,
       List<EventListenerPlugin> eventListenerPlugins,
       WrapperManagerFactory wrapperManagerFactory) {
+    return getIcebergResourceConfig(
+        c,
+        bindIcebergTableOps,
+        eventListenerPlugins,
+        Collections.emptyMap(),
+        wrapperManagerFactory);
+  }
+
+  private static ResourceConfig getIcebergResourceConfig(
+      Class c,
+      boolean bindIcebergTableOps,
+      List<EventListenerPlugin> eventListenerPlugins,
+      Map<String, String> serverConf,
+      WrapperManagerFactory wrapperManagerFactory) {
     ResourceConfig resourceConfig = new ResourceConfig();
     resourceConfig.register(c);
     resourceConfig
@@ -124,6 +162,16 @@ public class IcebergRestTestUtil {
     resourceConfig.register(IcebergExceptionMapper.class);
     resourceConfig.register(IcebergRequestBodyReaderInterceptor.class);
 
+    IcebergIdempotencyManager icebergIdempotencyManager =
+        new IcebergIdempotencyManager(new IcebergConfig(serverConf));
+    resourceConfig.register(
+        new AbstractBinder() {
+          @Override
+          protected void configure() {
+            
bind(icebergIdempotencyManager).to(IcebergIdempotencyManager.class).ranked(2);
+          }
+        });
+
     if (DEBUG_SERVER_LOG_ENABLED) {
       resourceConfig.register(
           new LoggingFeature(
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergNamespaceOperations.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergNamespaceOperations.java
index 7c955c7b55..61b6ceb79a 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergNamespaceOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergNamespaceOperations.java
@@ -22,13 +22,15 @@ package org.apache.gravitino.iceberg.service.rest;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 
 public class MockIcebergNamespaceOperations extends IcebergNamespaceOperations 
{
 
   @Inject
   public MockIcebergNamespaceOperations(
-      IcebergNamespaceOperationDispatcher namespaceOperationDispatcher) {
-    super(namespaceOperationDispatcher);
+      IcebergNamespaceOperationDispatcher namespaceOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager) {
+    super(namespaceOperationDispatcher, idempotencyManager);
   }
 
   // HTTP request is null in Jersey test, create a mock request
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergTableOperations.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergTableOperations.java
index 098081ba8b..17ae6514f6 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergTableOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergTableOperations.java
@@ -22,6 +22,7 @@ package org.apache.gravitino.iceberg.service.rest;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.iceberg.service.metrics.IcebergMetricsManager;
 import 
org.apache.gravitino.iceberg.service.restriction.IcebergReadRestrictionLoader;
 
@@ -31,8 +32,10 @@ public class MockIcebergTableOperations extends 
IcebergTableOperations {
   public MockIcebergTableOperations(
       IcebergMetricsManager icebergMetricsManager,
       IcebergTableOperationDispatcher tableOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager,
       IcebergReadRestrictionLoader readRestrictionLoader) {
-    super(icebergMetricsManager, tableOperationDispatcher, 
readRestrictionLoader);
+    super(
+        icebergMetricsManager, tableOperationDispatcher, idempotencyManager, 
readRestrictionLoader);
   }
 
   // HTTP request is null in Jersey test, create a mock request
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergTableRenameOperations.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergTableRenameOperations.java
index 8a71b8d701..aa9378d7cf 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergTableRenameOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergTableRenameOperations.java
@@ -22,12 +22,14 @@ package org.apache.gravitino.iceberg.service.rest;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 
 public class MockIcebergTableRenameOperations extends 
IcebergTableRenameOperations {
   @Inject
   public MockIcebergTableRenameOperations(
-      IcebergTableOperationDispatcher tableOperationDispatcher) {
-    super(tableOperationDispatcher);
+      IcebergTableOperationDispatcher tableOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager) {
+    super(tableOperationDispatcher, idempotencyManager);
   }
 
   // HTTP request is null in Jersey test, create a mock request
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergViewOperations.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergViewOperations.java
index ed229a0424..cd6e0068a6 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergViewOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergViewOperations.java
@@ -22,12 +22,15 @@ package org.apache.gravitino.iceberg.service.rest;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 
 public class MockIcebergViewOperations extends IcebergViewOperations {
 
   @Inject
-  public MockIcebergViewOperations(IcebergViewOperationDispatcher 
viewOperationDispatcher) {
-    super(viewOperationDispatcher);
+  public MockIcebergViewOperations(
+      IcebergViewOperationDispatcher viewOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager) {
+    super(viewOperationDispatcher, idempotencyManager);
   }
 
   // HTTP request is null in Jersey test, create a mock request
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergViewRenameOperations.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergViewRenameOperations.java
index 694db5e201..6eec531eda 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergViewRenameOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergViewRenameOperations.java
@@ -22,11 +22,14 @@ package org.apache.gravitino.iceberg.service.rest;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 
 public class MockIcebergViewRenameOperations extends 
IcebergViewRenameOperations {
   @Inject
-  public MockIcebergViewRenameOperations(IcebergViewOperationDispatcher 
viewOperationDispatcher) {
-    super(viewOperationDispatcher);
+  public MockIcebergViewRenameOperations(
+      IcebergViewOperationDispatcher viewOperationDispatcher,
+      IcebergIdempotencyManager idempotencyManager) {
+    super(viewOperationDispatcher, idempotencyManager);
   }
 
   // HTTP request is null in Jersey test, create a mock request
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergConfig.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergConfig.java
index 67fa0a3b52..9eae6b3c21 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergConfig.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergConfig.java
@@ -51,6 +51,15 @@ public class TestIcebergConfig extends IcebergTestBase {
     Assertions.assertEquals(0, response.overrides().size());
   }
 
+  @Test
+  public void testConfigOmitsIdempotencyKeyLifetimeWhenDisabled() {
+    // Idempotency is disabled by default, and per the Iceberg REST spec the 
absence of
+    // `idempotency-key-lifetime` tells clients the server does not support 
Idempotency-Key.
+    Response resp = getConfigClientBuilder().get();
+    Assertions.assertEquals(Response.Status.OK.getStatusCode(), 
resp.getStatus());
+    
Assertions.assertNull(resp.readEntity(ConfigResponse.class).idempotencyKeyLifetime());
+  }
+
   @Test
   public void testConfigWithEmptyWarehouse() {
     Map<String, String> queryParams = ImmutableMap.of("warehouse", "");
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyConfig.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyConfig.java
new file mode 100644
index 0000000000..5ef8a6fa48
--- /dev/null
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyConfig.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.iceberg.service.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/** HTTP coverage of a custom idempotency key lifetime. */
+public class TestIcebergIdempotencyConfig extends IcebergTestBase {
+  @Override
+  protected Application configure() {
+    return IcebergRestTestUtil.getIcebergResourceConfig(
+        IcebergConfigOperations.class,
+        true,
+        Collections.emptyList(),
+        ImmutableMap.of(
+            IcebergConstants.ICEBERG_IDEMPOTENCY_ENABLED,
+            "true",
+            IcebergConstants.ICEBERG_IDEMPOTENCY_KEY_LIFETIME,
+            "PT2H"));
+  }
+
+  @Test
+  void testCustomLifetimeIsAdvertisedAtTopLevel() {
+    try (Response response = getConfigClientBuilder().get()) {
+      Assertions.assertEquals(200, response.getStatus());
+      JsonNode config = response.readEntity(JsonNode.class);
+      Assertions.assertEquals("PT2H", 
config.get("idempotency-key-lifetime").asText());
+      
Assertions.assertFalse(config.get("defaults").has("idempotency-key-lifetime"));
+      
Assertions.assertFalse(config.get("overrides").has("idempotency-key-lifetime"));
+    }
+  }
+}
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyFinalizeFailure.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyFinalizeFailure.java
new file mode 100644
index 0000000000..03890a6e35
--- /dev/null
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyFinalizeFailure.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.iceberg.service.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
+import java.util.Optional;
+import javax.annotation.Nullable;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import 
org.apache.gravitino.iceberg.common.idempotency.InMemoryIdempotencyStore;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
+import org.apache.gravitino.server.ServerConfig;
+import org.apache.gravitino.server.authorization.GravitinoAuthorizerProvider;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;
+import org.glassfish.jersey.internal.inject.AbstractBinder;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+/** HTTP coverage of a committed mutation whose response cannot be retained. */
+public class TestIcebergIdempotencyFinalizeFailure extends IcebergTestBase {
+  @Override
+  protected Application configure() {
+    ResourceConfig config =
+        IcebergRestTestUtil.getIcebergResourceConfig(
+            MockIcebergNamespaceOperations.class,
+            true,
+            Collections.emptyList(),
+            ImmutableMap.of(
+                IcebergConstants.ICEBERG_IDEMPOTENCY_ENABLED,
+                "true",
+                IcebergConstants.ICEBERG_IDEMPOTENCY_STORE_TYPE,
+                NoOpFinalizeStore.class.getName()));
+    config.register(
+        new AbstractBinder() {
+          @Override
+          protected void configure() {
+            HttpServletRequest request = 
Mockito.mock(HttpServletRequest.class);
+            Mockito.when(request.getUserPrincipal()).thenReturn(() -> 
"test-user");
+            bind(request).to(HttpServletRequest.class);
+          }
+        });
+    GravitinoAuthorizerProvider.getInstance().initialize(new ServerConfig());
+    return config;
+  }
+
+  @Test
+  void testRetryExecutesAgainAfterSuccessfulMutationCannotFinalize() {
+    Namespace namespace = Namespace.of("finalize_failure");
+    CreateNamespaceRequest request =
+        CreateNamespaceRequest.builder().withNamespace(namespace).build();
+    String key = "017f22e2-79b0-7cc3-98c4-dc0c0c07398f";
+    try (Response first =
+        getNamespaceClientBuilder()
+            .header(IcebergIdempotencyManager.IDEMPOTENCY_KEY, key)
+            .post(Entity.json(request))) {
+      Assertions.assertEquals(200, first.getStatus());
+    }
+    // The catalog committed even though the store did not retain the response.
+    try (Response loaded = 
getNamespaceClientBuilder(Optional.of(namespace)).get()) {
+      Assertions.assertEquals(200, loaded.getStatus());
+    }
+    try (Response retry =
+        getNamespaceClientBuilder()
+            .header(IcebergIdempotencyManager.IDEMPOTENCY_KEY, key)
+            .post(Entity.json(request))) {
+      // Release permits execution again: this is the catalog's AlreadyExists 
response,
+      // not an in-flight idempotency conflict or a replayed 200.
+      Assertions.assertEquals(409, retry.getStatus());
+      Assertions.assertNull(retry.getHeaderString(HttpHeaders.RETRY_AFTER));
+      Assertions.assertEquals(
+          "AlreadyExistsException",
+          retry.readEntity(JsonNode.class).get("error").get("type").asText());
+    }
+  }
+
+  /** Fault-injection store that accepts reservations but never retains final 
responses. */
+  public static class NoOpFinalizeStore extends InMemoryIdempotencyStore {
+    @Override
+    public void finalizeRecord(String key, long claim, int status, @Nullable 
String summary) {
+      // Deliberately leave the record reserved to exercise the manager's 
release path.
+    }
+  }
+}
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyKey.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyKey.java
new file mode 100644
index 0000000000..4b7c005932
--- /dev/null
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergIdempotencyKey.java
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.iceberg.service.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.ImmutableMap;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.apache.gravitino.catalog.lakehouse.iceberg.IcebergConstants;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
+import org.apache.gravitino.listener.api.event.IcebergCreateTableEvent;
+import org.apache.gravitino.server.ServerConfig;
+import org.apache.gravitino.server.authorization.GravitinoAuthorizerProvider;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.rest.requests.CreateTableRequest;
+import org.apache.iceberg.rest.responses.LoadTableResponse;
+import org.apache.iceberg.types.Types.NestedField;
+import org.apache.iceberg.types.Types.StringType;
+import org.glassfish.jersey.internal.inject.AbstractBinder;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+/** End-to-end coverage of the {@code Idempotency-Key} header on mutation 
endpoints. */
+@SuppressWarnings("deprecation")
+public class TestIcebergIdempotencyKey extends IcebergNamespaceTestBase {
+
+  private static final Namespace NAMESPACE = Namespace.of("idempotency_test");
+
+  private static final String KEY = "017f22e2-79b0-7cc3-98c4-dc0c0c07398f";
+  private static final String OTHER_KEY = 
"017f22e2-79b0-7cc3-98c4-dc0c0c073990";
+
+  private static final Schema TABLE_SCHEMA =
+      new Schema(NestedField.of(1, false, "foo_string", StringType.get()));
+
+  private DummyEventListener dummyEventListener;
+
+  @Override
+  protected Application configure() {
+    this.dummyEventListener = new DummyEventListener();
+    ResourceConfig resourceConfig =
+        IcebergRestTestUtil.getIcebergResourceConfig(
+            MockIcebergTableOperations.class,
+            true,
+            Arrays.asList(dummyEventListener),
+            ImmutableMap.of(IcebergConstants.ICEBERG_IDEMPOTENCY_ENABLED, 
"true"));
+    resourceConfig.register(MockIcebergNamespaceOperations.class);
+    resourceConfig.register(IcebergConfigOperations.class);
+
+    // register a mock HttpServletRequest with user info
+    resourceConfig.register(
+        new AbstractBinder() {
+          @Override
+          protected void configure() {
+            HttpServletRequest mockRequest = 
Mockito.mock(HttpServletRequest.class);
+            Mockito.when(mockRequest.getUserPrincipal()).thenReturn(() -> 
"test-user");
+            bind(mockRequest).to(HttpServletRequest.class);
+          }
+        });
+
+    GravitinoAuthorizerProvider.getInstance().initialize(new ServerConfig());
+    return resourceConfig;
+  }
+
+  @Test
+  void testConfigAdvertisesTheKeyLifetime() {
+    Response response = getConfigClientBuilder().get();
+    Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());
+    // The Iceberg REST spec puts the lifetime at the top level of 
CatalogConfig, next to
+    // `defaults` and `overrides`, not inside them.
+    Assertions.assertEquals(
+        "PT30M", 
response.readEntity(JsonNode.class).get("idempotency-key-lifetime").asText());
+  }
+
+  @Test
+  void testRetryWithTheSameKeyReplaysTheOriginalResponse() {
+    Assertions.assertEquals(Status.OK.getStatusCode(), 
doCreateNamespace(NAMESPACE).getStatus());
+
+    Response first = createTable("replayed_table", KEY);
+    Assertions.assertEquals(Status.OK.getStatusCode(), first.getStatus());
+    String firstMetadataLocation = 
first.readEntity(LoadTableResponse.class).metadataLocation();
+    Assertions.assertTrue(dummyEventListener.popPostEvent() instanceof 
IcebergCreateTableEvent);
+    dummyEventListener.clearEvent();
+
+    Response retry = createTable("replayed_table", KEY);
+    Assertions.assertEquals(Status.OK.getStatusCode(), retry.getStatus());
+    Assertions.assertEquals(
+        firstMetadataLocation, 
retry.readEntity(LoadTableResponse.class).metadataLocation());
+    Assertions.assertTrue(
+        dummyEventListener.postEvents.isEmpty(),
+        "a replayed request must not re-run the mutation: " + 
dummyEventListener.postEvents);
+  }
+
+  @Test
+  void testRetryWithANewKeyReExecutesAndConflicts() {
+    Assertions.assertEquals(Status.OK.getStatusCode(), 
doCreateNamespace(NAMESPACE).getStatus());
+
+    Assertions.assertEquals(
+        Status.OK.getStatusCode(), createTable("fresh_key_table", 
KEY).getStatus());
+    // A new key means a new logical operation, so the mutation runs and hits 
the existing table.
+    Assertions.assertEquals(
+        Status.CONFLICT.getStatusCode(), createTable("fresh_key_table", 
OTHER_KEY).getStatus());
+  }
+
+  @Test
+  void testTerminalErrorIsReplayed() {
+    Assertions.assertEquals(Status.OK.getStatusCode(), 
doCreateNamespace(NAMESPACE).getStatus());
+    Assertions.assertEquals(
+        Status.OK.getStatusCode(), createTable("conflict_table", 
OTHER_KEY).getStatus());
+
+    Assertions.assertEquals(
+        Status.CONFLICT.getStatusCode(), createTable("conflict_table", 
KEY).getStatus());
+    // The stored 409 is replayed rather than re-running the create.
+    Assertions.assertEquals(
+        Status.CONFLICT.getStatusCode(), createTable("conflict_table", 
KEY).getStatus());
+  }
+
+  @Test
+  void testInvalidKeyIsRejected() {
+    Assertions.assertEquals(Status.OK.getStatusCode(), 
doCreateNamespace(NAMESPACE).getStatus());
+
+    // A UUIDv4 is well-formed but the spec requires UUIDv7.
+    Response response = createTable("rejected_table", 
"f47ac10b-58cc-4372-a567-0e02b2c3d479");
+    Assertions.assertEquals(Status.BAD_REQUEST.getStatusCode(), 
response.getStatus());
+
+    // The mutation must not have run.
+    Assertions.assertEquals(
+        Status.OK.getStatusCode(), createTable("rejected_table", 
KEY).getStatus());
+  }
+
+  @Test
+  void testKeyReusedForAnotherOperationIsRejected() {
+    Assertions.assertEquals(Status.OK.getStatusCode(), 
doCreateNamespace(NAMESPACE).getStatus());
+    Assertions.assertEquals(
+        Status.OK.getStatusCode(), createTable("reused_table", 
KEY).getStatus());
+
+    Response response =
+        getTableClientBuilder(NAMESPACE, Optional.of("reused_table"))
+            .header(IcebergIdempotencyManager.IDEMPOTENCY_KEY, KEY)
+            .delete();
+
+    Assertions.assertEquals(Status.CONFLICT.getStatusCode(), 
response.getStatus());
+    Assertions.assertNull(response.getHeaderString(HttpHeaders.RETRY_AFTER));
+    JsonNode error = response.readEntity(JsonNode.class).get("error");
+    Assertions.assertEquals("IdempotencyConflictException", 
error.get("type").asText());
+    Assertions.assertEquals(
+        "Idempotency-Key: " + KEY + " was already used for a different 
operation; use a new key",
+        error.get("message").asText());
+    // The table is still there: the drop never ran.
+    Assertions.assertEquals(
+        Status.OK.getStatusCode(),
+        getTableClientBuilder(NAMESPACE, 
Optional.of("reused_table")).get().getStatus());
+  }
+
+  @Test
+  void testRequestWithoutAKeyIsUnaffected() {
+    Assertions.assertEquals(Status.OK.getStatusCode(), 
doCreateNamespace(NAMESPACE).getStatus());
+
+    Assertions.assertEquals(
+        Status.OK.getStatusCode(), createTable("no_key_table", 
null).getStatus());
+    Assertions.assertEquals(
+        Status.CONFLICT.getStatusCode(), createTable("no_key_table", 
null).getStatus());
+  }
+
+  @Test
+  void testDropIsReplayed() {
+    Assertions.assertEquals(Status.OK.getStatusCode(), 
doCreateNamespace(NAMESPACE).getStatus());
+    Assertions.assertEquals(
+        Status.OK.getStatusCode(), createTable("dropped_table", 
OTHER_KEY).getStatus());
+
+    Assertions.assertEquals(Status.NO_CONTENT.getStatusCode(), 
dropTable("dropped_table", KEY));
+    // Without idempotency the retry would be a 404; the stored 204 is 
replayed instead.
+    Assertions.assertEquals(Status.NO_CONTENT.getStatusCode(), 
dropTable("dropped_table", KEY));
+  }
+
+  @Test
+  void testLongQueryBindingsDoNotAlias() {
+    Assertions.assertEquals(200, doCreateNamespace(NAMESPACE).getStatus());
+    String prefix = "x".repeat(600);
+    try (Response first = createTableWithQuery("long_query", 
ImmutableMap.of("tag", prefix + "a"));
+        Response different =
+            createTableWithQuery("long_query", ImmutableMap.of("tag", prefix + 
"b"))) {
+      Assertions.assertEquals(200, first.getStatus());
+      Assertions.assertEquals(409, different.getStatus());
+    }
+  }
+
+  @Test
+  void testQueryDelimitersDoNotAlias() {
+    Assertions.assertEquals(200, doCreateNamespace(NAMESPACE).getStatus());
+    try (Response first = createTableWithQuery("query_delimiter", 
ImmutableMap.of("a", "b&c=d"));
+        Response different =
+            createTableWithQuery("query_delimiter", ImmutableMap.of("a", "b", 
"c", "d"))) {
+      Assertions.assertEquals(200, first.getStatus());
+      Assertions.assertEquals(409, different.getStatus());
+    }
+  }
+
+  @Test
+  void testChangedBodyWithSameKeyDoesNotCreateSecondTable() {
+    Assertions.assertEquals(200, doCreateNamespace(NAMESPACE).getStatus());
+    try (Response first = createTable("original_body", KEY);
+        Response changed = createTable("changed_body", KEY)) {
+      Assertions.assertEquals(200, first.getStatus());
+      Assertions.assertEquals(200, changed.getStatus());
+      Assertions.assertEquals(first.readEntity(String.class), 
changed.readEntity(String.class));
+    }
+    try (Response missing = getTableClientBuilder(NAMESPACE, 
Optional.of("changed_body")).get()) {
+      Assertions.assertEquals(404, missing.getStatus());
+    }
+  }
+
+  @Test
+  void testReplayPreservesWireJsonAndOmitsEtag() {
+    Assertions.assertEquals(200, doCreateNamespace(NAMESPACE).getStatus());
+    try (Response first = createTable("wire_json", KEY);
+        Response retry = createTable("wire_json", KEY)) {
+      Assertions.assertEquals(200, first.getStatus());
+      Assertions.assertEquals(first.getStatus(), retry.getStatus());
+      Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE, 
retry.getMediaType());
+      Assertions.assertNotNull(first.getHeaderString(HttpHeaders.ETAG));
+      Assertions.assertNull(retry.getHeaderString(HttpHeaders.ETAG));
+      Assertions.assertEquals(first.readEntity(String.class), 
retry.readEntity(String.class));
+    }
+  }
+
+  private Response createTableWithQuery(String name, Map<String, String> 
query) {
+    return getIcebergClientBuilder(
+            IcebergRestTestUtil.NAMESPACE_PATH + "/idempotency_test/tables", 
Optional.of(query))
+        .header(IcebergIdempotencyManager.IDEMPOTENCY_KEY, KEY)
+        .post(
+            Entity.json(
+                
CreateTableRequest.builder().withName(name).withSchema(TABLE_SCHEMA).build()));
+  }
+
+  private Response createTable(String name, String idempotencyKey) {
+    CreateTableRequest request =
+        
CreateTableRequest.builder().withName(name).withSchema(TABLE_SCHEMA).build();
+    Invocation.Builder builder = getTableClientBuilder(NAMESPACE, 
Optional.empty());
+    if (idempotencyKey != null) {
+      builder = builder.header(IcebergIdempotencyManager.IDEMPOTENCY_KEY, 
idempotencyKey);
+    }
+    return builder.post(Entity.entity(request, 
MediaType.APPLICATION_JSON_TYPE));
+  }
+
+  private int dropTable(String name, String idempotencyKey) {
+    return getTableClientBuilder(NAMESPACE, Optional.of(name))
+        .header(IcebergIdempotencyManager.IDEMPOTENCY_KEY, idempotencyKey)
+        .delete()
+        .getStatus();
+  }
+}
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergNamespaceAuthorizationPaths.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergNamespaceAuthorizationPaths.java
index d85e499a9c..7a211a68d8 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergNamespaceAuthorizationPaths.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergNamespaceAuthorizationPaths.java
@@ -35,11 +35,13 @@ import java.nio.charset.StandardCharsets;
 import java.time.Duration;
 import javax.inject.Singleton;
 import javax.ws.rs.core.Application;
+import org.apache.gravitino.iceberg.common.IcebergConfig;
 import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;
 import org.apache.gravitino.iceberg.service.IcebergObjectMapper;
 import org.apache.gravitino.iceberg.service.IcebergObjectMapperProvider;
 import 
org.apache.gravitino.iceberg.service.authorization.IcebergRESTServerContext;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.iceberg.service.provider.IcebergConfigProvider;
 import org.apache.gravitino.rest.RESTUtils;
 import 
org.apache.gravitino.server.web.filter.IcebergRESTAuthInterceptionService;
@@ -89,6 +91,8 @@ public class TestIcebergNamespaceAuthorizationPaths extends 
JerseyTest {
               @Override
               protected void configure() {
                 bind(dispatcher).to(IcebergNamespaceOperationDispatcher.class);
+                bind(new IcebergIdempotencyManager(new IcebergConfig()))
+                    .to(IcebergIdempotencyManager.class);
                 bind(IcebergRESTAuthInterceptionService.class)
                     .to(InterceptionService.class)
                     .in(Singleton.class);
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.java
index 7545bdf210..cc13a6166c 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.java
@@ -45,6 +45,7 @@ import 
org.apache.gravitino.exceptions.IllegalNameIdentifierException;
 import org.apache.gravitino.iceberg.service.IcebergRESTUtils;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;
 import org.apache.gravitino.iceberg.service.extension.DummyCredentialProvider;
+import 
org.apache.gravitino.iceberg.service.idempotency.IcebergIdempotencyManager;
 import org.apache.gravitino.iceberg.service.metrics.IcebergMetricsManager;
 import 
org.apache.gravitino.iceberg.service.restriction.IcebergReadRestrictionLoader;
 import org.apache.gravitino.listener.api.event.Event;
@@ -1440,7 +1441,11 @@ public class TestIcebergTableOperations extends 
IcebergNamespaceTestBase {
         .thenThrow(new IllegalNameIdentifierException("Dotted names are 
unsupported"));
 
     IcebergTableOperations operations =
-        new IcebergTableOperations(Mockito.mock(IcebergMetricsManager.class), 
dispatcher, loader);
+        new IcebergTableOperations(
+            Mockito.mock(IcebergMetricsManager.class),
+            dispatcher,
+            Mockito.mock(IcebergIdempotencyManager.class),
+            loader);
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     Mockito.when(request.getRemoteAddr()).thenReturn("127.0.0.1");
     
Mockito.when(request.getHeaderNames()).thenReturn(Collections.emptyEnumeration());
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/authorization/TestIcebergViewAuthorizationExpression.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/authorization/TestIcebergViewAuthorizationExpression.java
index dc843ff3fb..5ac65e0eda 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/authorization/TestIcebergViewAuthorizationExpression.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/authorization/TestIcebergViewAuthorizationExpression.java
@@ -28,6 +28,7 @@ import com.google.common.collect.ImmutableSet;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Parameter;
+import javax.ws.rs.core.UriInfo;
 import ognl.OgnlException;
 import org.apache.gravitino.iceberg.service.rest.IcebergViewOperations;
 import org.apache.gravitino.iceberg.service.rest.IcebergViewRenameOperations;
@@ -46,7 +47,12 @@ public class TestIcebergViewAuthorizationExpression {
   public void testCreateView() throws NoSuchMethodException, OgnlException {
     Method method =
         IcebergViewOperations.class.getMethod(
-            "createView", String.class, String.class, CreateViewRequest.class);
+            "createView",
+            String.class,
+            String.class,
+            CreateViewRequest.class,
+            String.class,
+            UriInfo.class);
     AuthorizationExpression annotation = 
method.getAnnotation(AuthorizationExpression.class);
     String expression = annotation.expression();
     MockAuthorizationExpressionEvaluator mockEvaluator =
@@ -253,7 +259,13 @@ public class TestIcebergViewAuthorizationExpression {
   public void testReplaceView() throws NoSuchMethodException, OgnlException {
     Method method =
         IcebergViewOperations.class.getMethod(
-            "replaceView", String.class, String.class, String.class, 
UpdateTableRequest.class);
+            "replaceView",
+            String.class,
+            String.class,
+            String.class,
+            UpdateTableRequest.class,
+            String.class,
+            UriInfo.class);
     AuthorizationExpression annotation = 
method.getAnnotation(AuthorizationExpression.class);
     String expression = annotation.expression();
     MockAuthorizationExpressionEvaluator mockEvaluator =
@@ -300,7 +312,8 @@ public class TestIcebergViewAuthorizationExpression {
   @Test
   public void testDropView() throws NoSuchMethodException, OgnlException {
     Method method =
-        IcebergViewOperations.class.getMethod("dropView", String.class, 
String.class, String.class);
+        IcebergViewOperations.class.getMethod(
+            "dropView", String.class, String.class, String.class, 
String.class, UriInfo.class);
     AuthorizationExpression annotation = 
method.getAnnotation(AuthorizationExpression.class);
     String expression = annotation.expression();
     MockAuthorizationExpressionEvaluator mockEvaluator =
@@ -388,7 +401,7 @@ public class TestIcebergViewAuthorizationExpression {
   public void testRenameView() throws NoSuchMethodException, OgnlException {
     Method method =
         IcebergViewRenameOperations.class.getMethod(
-            "renameView", String.class, RenameTableRequest.class);
+            "renameView", String.class, RenameTableRequest.class, 
String.class, UriInfo.class);
     AuthorizationExpression annotation = 
method.getAnnotation(AuthorizationExpression.class);
     String expression = annotation.expression();
     MockAuthorizationExpressionEvaluator mockEvaluator =
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestIcebergMetadataAuthorizationMethodInterceptor.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestIcebergMetadataAuthorizationMethodInterceptor.java
index 8ce1a11729..aa81ab963f 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestIcebergMetadataAuthorizationMethodInterceptor.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestIcebergMetadataAuthorizationMethodInterceptor.java
@@ -32,6 +32,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.stream.Stream;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.commons.lang3.reflect.FieldUtils;
 import org.apache.gravitino.Config;
@@ -148,17 +149,34 @@ public class 
TestIcebergMetadataAuthorizationMethodInterceptor {
       throws Throwable {
     resetContext(null, false);
     boolean update = operation.equals("updateNamespace");
-    Method method =
-        update
-            ? IcebergNamespaceOperations.class.getMethod(
-                operation, String.class, String.class, 
UpdateNamespacePropertiesRequest.class)
-            : IcebergNamespaceOperations.class.getMethod(operation, 
String.class, String.class);
-    Object[] args =
-        update
-            ? new Object[] {
-              TEST_CATALOG + "/", namespace, 
Mockito.mock(UpdateNamespacePropertiesRequest.class)
-            }
-            : new Object[] {TEST_CATALOG + "/", namespace};
+    Method method;
+    Object[] args;
+    if (update) {
+      method =
+          IcebergNamespaceOperations.class.getMethod(
+              operation,
+              String.class,
+              String.class,
+              UpdateNamespacePropertiesRequest.class,
+              String.class,
+              UriInfo.class);
+      args =
+          new Object[] {
+            TEST_CATALOG + "/",
+            namespace,
+            Mockito.mock(UpdateNamespacePropertiesRequest.class),
+            null,
+            null
+          };
+    } else if (operation.equals("dropNamespace")) {
+      method =
+          IcebergNamespaceOperations.class.getMethod(
+              operation, String.class, String.class, String.class, 
UriInfo.class);
+      args = new Object[] {TEST_CATALOG + "/", namespace, null, null};
+    } else {
+      method = IcebergNamespaceOperations.class.getMethod(operation, 
String.class, String.class);
+      args = new Object[] {TEST_CATALOG + "/", namespace};
+    }
     MethodInvocation invocation = Mockito.mock(MethodInvocation.class);
     Mockito.when(invocation.getMethod()).thenReturn(method);
     Mockito.when(invocation.getArguments()).thenReturn(args);
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestIcebergRequestBodyAuthzHandlers.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestIcebergRequestBodyAuthzHandlers.java
index 0ef678a3f8..b2fcb27884 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestIcebergRequestBodyAuthzHandlers.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestIcebergRequestBodyAuthzHandlers.java
@@ -27,6 +27,7 @@ import java.lang.reflect.Parameter;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.stream.Stream;
+import javax.ws.rs.core.UriInfo;
 import org.apache.gravitino.Entity.EntityType;
 import org.apache.gravitino.NameIdentifier;
 import org.apache.gravitino.iceberg.service.rest.IcebergNamespaceOperations;
@@ -90,7 +91,11 @@ public class TestIcebergRequestBodyAuthzHandlers {
   void testCreateRejectsDottedLevelsBeforeResolvingParent(Namespace namespace) 
throws Exception {
     Method method =
         IcebergNamespaceOperations.class.getMethod(
-            "createNamespace", String.class, CreateNamespaceRequest.class);
+            "createNamespace",
+            String.class,
+            CreateNamespaceRequest.class,
+            String.class,
+            UriInfo.class);
     CreateNamespaceRequest request =
         CreateNamespaceRequest.builder().withNamespace(namespace).build();
     NameIdentifier catalog = NameIdentifier.of("metalake", "catalog");
@@ -101,7 +106,7 @@ public class TestIcebergRequestBodyAuthzHandlers {
         BadRequestException.class,
         () ->
             new CreateNamespaceAuthzHandler(
-                    method.getParameters(), new Object[] {"catalog/", request})
+                    method.getParameters(), new Object[] {"catalog/", request, 
null, null})
                 .process(identifiers));
     assertEquals(Map.of(EntityType.CATALOG, catalog), identifiers);
   }
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestRegisterTableAuthzHandler.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestRegisterTableAuthzHandler.java
index 2582ac5372..de5750142d 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestRegisterTableAuthzHandler.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestRegisterTableAuthzHandler.java
@@ -34,6 +34,7 @@ import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.gravitino.GravitinoEnv;
 import org.apache.gravitino.MetadataObject;
@@ -308,10 +309,17 @@ class TestRegisterTableAuthzHandler {
       throws Throwable {
     Method method =
         IcebergNamespaceOperations.class.getMethod(
-            "registerTable", String.class, String.class, 
RegisterTableRequest.class, String.class);
+            "registerTable",
+            String.class,
+            String.class,
+            RegisterTableRequest.class,
+            String.class,
+            String.class,
+            UriInfo.class);
     MethodInvocation invocation = mock(MethodInvocation.class);
     when(invocation.getMethod()).thenReturn(method);
-    when(invocation.getArguments()).thenReturn(new Object[] {CATALOG + "/", 
SCHEMA, request, null});
+    when(invocation.getArguments())
+        .thenReturn(new Object[] {CATALOG + "/", SCHEMA, request, null, null, 
null});
     when(invocation.proceed()).thenReturn(PROCEEDED);
     return invocation;
   }
diff --git 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestUpdateTableAuthzHandler.java
 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestUpdateTableAuthzHandler.java
index 22832dc378..22eade42ce 100644
--- 
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestUpdateTableAuthzHandler.java
+++ 
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/server/web/filter/TestUpdateTableAuthzHandler.java
@@ -33,6 +33,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.gravitino.Entity.EntityType;
 import org.apache.gravitino.MetadataObject;
@@ -198,10 +199,17 @@ class TestUpdateTableAuthzHandler {
   private MethodInvocation updateInvocation(UpdateTableRequest request) throws 
Throwable {
     Method method =
         IcebergTableOperations.class.getMethod(
-            "updateTable", String.class, String.class, String.class, 
UpdateTableRequest.class);
+            "updateTable",
+            String.class,
+            String.class,
+            String.class,
+            UpdateTableRequest.class,
+            String.class,
+            UriInfo.class);
     MethodInvocation invocation = mock(MethodInvocation.class);
     when(invocation.getMethod()).thenReturn(method);
-    when(invocation.getArguments()).thenReturn(new Object[] {CATALOG + "/", 
"s1", TABLE, request});
+    when(invocation.getArguments())
+        .thenReturn(new Object[] {CATALOG + "/", "s1", TABLE, request, null, 
null});
     when(invocation.proceed()).thenReturn(PROCEEDED);
     return invocation;
   }

Reply via email to