Bug #95969 Setting sort_buffer_size to a large value causes query to go out of memory
Submitted: 25 Jun 2019 7:34 Modified: 15 Jan 2020 12:11
Reporter: Manuel Rigger Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:8.0.16, 5.7.26 OS:Ubuntu
Assigned to: CPU Architecture:Any

[25 Jun 2019 7:34] Manuel Rigger
Description:
Explicitly setting sort_buffer_size to a large value causes a query to go out of memory. The example below sets sort_buffer_size to the maximum value on Linux (18446744073709551615, see https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sort_buffer_si...), but it can also be set to a lower value.

How to repeat:
SET SESSION sort_buffer_size = 18446744073709551615;
CREATE TABLE t0(c0 INT UNIQUE, c1 INT UNIQUE);
INSERT INTO t0(c0) VALUES(1), (2), (3);
SELECT * FROM t0 WHERE NOT((t0.c1 IS NULL) AND ((t0.c0) != (1))); -- unexpected: ERROR 5 (HY000): Out of memory (Needed 24 bytes)
[25 Jun 2019 7:39] MySQL Verification Team
Hello Manuel Rigger,

Thank you for the report.

regards,
Umesh
[20 Aug 2019 0:48] Jon Stephens
Documented fix as follows in the MySQL 8.0.18 changelog:

    Explicitly setting sort_buffer_size to its maximum value or
    close to it caused some queries to fail with an out of memory
    error.

Closed.