Skip to content

Commit f929f96

Browse files
authored
Merge pull request #2392 from WhaleCloud-platform/#2390
#2390 load data local过程中出现错误,应用直接报Lost connection to MySQL server dur…
2 parents 97c7a15 + 7fac07e commit f929f96

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/main/java/io/mycat/backend/mysql/nio/handler/MultiNodeQueryHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ protected void reset(int initCount) {
175175
this.execCount = 0;
176176
this.netInBytes = 0;
177177
this.netOutBytes = 0;
178+
179+
if (rrs.isLoadData()) {
180+
packetId = session.getSource().getLoadDataInfileHandler().getLastPackId();
181+
}
178182
}
179183

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

346350
lock.lock();
347351
try {
352+
ok.packetId = ++packetId;// OK_PACKET
348353
if (rrs.isLoadData()) {
349-
byte lastPackId = source.getLoadDataInfileHandler()
350-
.getLastPackId();
351-
ok.packetId = ++lastPackId;// OK_PACKET
352354
ok.message = ("Records: " + affectedRows + " Deleted: 0 Skipped: 0 Warnings: 0")
353355
.getBytes();// 此处信息只是为了控制台给人看的
354356
source.getLoadDataInfileHandler().clear();
355-
} else {
356-
ok.packetId = ++packetId;// OK_PACKET
357357
}
358358

359359
ok.affectedRows = affectedRows;

src/main/java/io/mycat/backend/mysql/nio/handler/SingleNodeHandler.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ public void execute() throws Exception {
176176
startTime=System.currentTimeMillis();
177177
ServerConnection sc = session.getSource();
178178
this.isRunning = true;
179-
this.packetId = 0;
179+
if (rrs.isLoadData()) {
180+
this.packetId = session.getSource().getLoadDataInfileHandler().getLastPackId();
181+
} else {
182+
this.packetId = 0;
183+
}
184+
180185
final BackendConnection conn = session.getTarget(node);
181186
LOGGER.debug("rrs.getRunOnSlave() " + rrs.getRunOnSlaveDebugInfo());
182187
node.setRunOnSlave(rrs.getRunOnSlave()); // 实现 master/slave注解
@@ -327,8 +332,8 @@ public void okResponse(byte[] data, BackendConnection conn) {
327332
ok.read(data);
328333
boolean isCanClose2Client =(!rrs.isCallStatement()) ||(rrs.isCallStatement() &&!rrs.getProcedure().isResultSimpleValue());
329334
if (rrs.isLoadData()) {
330-
byte lastPackId = source.getLoadDataInfileHandler().getLastPackId();
331-
ok.packetId = ++lastPackId;// OK_PACKET
335+
// byte lastPackId = source.getLoadDataInfileHandler().getLastPackId();
336+
ok.packetId = ++packetId;// OK_PACKET
332337
source.getLoadDataInfileHandler().clear();
333338

334339
} else if (isCanClose2Client) {

0 commit comments

Comments
 (0)