StarRocks / starrocks

StarRocks, a Linux Foundation project, is a next-generation sub-second MPP OLAP database for full analytics scenarios, including multi-dimensional analytics, real-time analytics, and ad-hoc queries.
https://starrocks.io
Apache License 2.0
8.55k stars 1.73k forks source link

Issue with Python Django Support #40846

Open metalshanked opened 6 months ago

metalshanked commented 6 months ago

Running Django versions from 3.2.x to 5.x (Same issue)

Steps to reproduce the behavior (Required)

Below is an example config that I tried

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'django',
        'PASSWORD':'',
        'HOST':'127.0.0.1',
        'PORT':'3306',
        'USER':'',
        'OPTIONS': {
            "init_command": "SET storage_engine=olap",
             #"init_command": "SET @default_storage_engine=olap",
        },
    }
}

Expected behavior (Required)

Should Connect without errors

Real behavior (Required)

(1064, "Getting analyzing error. Detail message: Unknown system variable 'default_storage_engine', the most similar variables are {'default_rowset_type', 'default_table_compression', 'enable_sort_aggregate'}.")

StarRocks version (Required)

3.2.2

Seems like there is no system variable in Starrocks for default_storage_engine which is needed by the mssqlclient for Django

Note: default_storage_engine was introduced in MySQL 5.5.3. storage_engine was removed in MySQL 5.7.5.

Starrocks seem to be show up as 5.1.0

MySQL 8.0.11 or later is required (found 5.1.0)

Please advise.

Thanks!

chaoyli commented 6 months ago

You can change the mysql_server_version in the fe.conf. The default is 5.1.0

metalshanked commented 6 months ago

Thanks @chaoyli. Will update it How about the 1st part of the problem...i.e. Django is hardcoded to look for system variable default_storage_engine

default_storage_engine was introduced in MySQL 5.5.3 and above and storage_engine variable used in starrocks is deprecated and removed in all newer mysql versions.

so applications like Django are hardcoded to look for default_storage_engine variable and cannot connect to starrocks

Eg:- https://github.com/django/django/blob/9cefdfc43f0bae696b56fa5a0bf22346f85affff/django/db/backends/mysql/base.py#L412

https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_storage_engine

metalshanked commented 6 months ago

@chaoyli if we change mysql_server_version to any 8.x.x version then DDL statements like create throw error like below

setting mysql_server_version as 8.0.0

SQL Error [1064] [42000]: Getting analyzing error. Detail message: Unknown system variable 'tx_read_only', the most similar variables are {'innodb_read_only', 'trace_log_mode', 'default_rowset_type'}.

setting mysql_server_version > 8.0.0

SQL Error [1064] [42000]: Getting analyzing error. Detail message: Unknown system variable 'transaction_read_only', the most similar variables are {'innodb_read_only', 'trace_log_mode', 'default_rowset_type'}.
github-actions[bot] commented 1 week ago

We have marked this issue as stale because it has been inactive for 6 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to StarRocks!