lasdf1234 commented on PR #14972:
URL: https://github.com/apache/gravitino/pull/14972#issuecomment-6910074565

   ## Bugbot-style review
   
   **Verdict:** No blocking correctness bug in reserve / reclaim / finalize / 
purge. Approve with minor follow-ups — main risks are distributed clock 
semantics and a few JDBC test gaps vs the in-memory suite.
   
   ### Issues & risks
   
   | Severity | Area | Finding |
   |---|---|---|
   | Medium | Clock skew | Expiry / reclaim / purge / load / finalize all use 
each JVM’s `Clock.systemUTC()`. A fast-clock replica can purge or reclaim rows 
a slow-clock replica still treats as live → inconsistent replay vs 
re-execution. Documented in `docs/iceberg-rest-service.md`; worth calling out 
in runbooks because it is safety-critical for idempotency. |
   | Medium | Stale finalize/release + test gap | `finalizeRecord` / `release` 
commit without checking affected row count (SPI design). Claim guards look 
correct in SQL, but JDBC suite is missing parity with in-memory: 
`testStaleFinalizeAfterReReservationIsIgnored`, 
`testStaleReleaseAfterReReservationIsIgnored`, and different 
`operation_binding` still returns `DUPLICATE` without replacing the original. |
   | Low | Purge scheduler | Each `initialize()` starts its own single-thread 
scheduled executor. Multiple store instances → redundant purges / extra lock 
churn. Prefer singleton usage or a process-wide scheduler. |
   | Low | Purge throughput | `MAX_PURGE_BATCHES * PURGE_BATCH_SIZE` ≈ 100k 
rows per `purgeExpired` call. Backlog only delays cleanup; reserve/load still 
enforce expiry in SQL. |
   | Low | Partial `initialize()` | If schema probe fails after 
`sessionFactory` is assigned, the instance cannot re-`initialize()`. Factory 
discard-on-failure is fine for production; awkward for tests/hot reload. |
   | Low | Schema CI | Table + `idx_iik_expires` are in 2.0.0 schemas and 
1.3→2.0 upgrades; `TestSQLScripts` does not assert the new table yet. |
   
   ### What’s solid
   
   - Separate transactions for INSERT vs `replaceExpired` (avoids MySQL 
duplicate-key lock escalation; handles purge-between-attempt races).
   - Claim-guarded finalize/release; PG purge with outer expiry recheck after 
subquery.
   - Strong concurrency coverage (multi-thread reserve, interceptor pause 
during `replaceExpired`, cross-session lock wait on H2/MySQL/PG).
   
   ### Recommended follow-ups (non-blocking)
   
   1. Port the three in-memory parity tests above into 
`TestJdbcIdempotencyStore`.
   2. Optionally assert / debug-log when `finalizeRecord` / `release` affect 0 
rows (helps HTTP-layer integration).
   3. Shared purge scheduler or “initialize once” guard if multiple store 
lifecycles are possible.
   4. Optionally assert `iceberg_idempotency_key_meta` in `TestSQLScripts`.
   5. Align `design-docs/iceberg-idempotency-key.md` §4 with the implementation 
(`claim`, TEXT binding, INSERT + `replaceExpired` vs `ON CONFLICT`).
   
   **No must-fix code changes** before merge; adding the JDBC parity tests 
would materially reduce regression risk ahead of the HTTP integration 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