Bug #103814 ClusterJ partition key scratch buffer size too small
Submitted: 26 May 2021 12:30 Modified: 14 Feb 2023 21:21
Reporter: Mikael Ronström Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:8.0.23++ OS:Any
Assigned to: CPU Architecture:Any

[26 May 2021 12:30] Mikael Ronström
Description:
Create a table like this:

CREATE TABLE t (
a VARCHAR(500) collate utf8_unicode_ci primry key NOT NULL
) engine=NDB DEFAULT CHARSET utf8;

Insert a row into this table from ClusterJ
Will generate error code 4278, buffer too small.
The problem is the partition key scratch buffer size which is limited
to 10000 bytes. This table will require 120000 bytes of hash buffer
(500 * 3 * 8).

How to repeat:
Create a table like this:

CREATE TABLE t (
a VARCHAR(500) collate utf8_unicode_ci primry key NOT NULL
) engine=NDB DEFAULT CHARSET utf8;

Insert a row into this table from ClusterJ
Will generate error code 4278, buffer too small.

Suggested fix:
Use malloc when buffer isn't large enough in Ndb.cpp::computeHash.
[27 May 2021 0:14] MySQL Verification Team
Hi Mikael,

Thanks for the report!

all best
Bogdan
[15 Dec 2022 15:20] OCA Admin
Contribution submitted via Github - BUG#32959894 
(*) Contribution by Mikael Ronström (Github mronstro, mysql-server/pull/433#issuecomment-1352409867): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_1165880699.txt (text/plain), 22.60 KiB.

[14 Feb 2023 21:21] Jon Stephens
Documented fix as follows in the NDB 7.5.30, 7.6.26, and 8.0.33 changelogs:

    ClusterJ uses a scratch buffer for primary key hash calculations
    which was limited to 10000 bytes, which proved too small in some
    cases. Now we malloc() the buffer if its size is not sufficient.

    This also fixes an issue with the Ndb object methods
    startTransaction() and computeHash() in the NDB API: Previously,
    if either of these methods was passed a temporary buffer of
    insufficient size, the method failed. Now in such cases a
    temporary buffer is allocated.

    Our thanks to Mikael Ronström for this contribution.

Closed.

Tack så mycket!