From 83a751497ec67c53e9e307d7ce07953bc57b3442 Mon Sep 17 00:00:00 2001 From: Mingyu Chen Date: Wed, 29 Jul 2020 15:01:27 +0800 Subject: [PATCH] [Bug][Socket Leak] Fix bug that Mysql NIO server is leaking sockets (#4192) When using mysql nio server, if the mysql handshake protocol fails, we need to actively close the channel to prevent socket leakage. --- .github/PULL_REQUEST_TEMPLATE.md | 22 +++++++++---------- .../org/apache/doris/mysql/MysqlChannel.java | 2 +- .../doris/mysql/nio/AcceptListener.java | 19 ++++++++++++++-- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e541a98cc7..e1710d1253 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -7,22 +7,22 @@ Describe the big picture of your changes here to communicate to the maintainers What types of changes does your code introduce to Doris? _Put an `x` in the boxes that apply_ -- [ ] Bugfix (non-breaking change which fixes an issue) -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) -- [ ] Documentation Update (if none of the other choices apply) +- [] Bugfix (non-breaking change which fixes an issue) +- [] New feature (non-breaking change which adds functionality) +- [] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [] Documentation Update (if none of the other choices apply) +- [] Code refactor (Modify the code structure, format the code, etc...) ## Checklist _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._ -- [ ] I have create an issue on [Doris's issues](https://github.com/apache/incubator-doris/issues), and have described the bug/feature there in detail -- [ ] Commit messages in my PR start with the related issues ID, like "#4071 Add pull request template to doris project" -- [ ] Compiling and unit tests pass locally with my changes -- [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] If this change need a document change, I have updated the document -- [ ] Any dependent changes have been merged +- [] I have create an issue on #ISSUE, and have described the bug/feature there in detail +- [] Compiling and unit tests pass locally with my changes +- [] I have added tests that prove my fix is effective or that my feature works +- [] If this change need a document change, I have updated the document +- [] Any dependent changes have been merged ## Further comments -If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc... \ No newline at end of file +If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc... diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlChannel.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlChannel.java index 081214971e..fa7ba25d39 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlChannel.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlChannel.java @@ -147,7 +147,7 @@ public class MysqlChannel { readLen = readAll(headerByteBuffer); if (readLen != PACKET_HEADER_LEN) { // remote has close this channel - LOG.info("Receive packet header failed, remote may close the channel."); + LOG.debug("Receive packet header failed, remote may close the channel."); return null; } if (packetId() != sequenceId) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/nio/AcceptListener.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/nio/AcceptListener.java index dad1bd91e4..a653f52030 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mysql/nio/AcceptListener.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/nio/AcceptListener.java @@ -48,6 +48,8 @@ public class AcceptListener implements ChannelListener