Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to read longblob field in Amoeba

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

In this issue, the editor will bring you about how to read the longblob field in Amoeba. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Recently, an application uses Amoeba to read tables containing longblob fields in MySQL from several libraries and always reports Session was killed.

It is found that it is caused by the cache size of the readable channel in Amoeba. It turns out that in the com.meidusa.amoeba.net.io.PacketInputStream class, there is an attribute maxPacketSize that limits the cache size of the readable channel. If the length of the record currently read is greater than maxPacketSize, an error will be reported. So we have to make it bigger.

Java code

/ * * maximum capacity * /

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 defaults to 2MB, but it is found that the setMaxPacketSize method is not called elsewhere and should not be configurable, so I directly modified the MAX_BUFFER_CAPACITY and repackaged it and threw it.

In addition, when using SQLYog to connect agents when maxPacketSize is not large enough, an interesting phenomenon is found. If I have a table, the lengths of the fields are as follows:

Field1 | field2

1m | 3m

If I execute: SELECT field2 FROM tab first

Error at this time: Lost connection to MySQL server during query

Execute again: SELECT field1 FROM tab

SQLYog doesn't respond, and amoeba throws an OOM exception, which works all the time. After checking the DUMP file, it is found that the DailyRollingFileAppender of AuthingableConnectionManager and Log4j is full of memory.

This is how to read the longblob field in the Amoeba shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report