Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
3.3.3, 3.4.1
-
None
Description
This was tested with MariaDB Connector J 3.3.3 and 3.4.1 with Java 21 and database 11.4 and 10.11 with the same result:
doint batch import into a table with BLOB field and two entries in the batch with one BLOB field of around 330KByte and the other arount 22MByte fails with an "Unknown Command" exception. The important is partly done. Doing single inserts works. If the size is varied then it works or does not work, seems to be related to the required buffer for the command.
To reproduce: simple table
CREATE TABLE sn_test (sn_key INTEGER, sn_name VARCHAR(255), sn_description VARCHAR(255), sn_object LONGBLOB, CONSTRAINT pk_test_i PRIMARY KEY (sn_key) )
|
And then simple code. Database connection was with all defaults of the driver. The maximum packet size of the database is configured to 1 GB (the test data is much smaller).
String insertStatement = "INSERT INTO sn_test (sn_key, sn_name, sn_description, sn_object) VALUES (?, ?, ?, ?)";
|
try (PreparedStatement prep = connection.prepareStatement(insertStatement))
|
{
|
prep.setInt(1, 1000);
|
prep.setString(2, "name1");
|
prep.setString(3, "desc1");
|
prep.setBytes(4, new byte[334004]);
|
prep.addBatch();
|
|
prep.setInt(1, 1001);
|
prep.setString(2, "name2");
|
prep.setString(3, "desc2");
|
prep.setBytes(4, new byte[21963743]);
|
prep.addBatch();
|
|
prep.executeBatch();
|
prep.clearBatch();
|
connection.commit();
|
}
|
The following exception is thrown:
java.sql.BatchUpdateException: (conn=94633) Unknown command
|
2024-09-04 10:26:48 - at org.mariadb.jdbc.export.ExceptionFactory.createBatchUpdate(ExceptionFactory.java:181)
|
2024-09-04 10:26:48 - at org.mariadb.jdbc.BasePreparedStatement.executeBatchBulk(BasePreparedStatement.java:1805)
|
2024-09-04 10:26:48 - at org.mariadb.jdbc.ClientPreparedStatement.executeInternalPreparedBatch(ClientPreparedStatement.java:132)
|
2024-09-04 10:26:48 - at org.mariadb.jdbc.BasePreparedStatement.executeBatch(BasePreparedStatement.java:1623)
|
But at least the first entry is imported. This is also an issue since the commit fails with an exception, part of the import is done (which should not be on a commit failure).
Perhaps this is caused by internal issue in buffer/parameter handling of the prepared statement and the command is then garbage.
The database does not log anything special, except a generic about aborted connection due to "Got an error reading communication packets"