tju-yxq opened a new pull request, #6175:
URL: https://github.com/apache/rocketmq-dashboard/pull/6175
### Which Issue(s) This PR Fixes
- Fixes #6174
### Brief Description
Serializes `ResourceOwnershipSchemaMigration` inside one process with a
process-wide mutex — the same in-process discipline Flyway applies to its
migrations.
The migration body is unchanged; only its execution is wrapped:
- **Why this is safe for production**: two real studio nodes never overlap
inside one process — they are serialized across processes by MySQL's metadata
locks, and the existing `CREATE ... IF NOT EXISTS` plus the catch-and-recheck
in `ensureIndex` already tolerate a *completed* concurrent DDL. The mutex only
adds ordering that the in-memory H2 engine cannot provide itself.
- **What it fixes**: overlapping executions in a single process — the
concurrent-startup regression test, or two Spring contexts sharing one test
database — previously interleaved one execution's validation query planning
with the other's index DDL. H2 has no metadata locking, so its planner iterated
an index list the sibling thread was mutating and failed with an internal
`ConcurrentModificationException` (see the root-cause analysis and stack in
#6174).
### How Did You Test This Change?
The regression test that used to flake, run repeatedly before and after the
change (single method, consecutive runs on the same machine):
```
# BEFORE (trunk @ 5e4c39b0): 7 of 10 runs fail
for i in 1..10: cd server && mvn test
-Dtest='ResourceOwnershipGuardTest#migrationConcurrentStartupIsIdempotentTest'
1: Tests run: 1, Failures: 0, Errors: 1 # ConcurrentModificationException
@ migration line 50
2: Errors: 1 3: Errors: 1 4: Errors: 1 5: Errors: 0
6: Errors: 1 7: Errors: 1 8: Errors: 1 9: Errors: 0 10: Errors: 0
# AFTER (this branch): 20 of 20 runs pass
1..20: Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 (20 consecutive
green runs)
```
The full suite of the class is green, and the style gate stays green:
```
cd server && mvn test -Dtest=ResourceOwnershipGuardTest
Tests run: 33, Failures: 0, Errors: 0, Skipped: 0
cd server && mvn checkstyle:check
(no output — exit 0)
```
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in (one
concern — overlapping in-process migration executions must not race the engine
— one class, body moved unchanged into a synchronized wrapper)
- [x] Commit subject follows Conventional Commits
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test` (the existing concurrent-startup regression test is the coverage; it
goes from ~70% flaky to deterministically green)
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(no UI text — server-only change)
- [x] Architecture constraints stay green (no ArchUnit-relevant changes)
- [x] New source files carry the ASF license header (no new source files)
- [ ] Documentation touched where behaviour changed (no observable behaviour
change; ordering only)
--
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]