Skip to content

[Bug][Compatibility]: Gitea cannot initialize because ALTER DATABASE COLLATE is rejected #28998

Closed

Description

@daviszhen

Description

Gitea/Gogs applications using MatrixOne through the MySQL protocol cannot complete ORM initialization because the collation bootstrap statement is rejected by the MatrixOne parser. This is observed in the mo-scenario integration deployment; MatrixOne service-component logs are not used as the source of this report.

Environment

  • MatrixOne cloud endpoint exposed through the MySQL protocol on port 6001
  • Gitea integration image: scenario-runner-gitea
  • Observed: 2026-09-16 (private mo-scenario cluster)

Reproduction

Gitea executes the following MySQL-compatible statement during startup (database name abbreviated here):

ALTER DATABASE `gitea_mo`
  CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

MatrixOne returns:

Error 1064 (42000): SQL parser error
syntax error near " CHARACTER SET utf8mb4 COLLATE utf8mb4_bin"

The same error is emitted on every ORM initialization retry. The application eventually logs InitDBEngine failed and remains unready/enters CrashLoopBackOff.

Expected behavior

Either accept the MySQL-compatible ALTER DATABASE ... CHARACTER SET ... COLLATE ... form, or provide a compatibility-safe no-op/response that allows the application migration to continue when the requested collation is already the effective collation. A supported MySQL application should not be blocked during startup by this statement.

Impact

Gitea cannot start when configured to use MatrixOne, even though the database connection itself succeeds. This blocks deployment of the application without changing its source code or adding a dialect-specific workaround.

Related

