Unexpected HY001: Memory allocation error after MySQL upgrade Earlier today I upgraded a db.t3.large MySQL instance on AWS from v8.0.17 to 8.0.20.  I've seen a handful of cases where I'm seeing the error SQLSTATE[HY001]: Memory allocation error: 1038 Out of sort memory, consider increasing server sort buffer size.  I don't expect such an error because the config or instance type didn't change.  An example of where I'm seeing this is on the following query:
SELECT * FROM `messages`
WHERE
    EXISTS (
        SELECT * FROM `updates`
        WHERE
            `messages`.`update_id` = `updates`.`id`
            AND `game_id` = 18
    )
    AND `messages`.`deleted_at` IS NULL
ORDER BY `id` DESC
LIMIT 6

In this query, all columns used in the order and where clauses are either foreign or primary keys with messages.deleted_at being the only exception.
In the meantime I'm going to adjust this setting in my prod environment to increase the size of the sort_buffer_size, but this change is not recommend according to a lot of stuff I'm reading so I hope it'll temporarily resolve the issue.
And you have large JSON or Geometry columns?  (Always provide SHOW CREATE TABLE when asking a question.)
Either increase or decrease sort_buffer_size and innodb_sort_buffer_size.
https://bugs.mysql.com/bug.php?id=103465
and
https://bugs.mysql.com/bug.php?id=103225