123123213weqw opened a new pull request, #7093: URL: https://github.com/apache/rocketmq-dashboard/pull/7093
Makes `ResourceOwnershipGuardTest.migrationConcurrentStartupIsIdempotentTest` deterministic. The test intermittently fails under full-suite load with `JdbcSQLNonTransientException [50000-240]` wrapping a `ConcurrentModificationException`, and passed every standalone run — which is why it survived so long. ## Root cause (H2 2.4.240 internals, line-level) Each H2 `MVTable` keeps its index list in a plain unsynchronized `ArrayList` (`MVTable.indexes`), mutated in place by DDL while `DatabaseMetaLocal.getIndexInfo` and query planning (`Table.getBestPlanItem`) iterate it. The test's two concurrent `ResourceOwnershipSchemaMigration` threads race those iterations; H2 wraps the resulting CME into the observed General error. Upstream #6736 already retried only the `getIndexInfo` read — the four pre-check SELECTs, `CREATE TABLE`, `CREATE INDEX` and `DROP INDEX` in `afterPropertiesSet` were all unguarded. Stress testing also surfaced a second escape path: `CREATE INDEX`'s existence check reads the concurrent `Schema.indexes` map while `getIndexInfo` serves the stale ArrayList, so the losing thread could see "Index already exists" (42111) while its metadata re-read still missed the winner's index. ## The fix (production, not a test band-aid) `ResourceOwnershipSchemaMigration.afterPropertiesSet` wraps the whole idempotent sequence in the existing bounded (5x), CME-cause-only retry — on a fresh connection per attempt, since a General error can poison the H2 session. `ensureIndex` retries its bounded read-and-DDL pair instead of deciding from one read (a definition mismatch still throws immediately, so duplicate-data failures are never swallowed), and `dropLegacyIndex` gets the same bounded retry. Deliberately not a lock: that would make the regression test tautological (per #6736's rationale), and MySQL never takes these paths. ## Verification 39 consecutive stress runs of the target test (sequential, 3-concurrent-Maven-process rounds, and tight single-method loops) — zero failures, zero `ConcurrentModification` in any log; checkstyle green. The first fix iteration failed 1 of 10 runs with the 42111 escape, which is what drove the `ensureIndex`/`dropLegacyIndex` retries. -- 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]
