kinghao007 opened a new issue, #5320: URL: https://github.com/apache/linkis/issues/5320
### Search before asking - [x] I searched the [issues](https://github.com/apache/linkis/issues) and found no similar issues. ### Linkis Component linkis-engineplugin-jdbc ### What happened 通过JDBC EngineConn执行StarRocks任务时,当任务包含多条SQL语句(如 DROP TABLE 和 CREATE TABLE AS SELECT),在任务执行过长时间后用户取消任务会出现不一致的错误状态。 **问题场景:** ```sql DROP TABLE IF EXISTS old_table; CREATE TABLE new_table AS SELECT * FROM source_table WHERE condition; ``` 当用户取消正在执行的任务时: 1. 系统提示错误:表文件已经存在(Table already exists) 2. 但查询该表时又报错:表不存在(Table not found) 这表明任务取消时的事务处理存在问题,导致表的元数据和实际数据不一致。 ### What you expected to happen 任务取消时应该: 1. 正确回滚已执行的语句或保证事务完整性 2. 不出现"表已存在"和"表不存在"的矛盾状态 3. 给用户明确的任务取消状态反馈 4. 清理中间状态,避免数据不一致 ### How to reproduce 1. 配置JDBC引擎连接StarRocks数据库 2. 提交包含多条语句的SQL任务: ```sql DROP TABLE IF EXISTS test_table; CREATE TABLE test_table AS SELECT * FROM large_table WHERE id > 1000000; ``` 3. 等待CREATE TABLE语句开始执行(确保有大量数据需要处理) 4. 在任务执行过程中点击取消 5. 观察错误信息和表状态 **预期结果:** - 查询 test_table:Table not found(表不存在) **实际结果:** - 取消时报错:Table already exists - 查询时报错:Table not found ### Anything else **可能的原因:** 1. JDBC引擎执行多语句时没有使用事务或事务隔离级别不当 2. 任务取消时Statement.cancel()调用时机不正确 3. CREATE TABLE AS SELECT是DDL+DML混合操作,取消时处理不当 4. StarRocks的表元数据和数据文件清理不同步 **建议的解决方案:** 1. 检查JDBC引擎的任务取消逻辑,确保正确调用Statement.cancel() 2. 对于DDL操作,考虑添加清理逻辑 3. 为多语句任务添加事务支持(如果数据库支持) 4. 增加任务取消后的状态检查和清理机制 5. 针对CREATE TABLE AS SELECT类型的语句,在取消时尝试DROP TABLE清理 ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Linkis Version 1.8.0 ### Java Version OpenJDK 1.8.0 ### Additional Information 相关技术要点: - JDBC Statement.cancel() 方法 - 数据库事务和隔离级别 - DDL语句的原子性 - StarRocks的表创建和删除机制 影响范围: - 不仅影响StarRocks,可能对其他JDBC数据源(如ClickHouse、Doris等)也存在类似问题 - 建议在修复时考虑通用性 -- 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]
