Home > Database > Mysql Tutorial > 关于Amoeba读取longblob字段的问题_MySQL

关于Amoeba读取longblob字段的问题_MySQL

WBOY
Release: 2016-06-01 13:46:09
Original
1099 people have browsed it

bitsCN.com

最近有一个应用使用Amoeba从几个库中读取MySQL中含有longblob字段的表,老是报Session was killed。

经查是Amoeba中可读通道的缓存大小引起的。原来在com.meidusa.amoeba.net.io.PacketInputStream类中,有一个属性maxPacketSize,限制了可读通道的缓存大小,如果当前读取的记录的长度大于maxPacketSize,就会报错。所以我们必须把它调大点。

Java代码 
/** 最大容量 */ 
protected static final int MAX_BUFFER_CAPACITY = 1024 * 1024 * 2; 
private int maxPacketSize = MAX_BUFFER_CAPACITY; 
 
 
public int getMaxPacketSize() { 
    return maxPacketSize; 

 
public void setMaxPacketSize(int maxPacketSize) { 
    this.maxPacketSize = maxPacketSize; 

maxPacketSize默认是2MB,但是发现setMaxPacketSize方法没有在其它地方有调用,应该是不可配置的,因此我直接修改了MAX_BUFFER_CAPACITY,重新打包扔上去就没问题了。


另外,当maxPacketSize大小不足时,用SQLYog连代理时的时候,发现一个有趣的现象。假如我有一表,各字段长度如下:
field1 | field2
1M     | 3M

如果我先执行:SELECT field2 FROM tab
这时出错:Lost connection to MySQL server during query
再执行:SELECT field1 FROM tab
SQLYog就没有响应了,然后amoeba抛OOM异常,屡试不爽。查DUMP文件后,发现AuthingableConnectionManager 和 Log4j的DailyRollingFileAppender塞满了内存。

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template