yuqi1129 opened a new issue, #14791:
URL: https://github.com/apache/gravitino/issues/14791

   ### Version
   main branch, commit f475443da6 (2.0.0-SNAPSHOT)
   
   ### Describe what's wrong
   `table_meta` has a unique key on `(schema_id, table_name, deleted_at)`, and 
`deleted_at` is a time in milliseconds. If two tables with the same name in one 
schema are soft-deleted in the same millisecond, the second `UPDATE` breaks the 
key. The drop returns HTTP 500 instead of succeeding or reporting a conflict.
   
   Priority is low. It needs very fast create and drop of one name. In one 
local run, 1 of 2400 drops failed. A later run of the same size had no failures.
   
   ### Error message and/or stacktrace
   ```
   java.lang.RuntimeException: 
org.apache.ibatis.exceptions.PersistenceException:
   ### Error updating database. Cause: 
org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Unique index or 
primary key violation: "PUBLIC.UK_SID_TN_DEL_INDEX_C ON PUBLIC.TABLE_META(...)"
   UPDATE table_meta SET deleted_at = ... WHERE table_id = ? AND 
current_version = ? AND deleted_at = 0
     at 
org.apache.gravitino.catalog.TableOperationDispatcher.lambda$dropTable$18(TableOperationDispatcher.java:513)
   ```
   
   ### How to reproduce
   Use the concurrent create and drop script from #14420, with many rounds on 
one table name. The failure is rare.
   
   ### Additional context
   - Seen on H2 only. MySQL and PostgreSQL have the same key but were not 
tested.
   - #14753 is the same kind of problem on `owner_meta`. Its fix covers only 
the PostgreSQL owner path, so it does not fix this.
   - Many other tables also have `deleted_at` in a unique key. They were not 
checked.
   


-- 
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