Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MariaDB no longer supported - admin post screen 400 #15729

Closed
1 task done
ngreve opened this issue Oct 30, 2022 · 8 comments
Closed
1 task done

MariaDB no longer supported - admin post screen 400 #15729

ngreve opened this issue Oct 30, 2022 · 8 comments

Comments

@ngreve
Copy link

ngreve commented Oct 30, 2022

Issue Summary

I cannot access my posts. When I try to access my Posts (Drafts/Scheduled/Published) , I get the error message "Request not understood error, cannot list posts. Could not understand request. "

image

For example when I try to access the Drafts tab, the call to
https://nicogreve.de/ghost/api/admin/posts/?formats=mobiledoc%2Clexical&limit=30&page=1&filter=status%3Adraft fails with the response:

{
	"errors": [
		{
			"message": "Request not understood error, cannot list posts.",
			"context": "Could not understand request.",
			"type": "BadRequestError",
			"details": null,
			"property": null,
			"help": null,
			"code": "ER_BAD_FIELD_ERROR",
			"id": "<removed: dont know if sensitive>",
			"ghostErrorCode": null
		}
	]
}

But the website itself works just fine. I can also open the Pages tab without any problems.

The error also occurs with all browser Addons disabled and running in private mode.

Steps to Reproduce

See above

Ghost Version

5.21.0

Node.js Version

  • v16.18.0
  • v16.17.1
  • v16.16.0

How did you install Ghost?

via npm

Database type

Other

Browser & OS version

ArchLinux - Firefox/Chromium

Relevant log / error output

No response

Code of Conduct

  • I agree to be friendly and polite to people in this repository
@github-actions github-actions bot added the needs:triage [triage] this needs to be triaged by the Ghost team label Oct 30, 2022
@iBotPeaches
Copy link
Contributor

@ngreve - Are you using Maria? I had that and reported here #15727, but then I realized it was because of Maria and finally did the swap over to mysql8 and it went away.

@ngreve
Copy link
Author

ngreve commented Oct 30, 2022

Yes, I am using MariaDB. Unfortunately switching to Mysql is not an option. My distro does not have an official package for mysql. If this is not fixable by the Ghost dev team, please close this issue and I will have to switch to another CMS.
(I know that MariaDB is officially not supported. But fortunately, in the past the dev team fixed some things anyway)

@b-turchyn
Copy link

b-turchyn commented Nov 1, 2022

This impacted me as well.

The issue occurs in the subquery for counting conversions. MariaDB seems to struggle with referencing a table that is the more than the "parent" of the subquery. If the post WHERE clause is done more than one child down, the issue occurs.

This Gist has the original query and a manually updated one that produces the same results. Haven't run a query plan on it to see what (if any) performance impact would arise.

A snippet of the original and updated queries:

Original:

SELECT
    `posts`.*,
    (WITH `k` AS (
    SELECT
        `member_id`
    FROM
        `members_subscription_created_events`
    WHERE
        posts.id = members_subscription_created_events.attribution_id
UNION
    SELECT
        `member_id`
    FROM
        `members_created_events`
    WHERE
        posts.id = members_created_events.attribution_id)
    SELECT
        count(*)
    FROM
        `k`) AS `count__conversions`,

Modified, working:

SELECT
    `posts`.*,
    (WITH `k` AS (
    SELECT
        `member_id`, `attribution_id`
    FROM
        `members_subscription_created_events`
UNION
    SELECT
        `member_id`, `attribution_id`
    FROM
        `members_created_events`)
    SELECT
        count(*)
    FROM
        `k` WHERE `k`.attribution_id = `posts`.id) AS `count__conversions`,

(Unrelated: it seems like this query is retrieving posts.* multiple times. Probably not inefficient from a query performance perspective, but inefficient from a data transfer perspective.)

Edit: the source of this seems to be at core/core/server/models/post.js#L1363 (conversions(modelOrCollection)).

@ErisDS
Copy link
Member

ErisDS commented Nov 1, 2022

Sorry for taking a couple of days to get to this. As of Ghost v5 the Ghost team are no longer maintaining support for any database in production other than MySQL 8.

I've explained this a few times on the forum, but I'll also explain here:

For MySQL5, MariaDB was a 100% compatible drop in replacement. Since then, the MariaDB team have opted to diverge and not keep compatibility with MySQL. Along side this, the ORM and query builder that we depended on to maintain compatibility have not matured enough or received enough contributions to fully handle the differences.

These things combined left our tiny team with the burden of handling incompatibilities, and it was actively detracting from us being able to deliver new features.

Therefore, as of v5 we declared MySQL8 the only DB supported in production knowing full well with the features we intended to build that at some point we'd hit a breaking change in MariaDB, which has now happened.

Ghost is an open source project, and if there's an individual or preferably a group of individuals who want to take on the burden of supporting MariaDB, that is of course possible however I think that realistically the effort belongs in knex.

@ErisDS ErisDS changed the title Cannot access Posts (Drafts/Scheduled/Published) MariaDB no longer supported - issues with post screen Nov 1, 2022
@ErisDS ErisDS removed the needs:triage [triage] this needs to be triaged by the Ghost team label Nov 1, 2022
@zblesk
Copy link

zblesk commented Nov 7, 2022

Thanks to everyone here in elaborating. I've just encountered this error today, when I'd been trying to switch from MySQL to MariaDB and wondered if I'd just messed something up.

Maybe I'll consider running an older version of Ghost instead. 🤔 I do not need any of the subscription features; and since I'm self-hosting low-traffic blogs on a small server I can't really enlarge, memory usage is becoming a problem. I run both MariaDB and MySQL. MySQL runs 3 Ghost blogs and nothing else, and has ~50% bigger memory use than MariaDB running 11 app DBs...

@TheManchineel
Copy link

Any advice to migrate from MariaDB to MySQLv8?

@ErisDS ErisDS changed the title MariaDB no longer supported - issues with post screen MariaDB & MySQL 5.7 no longer supported - issues with post screen Nov 14, 2022
@ErisDS ErisDS changed the title MariaDB & MySQL 5.7 no longer supported - issues with post screen MariaDB no longer supported - issues with post screen Nov 14, 2022
@ErisDS ErisDS changed the title MariaDB no longer supported - issues with post screen MariaDB no longer supported - admin post screen 400 Nov 14, 2022
@ErisDS
Copy link
Member

ErisDS commented Nov 14, 2022

There's loads of discussions around this on the forum: https://forum.ghost.org/t/how-to-migrate-from-mariadb-10-to-mysql-8/29575

I'm going to close this issue now. If someone wants to take on the work of mariadb compatibility, we can reopen.

@TemaSM
Copy link

TemaSM commented Nov 15, 2022

Introduced by:
22fe1c0#diff-3149f93d170c65cd0c97a204a2d19c6102351b3c542c357aa342874699521237R1363
Seems to be that can be fixed by simple escaping of table's name (posts.id to `posts`.id) inside whereRaw()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants