You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "flwitten (via GitHub)" <gi...@apache.org> on 2026/03/13 10:06:46 UTC
[I] 6.0.0 - Superset fails to initialize with MariaDB due to unsupported SQLAlchemy Sequence() in FAB models [superset]
flwitten opened a new issue, #38626:
URL: https://github.com/apache/superset/issues/38626
### Bug description
# Bug: Superset fails to initialize with MariaDB due to unsupported SQLAlchemy Sequence() in FAB models
## Summary
When using Superset with MariaDB as the metadata database, `superset db upgrade` and `superset init` fail because `flask_appbuilder` generates `Sequence()` objects for primary key columns. MariaDB does not support `CREATE SEQUENCE` in the same way as PostgreSQL, causing `OperationalError` during migrations and application startup.
## Environment
| Component | Version |
|---|---|
| Apache Superset | 6.0.0 |
| flask_appbuilder | ≥ 4.5 |
| SQLAlchemy | 2.x |
| Python | 3.11 |
| Database | MariaDB 10.x / 11.x |
> **Note:** This issue does **not** affect PostgreSQL, which supports `SEQUENCE` natively.
## Steps to Reproduce
1. Configure Superset with a MariaDB `SQLALCHEMY_DATABASE_URI`
2. Run `superset db upgrade`
3. Observe `OperationalError` during Alembic migration
## Errors
**During `superset db upgrade`:**
```
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError)
(1064, "You have an error in your SQL syntax ... near 'SEQUENCE ab_user_id_seq START WITH 100000 INCREMENT BY 1 MINVALUE 1 NOCYCLE'")
```
**During application startup / `superset init`:**
```
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError)
(4000, "Unknown SEQUENCE: 'ab_permission_id_seq'")
```
## Root Cause
`flask_appbuilder` ≥ 4.5 adds `SQLAlchemy Sequence()` objects to primary key columns in its security models (`flask_appbuilder/security/sqla/models.py`):
```python
class Permission(Model):
id = Column(
Integer,
Sequence("ab_permission_id_seq"), # <-- PostgreSQL-specific
primary_key=True,
)
```
SQLAlchemy emits `CREATE SEQUENCE` DDL for these during migrations. PostgreSQL supports this natively; MariaDB does not.
## Fix
Two-part fix required:
**1. Patch `models.py` at install time** - strip `Sequence()` calls from the FAB source:
```bash
# Remove Sequence(...), from flask_appbuilder security models
sed -i '/^[[:space:]]*Sequence([^)]*)[[:space:]]*,[[:space:]]*$/d' \
/path/to/venv/lib/python3.11/site-packages/flask_appbuilder/security/sqla/models.py
```
**2. Install a `sitecustomize.py` import hook** - patches the in-memory SQLAlchemy column metadata at import time, before `create_app()` runs:
```python
# sitecustomize.py (placed in venv site-packages)
import sys
class _FABSequencePatcher:
_target = 'flask_appbuilder.security.sqla.models'
_done = False
def find_module(self, name, path=None):
if not self._done and name == self._target:
return self
return None
def load_module(self, name):
self._done = True
sys.meta_path.remove(self)
import importlib
mod = importlib.import_module(name)
try:
from sqlalchemy import Sequence as _Seq
for attr in dir(mod):
cls = getattr(mod, attr, None)
tbl = getattr(cls, '__table__', None)
if tbl is None:
continue
for col in tbl.columns:
if isinstance(getattr(col, 'default', None), _Seq):
col.default = None
except Exception:
pass
sys.modules[name] = mod
return mod
sys.meta_path.insert(0, _FABSequencePatcher())
```
Both fixes together are needed because SQLAlchemy caches column metadata in `.pyc` bytecode - patching only the source is not sufficient if a cached `.pyc` exists.
## Impact
- Superset **cannot be initialized at all** with MariaDB when using `flask_appbuilder` ≥ 4.5
- Affects fresh installs and upgrades from older FAB versions
- PostgreSQL is unaffected
### Screenshots/recordings
_No response_
### Superset version
master / latest-dev
### Python version
3.9
### Node version
16
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 6.0.0 - Superset fails to initialize with MariaDB due to unsupported SQLAlchemy Sequence() in FAB models [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber closed issue #38626: 6.0.0 - Superset fails to initialize with MariaDB due to unsupported SQLAlchemy Sequence() in FAB models
URL: https://github.com/apache/superset/issues/38626
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 6.0.0 - Superset fails to initialize with MariaDB due to unsupported SQLAlchemy Sequence() in FAB models [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on issue #38626:
URL: https://github.com/apache/superset/issues/38626#issuecomment-4059512971
MariaDB isn't officially supported as a metadata database ([doc](https://superset.apache.org/admin-docs/configuration/configuring-superset#setting-up-a-production-metadata-database)). I'd be closing this off since this is out of support scope.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org