yuqi1129 opened a new pull request, #14789: URL: https://github.com/apache/gravitino/pull/14789
### What changes were proposed in this pull request? `ModelMetaService.updateModel` now checks the new name inside the transaction, before the `UPDATE`. If another live model holds the name, it fails with `EntityAlreadyExistsException`. The check takes no lock and uses an existing mapper query. No SQL or interface changes. ### Why are the changes needed? On PostgreSQL, the rename `UPDATE` waits on the unique index entry of the row that holds the new name. Two renames that swap names wait for each other, and one fails with a deadlock and HTTP 500. Fixes #14752 ### Does this PR introduce _any_ user-facing change? Renaming a model onto a taken name now returns 409 instead of an occasional 500. Known limits: - Only the model rename path changes. Model is the one type with no tree lock on this path. Other types were not checked. - A name that appears after the check is still caught by the unique key, as before. ### How was this patch tested? - Added `testRenameOntoNameHeldByOpenWriteFailsWithoutWaiting`. It holds the target row in an open transaction, and fails on PostgreSQL without the fix. - `TestModelMetaService` passes on H2, MySQL and PostgreSQL. - Real server on PostgreSQL with two clients swapping names. Before: 2 of 400 requests returned 500. After: all 800 returned 409, with no deadlock in the log. -- 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]