Activity

  1. added
    kind/bug
    kind/compatibility
    on Sep 16, 2026
  2. added
    severity/s0
    and removed on Sep 16, 2026
  3. ck89119 commented on Sep 29, 2026

    @ck89119
    Contributor

    This issue is reused as the canonical workstream for C03 under #29479. The newly created series subtask #29482 is being closed as duplicate tracking, not as completed functionality. Please retain the full additional scope and acceptance below alongside the original report. Existing open implementation PRs are references, not completion evidence.

    Persist and apply defaults to subsequently created objects rather than returning a compatibility no-op.

    Tracking disposition: this C-series alias is to be closed as duplicate/reused tracking in favor of #28998. The canonical issue remains responsible for the complete scope and acceptance below; closure is not a product-completion claim.

    Scope

    • Cover CREATE/ALTER DATABASE, table/column declarations, CREATE LIKE, CTAS, ADD/MODIFY COLUMN and prepared DDL.
    • Keep SHOW CREATE, information_schema, CHARSET/COLLATION and runtime behavior consistent.
    • Separate changing table defaults from CONVERT TO CHARACTER SET and actual data/index conversion.

    Acceptance criteria

    • ALTER DATABASE affects later unqualified objects but does not rewrite existing columns; explicit declarations override defaults.
    • New columns demonstrate inherited semantics through comparisons and indexes, not metadata alone.
    • Invalid combinations and new latin1 declarations fail without partial objects; conversion failure preserves original data and indexes.
    • Validate privileges, missing databases, tenant isolation, transaction/background contexts and restart/restore.

    Describe implementation you've considered

    Reuse #28998 and PR #29374, adapting their metadata to C01 and conversion policy to C02. Preserve the real inheritance contract; do not revive the no-op in #29023.

    Additional information

  4. XuPeng-SH commented on Oct 17, 2026

    @XuPeng-SH
    Contributor

    Post-merge actual verification of #29374, retaining separate branch/qualification scope.

    main b111224b0c624773389b390cd3cf1223126b6ee2, Linux/amd64, Go1.27.1, repository CPU/CGo wrapper:

    • Independent real MySQL SQL executes the reported ALTER DATABASE ... CHARACTER SET utf8mb4 COLLATE utf8mb4_bin successfully, asserts SCHEMATA utf8mb4/utf8mb4_bin, then proves a newly created column inherits utf8mb4_bin. Changing the database default afterwards leaves the existing column/data unchanged.
    • The independent original SQL/nearby controls pass normal AND race, using overlay-only TestAuditRound1450OriginalSQL; no production patch or assertion edits.
    • 13 complete owner packages pass 40,594 test/subtest events, 0 failures/11 explicitly retained skips. Full SQL integration passes 54 roots/391 events, including TestDatabaseCharsetInheritanceContract, TestDatabaseDefaultsFailureAndRecovery and TestCharsetConversionPreservesExpressionSemantics.
    • Selected SQL/race consumers pass 82 events; frontend/bootstrap/cnservice/transaction default/collation/admission/cleanup race selection passes 80 events.
    • Real two-CN normal owning package passes 15 events; selected race prepared/protocol/join consumers pass 10. Durable restart passes. Real v4.0.15 migration handler replay against restored pre-defaults schema passes system/tenant and idempotence assertions (3 events). This is handler/schema upgrade evidence, not an old-binary rolling upgrade.
    • Failure coverage includes invalid repertoire/unique conversion preserving source, commit failure, corrupt generation fail-closed, snapshot/PITR and cross-account remapping, prepared freshness and persisted expression semantics after restart.

    Commands use mo-cgo-test, -count=1 -short -tags matrixone_test -json with bounded -p 1/2 and 12-minute guards; normal/race target ./pkg/tests/sqlintegration and mapped owners/consumers. Raw commands, actual SHAs and terminal results are preserved by the audit.

    4.2-dev ac27db31696c0394ab1b2787b7b0a8f4933f088f, Go1.26.4 remains broken for the original public statement:

    Error 1064 (42000): SQL parser error ... near " character set utf8mb4 collate utf8mb4_bin"
    

    The clean old-main d00ece1 negative control independently reproduces that same parser rejection. Keep development with ck89119 and leave the issue open for this branch gap; main-only acceptance is not an all-branch completion.

    Limits: the private mo-scenario Gitea deployment was not accessible/rebuilt; the exact SQL and real persistence/metadata consumers were tested instead. No GPU, live mixed/old-binary rolling upgrade, full-repository CI or complete C01-C12 collation certification. Initial local startup collisions from separate audit port registries were excluded and affected runs retried after unifying the lease directory; their original logs remain preserved.

  5. assigned and unassigned on Oct 18, 2026
  6. ck89119 commented on Oct 18, 2026

    @ck89119
    Contributor

    no need to backport to 4.2-dev

  7. slyunnn commented on Oct 21, 2026

    @slyunnn

    Regression and extended verification for #28998 (2026-10-21)

    Verification Environment

    • MatrixOne origin/main at validation time: 04fe057bd73520cdf30754f79f66f6505060ad1f — fix(frontend): publish DUMP archives with create-only storage writes (#29808). The running darwin/arm64 mo-service was freshly built from that commit, and its embedded VCS revision was checked.
    • Local topology: 2 CN / 1 TN / 1 Log service / 1 Proxy. Proxy 6001, CN1 16001, and CN2 16002 were independently reachable over the MySQL protocol. The original SQL was executed through all three endpoints, not merely health-checked.
    • Clients: PyMySQL text protocol for the original SQL; Go database/sql + go-sql-driver/mysql with interpolateParams=false for real COM_STMT_PREPARE / COM_STMT_EXECUTE. An official Gitea 1.26.4-rootless instance was also started against the local Proxy.
    • Associated fix: MatrixOne PR #29374, commit 7c2847207dc5bd87f6c23dc7318f7be21c0a5f2a — fix(sql): persist charset defaults and implement table conversion. It is included in the tested main binary. The issue owner said a 4.2-dev backport is not required.

    What Was Covered

    • OK — The original Gitea ALTER DATABASE ... CHARACTER SET utf8mb4 COLLATE utf8mb4_bin succeeded on Proxy 6001, CN1 16001, and CN2 16002; the reported 1064 parser error did not recur.
    • OK — information_schema.schemata showed the persisted utf8mb4 / utf8mb4_bin default. New columns inherited binary collation, while pre-existing columns and data retained their previous collation. MIN, MAX, and indexed equality checks confirmed runtime behavior rather than metadata alone.
    • OK — Explicit table override, repeated ALTER DATABASE, SQL prepared DDL, and binary-protocol prepared DDL used the expected current defaults. The binary-protocol scenario passed on all three endpoints.
    • OK — Negative cases included unsupported collation 20301, missing database 1049, initial privilege denial 20101, and grant/revoke rechecks. Failed conversion cases (20105 / 20301) preserved source data and indexes; valid conversion also passed.
    • OK — Tenant isolation was checked with the same database name in separate tenants through CN1 and CN2. Focused integration coverage passed for durable restart, snapshot/PITR and cross-account restore, plus the 4.0.15 metadata-upgrade handler. The handler test is not evidence of a live rolling upgrade.
    • OK — Official Gitea 1.26.4-rootless completed ORM initialization through the local Proxy, exposed a healthy /api/healthz, and created 112 tables. This is an application-level control, but it is not the private scenario image.
    • Not covered — Startup of the exact private scenario-runner-gitea-1.27.3 deployment; its environment was not accessible. Therefore recovery of that specific private deployment is not confirmed. The expanded C03 acceptance criteria have not received a complete, independent sign-off; unexecuted items must not be counted as passed.
    • Not covered — A successful live 4.2-dev → main rolling upgrade or its post-upgrade SQL assertions. This is a separate C11 upgrade-compatibility/release gate, not a prerequisite for concluding that the original [Bug][Compatibility]: Gitea cannot initialize because ALTER DATABASE COLLATE is rejected #28998 parser/bootstrap bug is fixed on the tested main.

    Findings

    • The original reported bug is fixed on the tested main binary. No MatrixOne product failure was observed in the executed local SQL, protocol, application-control, or focused integration scenarios.
    • TKE run #39568304757 failed during baseline-cluster scheduling, before the upgrade SQL assertions. In a subsequent run, CN rollout reached the protocol gate: the old CN reported protocol version 10, while the target migration required all CNs to support at least version 61. The upgrade was rejected; the new CN then timed out while waiting to become query-ready and panicked on startup. No post-upgrade [Bug][Compatibility]: Gitea cannot initialize because ALTER DATABASE COLLATE is rejected #28998 SQL assertion ran. These are upgrade-path blockers, not evidence that the original SQL regression failed. Rerunning the same version pair unchanged would not resolve the protocol mismatch.
    • Large-data regression: not needed for this defect mechanism. It concerns DDL parsing, persisted defaults, and collation semantics, not row count, block/batch, spill, skew, or throughput. The Nightly case targets the upgrade boundary, not data volume.

    MOTR / BVT Coverage

    • SQL and real binary-protocol cases are in MOTR PR #251. Source issue commit: bfb291f384365431c211053e9fa31f795362b9c6; daily cherry-pick: 9a806a901b34e30236710e8ab9e41f89497f7841.
    • Both cases were recorded and replayed on Proxy 6001: 2/2 cases and 27/27 statements/checks passed. The binary-protocol script also passed directly on CN1 16001 and CN2 16002; original/text checks passed on all three endpoints. The cases used isolated databases and ran with MOTR -j 2, which is case scheduling, not MatrixOne engine-parallel execution.
    • Nightly PR #1844, issue commit 05081e8c5af06becda70ae6e3b8012a7b3985e1b, adds a pre/post-upgrade fixture to the existing TKE workflow. Local script dry-runs and focused workflow tests passed. Live upgrade qualification did not pass: the first TKE attempt was blocked by cluster scheduling, and a later attempt was stopped by the mixed-version protocol gate before post-upgrade SQL. This PR is C11 upgrade-path evidence, not a completed [Bug][Compatibility]: Gitea cannot initialize because ALTER DATABASE COLLATE is rejected #28998 regression or a gate for the original bug's main verdict. No MatrixOne service source was changed.

    Final Conclusion

    Fixed for the original #28998 failure on the tested main; expanded C03 acceptance is not fully signed off. The original 1064 failure did not recur on any of the three endpoints, and the official Gitea control initialized successfully. The exact private Gitea deployment was not run, so its operational recovery cannot be claimed. Live 4.2-dev → main rolling upgrade belongs to C11 #29490; its current protocol-gate failure neither overturns the original main verdict nor establishes upgrade compatibility. The issue owner stated that a 4.2-dev backport is not required.

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

Metadata

Metadata

Assignees

Labels

kind/bugkind/compatibilityseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions