Merge pull request #3588 from actiontech/1983/3.22.07

[inner-1983] fix: in rwSplit, load data failure (cherry pick)
This commit is contained in:
wenyh
2023-01-11 11:07:14 +08:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -51,7 +51,8 @@ public class LoadDataProtoHandlerImpl implements ProtoHandler {
return mySQLProtoHandler;
}
private boolean isEndOfDataFile(byte[] data) {
public static boolean isEndOfDataFile(byte[] data) {
// Load Data's empty package
return (data.length == 4 && data[0] == 0 && data[1] == 0 && data[2] == 0);
}
}

View File

@@ -26,6 +26,7 @@ import com.actiontech.dble.server.variables.MysqlVariable;
import com.actiontech.dble.server.variables.VariableType;
import com.actiontech.dble.services.BusinessService;
import com.actiontech.dble.services.mysqlauthenticate.MySQLChangeUserService;
import com.actiontech.dble.services.mysqlsharding.LoadDataProtoHandlerImpl;
import com.actiontech.dble.services.rwsplit.handle.PreparedStatementHolder;
import com.actiontech.dble.singleton.TraceManager;
import com.actiontech.dble.singleton.TsQueriesCounter;
@@ -115,7 +116,12 @@ public class RWSplitService extends BusinessService<SingleDbGroupUserConfig> {
protected boolean beforeHandlingTask(@NotNull ServiceTask task) {
TraceManager.sessionStart(this, "rwSplit-server-start");
if (task.getType() == ServiceTaskType.NORMAL) {
final int packetType = ((NormalServiceTask) task).getPacketType();
NormalServiceTask task0 = ((NormalServiceTask) task);
// Filter Load Data's empty package
if (this.isInLoadData() && LoadDataProtoHandlerImpl.isEndOfDataFile(task0.getOrgData()))
return true;
final int packetType = task0.getPacketType();
if (packetType == MySQLPacket.COM_STMT_PREPARE || packetType == MySQLPacket.COM_STMT_EXECUTE || packetType == MySQLPacket.COM_QUERY) {
StatisticListener.getInstance().record(session, r -> r.onFrontendSqlStart());
}