Skip to content

fix: mysql user create if not exists error - #1412

Open
Kelketek wants to merge 1 commit into
overhangio:releasefrom
open-craft:fox/create-user-bypass
Open

fix: mysql user create if not exists error#1412
Kelketek wants to merge 1 commit into
overhangio:releasefrom
open-craft:fox/create-user-bypass

Conversation

@Kelketek

Copy link
Copy Markdown

Description

This pull request fixes an issue where MySQL may choke on the 'create user if not exists' command in the case that a user has a view that they have created. This is a bug in MySQL that has existed for at least a few years: https://bugs.mysql.com/bug.php?id=107139

The bug is more likely to occur in some managed database environments where the provided 'admin user' does not have the "SET_USER_ID" privilege. This is the case, for instance, with DigitalOcean. It may also happen for reasons not yet fully understood even if this privilege is available.

Supporting information

Internal ticket: https://tasks.opencraft.com/browse/BB-10998

Edx-Enterprise migration which creates a view: https://github.com/openedx/edx-enterprise/blob/master/enterprise/migrations/0236_create_vw_enterprise_customer_ecus_pecus.py

Testing instructions

  1. Run launch and verify nothing breaks in practice for normal migrations/initialization
  2. Create an admin user with all privileges except for SET_USER_ID, and set its settings:
  • MYSQL_ROOT_USERNAME
  • MYSQL_ROOT_PASSWORD
  • MYSQL_HOST
  • MYSQL_PORT
    ... as needed.
  • Try launching once more. Verify launch completes.

@tecoholic

tecoholic commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@Kelketek This was kind of insane that I didn't believe no one has run into this before, so I took a look.

  1. The bug related to SET_USER_ID only affects MySQL Version 8.0 and not 8.4.

The SET_USER_ID privilege, deprecated in MySQL 8.2.0, has been removed in this release, and its use in GRANT statements now causes a syntax error. Use the SET_ANY_DEFINER and ALLOW_NONEXISTENT_DEFINER privileges instead. (WL #15875)

  1. That means, theoretically we need to set DOCKER_IMAGE_MYSQL to docker.io/mysql:8.0 in our Tutor environment and run tutor dev launch twice to observe the failure.

If anyone like me doesn't want to spend that time confirming this using Tutor, this file contains the steps to reproduce the same issue in a standalone docker container -
mysql-shop-walkthrough.md

Running the same experiment using a MySQL 8.4 container returns cleanly.

@tecoholic tecoholic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kelketek Can you kindly update the comments to mention that this is needed for MySQL 8.0 only.

@Kelketek
Kelketek force-pushed the fox/create-user-bypass branch from 10eaf2e to a79ef7e Compare July 2, 2026 17:51
@Kelketek

Kelketek commented Jul 2, 2026

Copy link
Copy Markdown
Author

@tecoholic Done. Thank you for digging further into that-- it makes sense why others may not have hit it yet.

@ahmed-arb ahmed-arb moved this from Pending Triage to In review in Tutor project management Jul 21, 2026
@muhammadadeeltajamul

Copy link
Copy Markdown
Contributor

I think this change is not needed as current MySQL version on release branch when setting up Tutor is 8.4.11 (See here)

@tecoholic

Copy link
Copy Markdown
Contributor

@muhammadadeeltajamul This bugfix was for Tutor instances that used MySQL 8.0 from other sources like managed cloud DB service, and not for the one bundled by default with Tutor. As I mentioned in my earlier comment it's not commonly occurring and requires specific setup to reproduce locally.

DigitalOcean for example made MySQL 8.4 available in their managed DB offering only on May 2026. So the instances deployed earlier all had to use Mysql 8.0 and would run into issues.

@Kelketek

Copy link
Copy Markdown
Author

@muhammadadeeltajamul Just a ping here. Can you take another look in light of @tecoholic 's comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

6 participants