[fix](insert) Pick Insert init plan error may forget to abort txn (#34220) (#38260)

Pick https://github.com/apache/doris/pull/34220
This commit is contained in:
meiyi
2024-07-23 20:21:38 +08:00
committed by GitHub
parent a04583c9a1
commit b591837e13

View File

@ -137,7 +137,7 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync,
targetTableIf.getDatabase().getFullName() + "." + targetTableIf.getName());
}
AbstractInsertExecutor insertExecutor;
AbstractInsertExecutor insertExecutor = null;
// should lock target table until we begin transaction.
targetTableIf.readLock();
try {
@ -199,8 +199,14 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync,
insertExecutor.beginTransaction();
insertExecutor.finalizeSink(planner.getFragments().get(0), sink, physicalSink);
} finally {
targetTableIf.readUnlock();
} catch (Throwable e) {
targetTableIf.readUnlock();
// the abortTxn in onFail need to acquire table write lock
if (insertExecutor != null) {
insertExecutor.onFail(e);
}
throw e;
}
executor.setProfileType(ProfileType.LOAD);