[improve](group commit) Fix select tablet policy for random partition and remove some log (#28498)

This pr contains 2 improvements:

For random partition table, select tablet in the original way for load balance;
Skip execute stmt audit log since it's expensive in CPU;
This commit is contained in:
meiyi
2023-12-16 11:02:52 +08:00
committed by GitHub
parent f12a225844
commit 3ea68d576b
2 changed files with 22 additions and 6 deletions

View File

@ -350,8 +350,13 @@ public class OlapTableSink extends DataSink {
}
tPartition.setIsMutable(table.getPartitionInfo().getIsMutable(partitionId));
if (partition.getDistributionInfo().getType() == DistributionInfoType.RANDOM) {
int tabletIndex = Env.getCurrentEnv().getTabletLoadIndexRecorderMgr()
.getCurrentTabletLoadIndex(dbId, table.getId(), partition);
int tabletIndex;
if (tDataSink != null && tDataSink.type == TDataSinkType.GROUP_COMMIT_BLOCK_SINK) {
tabletIndex = 0;
} else {
tabletIndex = Env.getCurrentEnv().getTabletLoadIndexRecorderMgr()
.getCurrentTabletLoadIndex(dbId, table.getId(), partition);
}
tPartition.setLoadTabletIdx(tabletIndex);
}
@ -419,8 +424,13 @@ public class OlapTableSink extends DataSink {
}
if (partition.getDistributionInfo().getType() == DistributionInfoType.RANDOM) {
int tabletIndex = Env.getCurrentEnv().getTabletLoadIndexRecorderMgr()
.getCurrentTabletLoadIndex(dbId, table.getId(), partition);
int tabletIndex;
if (tDataSink != null && tDataSink.type == TDataSinkType.GROUP_COMMIT_BLOCK_SINK) {
tabletIndex = 0;
} else {
tabletIndex = Env.getCurrentEnv().getTabletLoadIndexRecorderMgr()
.getCurrentTabletLoadIndex(dbId, table.getId(), partition);
}
tPartition.setLoadTabletIdx(tabletIndex);
}
partitionParam.addToPartitions(tPartition);

View File

@ -18,6 +18,7 @@
package org.apache.doris.qe;
import org.apache.doris.analysis.ExecuteStmt;
import org.apache.doris.analysis.InsertStmt;
import org.apache.doris.analysis.LiteralExpr;
import org.apache.doris.analysis.NullLiteral;
import org.apache.doris.analysis.QueryStmt;
@ -136,7 +137,10 @@ public class MysqlConnectProcessor extends ConnectProcessor {
executor = new StmtExecutor(ctx, executeStmt);
ctx.setExecutor(executor);
executor.execute();
stmtStr = executeStmt.toSql();
PrepareStmtContext preparedStmtContext = ConnectContext.get().getPreparedStmt(String.valueOf(stmtId));
if (preparedStmtContext != null && !(preparedStmtContext.stmt.getInnerStmt() instanceof InsertStmt)) {
stmtStr = executeStmt.toSql();
}
} catch (Throwable e) {
// Catch all throwable.
// If reach here, maybe palo bug.
@ -144,7 +148,9 @@ public class MysqlConnectProcessor extends ConnectProcessor {
ctx.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR,
e.getClass().getSimpleName() + ", msg: " + e.getMessage());
}
auditAfterExec(stmtStr, prepareCtx.stmt.getInnerStmt(), null, false);
if (!stmtStr.isEmpty()) {
auditAfterExec(stmtStr, prepareCtx.stmt.getInnerStmt(), null, false);
}
}
// Process COM_QUERY statement,