huaxingao commented on code in PR #4269:
URL: https://github.com/apache/polaris/pull/4269#discussion_r3214269492


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/IdempotencyPersistence.java:
##########
@@ -84,30 +103,38 @@ enum HeartbeatResult {
   record ReserveResult(ReserveResultType type, Optional<IdempotencyRecord> 
existing) {}
 
   /**
-   * Attempts to reserve an idempotency key for a given operation and resource.
+   * Attempts to reserve an idempotency key for a given operation, resource, 
and caller.
    *
    * <p>If no record exists yet, the implementation should create a new 
reservation owned by {@code
    * executorId}. If a record already exists, the implementation should return 
{@link
-   * ReserveResultType#DUPLICATE} along with the existing record.
+   * ReserveResultType#DUPLICATE} along with the existing record. The caller 
is responsible for
+   * comparing the existing record's {@code principalHash} and {@code 
normalizedResourceId} against
+   * the current request and rejecting mismatches as conflicts.
    *
    * @param realmId logical tenant or realm identifier
    * @param idempotencyKey application-provided idempotency key
-   * @param operationType logical operation name (e.g., {@code "commit-table"})
+   * @param operationType logical operation name (e.g., {@code "create-table"})
    * @param normalizedResourceId normalized identifier of the affected resource
+   * @param principalHash hash of the caller principal identity (e.g., {@code 
SHA256(name + ":" +
+   *     realmId)}); persisted so replay can verify the same caller
    * @param expiresAt timestamp after which the reservation is considered 
expired
    * @param executorId identifier of the caller attempting the reservation
    * @param now timestamp representing the current time
    * @return {@link ReserveResult} describing whether the caller owns the 
reservation or hit a
    *     duplicate
    */
-  ReserveResult reserve(
+  default ReserveResult reserve(
       String realmId,
       String idempotencyKey,
       String operationType,
       String normalizedResourceId,
+      String principalHash,
       Instant expiresAt,
       String executorId,
-      Instant now);
+      Instant now) {
+    throw new UnsupportedOperationException(

Review Comment:
   I'll open a separate refactor PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to