[mysql8] Unknown column 'public' in 'firewall_rules_v2'

Bug #1846606 reported by Albert Damen
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
James Page
neutron-fwaas (Ubuntu)
Fix Released
High
James Page

Bug Description

I installed a fresh openstack test cluster in eoan today (October 3).

Neutron database initialization with the command:
sudo su -s /bin/sh -c "neutron-db-manage
  --config-file /etc/neutron/neutron.conf
  --config-file /etc/neutron/plugins/ml2/ml2_conf.ini
   upgrade head" neutron

failed with error message:
oslo_db.exception.DBError: (pymysql.err.InternalError) (1054, "Unknown column 'public' in 'firewall_rules_v2'") [SQL: 'ALTER TABLE firewall_rules_v2 CHANGE public shared BOOL NULL'] (Background on this error at: http://sqlalche.me/e/2j85)

In mysql the table and the column exist, with a constraint on the column:
CONSTRAINT `firewall_rules_v2_chk_1` CHECK ((`public` in (0,1))),

manually updating the column in mysql failed with the same error message.
mysql> ALTER TABLE firewall_rules_v2 CHANGE public shared BOOL NULL;
ERROR 1054 (42S22): Unknown column 'public' in 'check constraint firewall_rules_v2_chk_1 expression'

I guessed the constraint did not like it if the name of the column was changed.
I removed the column 'private' and created it again, without the constraint. The the alter table command worked fine.
After doing the same for the private columns in tables firewall_groups_v2 and firewall_policies_v2 Neutron could initialize the database and all was fine (I could create a network and start an instance).

neutron 2:15.0.0~rc1-0ubuntu1
mysql-server 8.0.16-0ubuntu3

Tags: db fwaas
Revision history for this message
Albert Damen (albrt) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in neutron (Ubuntu):
status: New → Confirmed
Revision history for this message
James Page (james-page) wrote :

Worth noting that mysql-8 is the first mysql release that supports check constraints and they behave a little differently to pgsql ones.

Revision history for this message
James Page (james-page) wrote :

I think that if you rename a column the check constraint would need to be dropped first and then re-created afterwards.

Revision history for this message
James Page (james-page) wrote :

I think the check constraint is automatically created by sqlalchemy to enforce the Boolean type definition.

Changed in neutron (Ubuntu):
assignee: nobody → James Page (james-page)
affects: neutron (Ubuntu) → neutron-fwaas (Ubuntu)
Changed in neutron-fwaas (Ubuntu):
assignee: James Page (james-page) → nobody
Revision history for this message
James Page (james-page) wrote :
summary: - [eoan] Unknown column 'public' in 'firewall_rules_v2'
+ [mysql8] Unknown column 'public' in 'firewall_rules_v2'
Revision history for this message
Bernard Cafarelli (bcafarel) wrote :

Not tested directly, but marking confirmed, James are you working on it on neutron-fwaas side?

Changed in neutron:
status: New → Confirmed
importance: Undecided → High
tags: added: fwaas
tags: added: db
Revision history for this message
James Page (james-page) wrote :

I can next week - however the solution is at best a workaround as alembic/sqla don't have an immediate fix for dropping and re-creating the constraint that gets auto-generated.

The fix is to use create_constraint=False when creating sa.Boolean column types so they don't get generated in the first place - that could be limited to MySQL thus maintaining the pre MySQL 8 behaviour.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron-fwaas (master)

Fix proposed to branch: master
Review: https://review.opendev.org/686753

Changed in neutron:
assignee: nobody → James Page (james-page)
status: Confirmed → In Progress
James Page (james-page)
Changed in neutron-fwaas (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → High
assignee: nobody → James Page (james-page)
James Page (james-page)
Changed in neutron-fwaas (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package neutron-fwaas - 1:15.0.0~rc1-0ubuntu2

---------------
neutron-fwaas (1:15.0.0~rc1-0ubuntu2) eoan; urgency=medium

  * d/p/disable-check-constraint-for-public-columns.patch: Disable
    creation of check constraints for 'public' columns under MySQL
    (LP: #1846606) resolving compatibility with MySQL >= 8.
  * d/tests/*: Add autopkgtest to validate database migrations under
    MySQL.

 -- James Page <email address hidden> Mon, 07 Oct 2019 09:31:20 +0100

Changed in neutron-fwaas (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron-fwaas (master)

Change abandoned by Slawek Kaplonski (<email address hidden>) on branch: master
Review: https://review.opendev.org/686753
Reason: As we are going to deprecate master branch in this project this patch is not needed anymore.

Changed in neutron:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.