[fix](planner) Empty table source should not begin a transaction to avoid infinite transaction (#38991) (#39108)

## Proposed changes

Issue Number: close #38956 

As title.
This commit is contained in:
Siyang Tang
2024-08-08 19:35:01 +08:00
committed by GitHub
parent efdd75f286
commit 21b6b863ae
2 changed files with 41 additions and 3 deletions

View File

@ -196,9 +196,10 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync,
// TODO: support other table types
throw new AnalysisException("insert into command only support [olap, hive, iceberg] table");
}
insertExecutor.beginTransaction();
insertExecutor.finalizeSink(planner.getFragments().get(0), sink, physicalSink);
if (!insertExecutor.isEmptyInsert()) {
insertExecutor.beginTransaction();
insertExecutor.finalizeSink(planner.getFragments().get(0), sink, physicalSink);
}
targetTableIf.readUnlock();
} catch (Throwable e) {
targetTableIf.readUnlock();