Skip to content

Commit

Permalink
Merge pull request #2392 from WhaleCloud-platform/#2390
Browse files Browse the repository at this point in the history
#2390 load data local过程中出现错误,应用直接报Lost connection to MySQL server dur…
  • Loading branch information
junwen12221 authored Jan 2, 2020
2 parents 97c7a15 + 7fac07e commit f929f96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ protected void reset(int initCount) {
this.execCount = 0;
this.netInBytes = 0;
this.netOutBytes = 0;

if (rrs.isLoadData()) {
packetId = session.getSource().getLoadDataInfileHandler().getLastPackId();
}
}

public NonBlockingSession getSession() {
Expand Down Expand Up @@ -345,15 +349,11 @@ public void okResponse(byte[] data, BackendConnection conn) {

lock.lock();
try {
ok.packetId = ++packetId;// OK_PACKET
if (rrs.isLoadData()) {
byte lastPackId = source.getLoadDataInfileHandler()
.getLastPackId();
ok.packetId = ++lastPackId;// OK_PACKET
ok.message = ("Records: " + affectedRows + " Deleted: 0 Skipped: 0 Warnings: 0")
.getBytes();// 此处信息只是为了控制台给人看的
source.getLoadDataInfileHandler().clear();
} else {
ok.packetId = ++packetId;// OK_PACKET
}

ok.affectedRows = affectedRows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ public void execute() throws Exception {
startTime=System.currentTimeMillis();
ServerConnection sc = session.getSource();
this.isRunning = true;
this.packetId = 0;
if (rrs.isLoadData()) {
this.packetId = session.getSource().getLoadDataInfileHandler().getLastPackId();
} else {
this.packetId = 0;
}

final BackendConnection conn = session.getTarget(node);
LOGGER.debug("rrs.getRunOnSlave() " + rrs.getRunOnSlaveDebugInfo());
node.setRunOnSlave(rrs.getRunOnSlave()); // 实现 master/slave注解
Expand Down Expand Up @@ -327,8 +332,8 @@ public void okResponse(byte[] data, BackendConnection conn) {
ok.read(data);
boolean isCanClose2Client =(!rrs.isCallStatement()) ||(rrs.isCallStatement() &&!rrs.getProcedure().isResultSimpleValue());
if (rrs.isLoadData()) {
byte lastPackId = source.getLoadDataInfileHandler().getLastPackId();
ok.packetId = ++lastPackId;// OK_PACKET
// byte lastPackId = source.getLoadDataInfileHandler().getLastPackId();
ok.packetId = ++packetId;// OK_PACKET
source.getLoadDataInfileHandler().clear();

} else if (isCanClose2Client) {
Expand Down

0 comments on commit f929f96

Please sign in to comment.