Get the App
SLTechnology News&Howtos  ›  Database  › 

How to read longblob field in Amoeba

Shulou Source: shulou.com Published: 2022-05-31 19:20:56 10月29日 Update

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.

Tags: Fields size content cache channel length analysis maximum interesting tried and tested professional small and medium code memory rich content place capacity that is properties files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno NVidia Redmi Shulou Information