924060929 opened a new pull request, #68881: URL: https://github.com/apache/doris/pull/68881
### What problem does this PR solve? Issue Number: N/A Related PR: #68849 (backport), #35210, #53486 (introducing changes) Problem Summary: Backport #68849 to branch-4.1. Two concurrent `CREATE TABLE IF NOT EXISTS ... AS SELECT` statements can both observe an absent table. Only one registers its table, but the losing creator does not propagate the atomic registration result to CTAS. Both statements then insert into the winning table, producing duplicate rows. Propagate the existing-table result under the database write lock so the losing CTAS skips INSERT. After releasing that lock, recycle the losing cloud indexes through the existing FE `dropMaterializedIndex` API; report cleanup errors rather than returning success. Preserve the winning table and existing FE cleanup. Resolve the backport conflicts using branch-4.1's `getIndexIdList()` API and retain only the tests relevant to this fix. This changes four FE files only; no MetaService, recycler, or protobuf changes are included. ### Release note Fix duplicate rows when concurrent CREATE TABLE IF NOT EXISTS AS SELECT statements target the same internal table, and recycle cloud indexes allocated by the losing creator. ### Check List (For Author) - Test: Unit Test; FE Checkstyle; git diff --check. - Behavior changed: Yes. The losing CTAS skips INSERT; cloud cleanup failure is reported. - Does this need documentation: No. Validation on branch-4.1 (JDK 17): - `bash run-fe-ut.sh --run org.apache.doris.catalog.CreateTableTest,org.apache.doris.nereids.trees.plans.commands.CreateTableCommandTest,org.apache.doris.cloud.datasource.CloudInternalCatalogTest`: 23 tests passed, 0 failures/errors/skips (18 + 3 + 2). - `cd fe && mvn checkstyle:check -pl fe-core -Dmaven.build.cache.enabled=false`: BUILD SUCCESS. - `git diff --check`: passed. The cloud RPC boundary is mocked. No live MetaService deployment was tested for this backport. Earlier deployed CTAS validation is documented in #68849. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
