Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[需求]增加流量控制功能,防止select大表导致mycat内存问题 #2527

Open
funnyAnt opened this issue Jun 20, 2020 · 3 comments

Comments

@funnyAnt
Copy link
Collaborator

需求来源

客户端执行select大表时,数据流向是mysql--->mycat---->客户端。目前的处理流程存在的问题是,mycat会暂时缓存mysql发送过来的数据,若客户端从mycat读取的数据慢或者卡住,会造成数据在mycat侧积压,由此引发mycat jvm内存问题。

解决方法:

在mycat侧做流量控制,当缓存队列积压的数据达到最高阀值后,关闭socket读事件,停止从mysql读取数据。当缓存队列数据恢复到安全阀值后,开启socket 读事件,继续从mysql读取数据。

副作用

超过net_write_timeout(默认值60s)时间,mysql侧socket发送缓存区的数据依然没有被读取走,mysql会主动关闭连接。

@funnyAnt
Copy link
Collaborator Author

你好,蚁人老哥。我想问个问题 ,关于中间件到数据库查询数据时,如果是流式查询,那么排序问题怎么解决,分片方式有很多种,怎么才能保证序列不乱呢?还有就是请问后端查询函数在哪里。

@majisama 目前mycat的处理框架,如果用流式的话,只能支持到不需要合并结果集的SQL,如分片表SQL且路由到多个节点,并且带sum,count,distinct,group by,limit ,order by这种是不支持的。 因为这种类型的SQL是需要mycat拉取到所有的数据,然后统一二次加工,所以就没有办法用流式查询。

@funnyAnt
Copy link
Collaborator Author

funnyAnt commented Jul 5, 2020

@junwen12221 代码已经提交,请验证下,是否有考虑不全的场景。

junwen12221 added a commit that referenced this issue Jul 5, 2020
#2527 增加流量控制功能,防止select大表导致mycat内存问题
@funnyAnt
Copy link
Collaborator Author

funnyAnt commented Jul 7, 2020

初步实现,还没有大规模测试,可能还有问题,使用过程中有问题请反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant