lymerin opened a new pull request, #7610:
URL: https://github.com/apache/shenyu/pull/7610

   Fixes #7584
   
   ### Problem
   
   - `data_permission` treats `(user_id, data_id, data_type)` as the logical 
unique key, but the database only enforces uniqueness on `id`.
   - Existing grant paths use read-then-write checks before inserting. 
Concurrent requests or retries can both observe a missing grant and insert the 
same permission because there is no database-level constraint.
   
   ### Impact
   
   - Duplicate permission rows can exist for the same user, data, and data type.
   - Operations such as `deleteByUniqueKey` may affect multiple rows even 
though the application treats the key as unique.
   - Correctness depends on request timing instead of being guaranteed by the 
database.
   
   ### Changes
   
   - Make `idx_data_permission_user_type` unique for fresh MySQL, PostgreSQL, 
Oracle, and H2 schemas; OceanBase and openGauss use the corresponding 
MySQL/PostgreSQL schema paths.
   - Update all `2.7.1 -> 2.7.2` database migrations to remove existing 
duplicate grants before creating the unique index, retaining the row with the 
smallest existing `id`.
   - Keep the existing application-side deduplication as the normal-path 
optimization while using the database constraint as the final correctness 
guarantee.
   - Extend mapper/index and native SQL matrix coverage to verify duplicate 
rejection, distinct grant preservation, concurrent inserts, migration cleanup, 
and unique-index metadata across supported dialects.
   - Document the upgrade requirement to stop Admin instances and run the 
migration once.
   
   ### Validation
   
   - `./mvnw clean install -Dmaven.javadoc.skip=true` passed with no failures.
   
   ### Checklist
   
   Make sure that:
   
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.


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