Skip to content

[Server] Run all tests on MySQL 8.4 and fix the issues it found - #2044

Merged
yili-db merged 21 commits into
unitycatalog:mainfrom
shba24:stack/uc-mysql-suite
Oct 29, 2026
Merged

yili-db merged 21 commits into
unitycatalog:mainfrom
shba24:stack/uc-mysql-suite

Conversation

@shba24

@shba24 shba24 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Every pull request now also runs the whole test suite on MySQL 8.4, and the bugs that run found are fixed.

#2008 and #2009 run every test on PostgreSQL 18. This PR does the same for MySQL:

  • SupportedDatabase.MYSQL_8, build/sbt testMySQL8, and one blocking CI row, All tests (Spark 4.0.0, Delta 4.3.1, MYSQL_8).
  • PostgreSQL and MySQL test databases now come from one shared harness (TemplateDatabases): the schema is built once per JVM, and each test gets its own copy.
  • @TempDatabase injects a per-test database (from the [Server] Run every test on H2 or PostgreSQL 18 #2008 review). The 12 classes that created and closed one by hand now declare a field.
  • MySQLDeltaCommitsCRUDTest, which started its own MySQL container, is removed. Its lock test moves into SdkDeltaCommitsCRUDTest, so it runs on every database.

Bugs the MySQL run found:

  • Columns came back in the wrong order. GET on a table returned columns in MySQL's primary-key order (random UUIDs), so Spark could build the table schema with columns swapped. Function parameters had the same problem. Both collections are now ordered by position with @OrderBy: the table columns by [Server] Return table columns in ordinal position order #2031 on main, the function parameters here. No schema change.
  • Storage paths were compared case-insensitively. MySQL's default collation treats s3://b/RESERVED and s3://b/reserved as equal, unlike S3, Linux, PostgreSQL and H2. The deployment docs and the example compose file now create the database with utf8mb4_0900_bin, and the server logs a warning at startup when the database or its tables compare text case-insensitively.

Testing

  • server/test passes on H2, PostgreSQL 18 and MySQL 8.4.
  • The whole MySQL suite (all projects) passes. Before the fixes, 6 Spark testTableWithSupportedDataTypes cases failed on column order and ExternalLocationUtilsTest failed on path case.
  • BaseFunctionCRUDTest now creates a function with 4 parameters submitted out of position order and checks they come back in position order, so a missing ORDER BY position fails on every database (the old test passed on MySQL about 1 time in 24).
📐 Design notes & details

Why @OrderBy and not sorting in Java. The order is a property of the data, so the entity's list is ordered for every reader, not only for callers that remember to sort. For tables, the existing unique key (table_id, ordinal_position, name) lets MySQL read the rows in order. PostgreSQL and H2 returned insertion order only by luck: a PostgreSQL UPDATE writes a new row version at the end of the table, so the same unsorted query reorders after one update.

Why a database collation, not query changes. A session or connection collation (for example JDBC connectionCollation) doesn't change how a column compares: the column's own collation wins. A database created with COLLATE utf8mb4_0900_bin gives every table created in it that collation, so every =, LIKE and unique key becomes case-sensitive with no code change. utf8mb4_0900_bin is NO PAD, like PostgreSQL and H2 (utf8mb4_bin would treat 'a' and 'a ' as equal). ALTER DATABASE doesn't convert existing tables, so existing installs keep working as before and get the warning.

How MySQL test databases are copied. MySQL has no CREATE DATABASE … TEMPLATE. The template's SHOW CREATE TABLE statements are captured once and replayed into each new database with foreign key checks off. The replay keeps primary keys, unique keys, indexes, foreign keys and check constraints. The template build checks that every mapped table exists, because MySQL rejects one Hibernate index (idx_staging_location, a 2048-character column is over InnoDB's 3072-byte key limit) and the build must continue past that error.

Pinned test images. The PostgreSQL and MySQL test images are pinned by digest (tag in a comment), like the repo's actions and Dockerfile base images.

Test container settings. Both containers keep their data in memory and skip disk syncs (PostgreSQL fsync=off, MySQL InnoDB flush and binary log off). Schema setup per test drops from about 1.2 s to 0.5 s on MySQL.

This pull request and its description were written by Isaac.

true);

// Request a level other than the default, or "restored" cannot be told from "never changed"
int requested =

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain me this code?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It checks that TransactionManager applies the isolation level a caller asks for and puts the connection back afterwards. Connections are pooled, so a leaked level would change the next transaction. Three transactions on the real database:

  1. Read the connection's default level (READ_COMMITTED on H2 and PostgreSQL, REPEATABLE_READ on MySQL).
  2. Ask for a different level (REPEATABLE_READ, or SERIALIZABLE when the default already is REPEATABLE_READ) and check it's in effect inside the transaction.
  3. Run without a level and check the connection is back at the default.

Before, it always asked for REPEATABLE_READ and expected READ_COMMITTED afterwards. On MySQL the default is REPEATABLE_READ, so that failed, and "restored" couldn't be told apart from "never changed". Asking for a level other than the default makes step 3 prove the restore on every database.

Added this reasoning as the test's Javadoc in f1c1d166c220

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to explain this special case for mysql in comments also.

* insert into idx_staging_location, which the request caused, so it is INVALID_ARGUMENT.
*/
@Test
public void testValueOverIndexLimitIsInvalidArgument() {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't I add this in the other PG PR already?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, #1993 added it (merged). This PR doesn't change it: it shows here because this PR's "Files changed" tab is cumulative (cross-fork PRs all target main), and #2009 below moved it into the real-database class. This PR's own diff: shba24/unitycatalog@stack/uc-one-suite-ci...stack/uc-mysql-suite

It can't be hidden while #2009 is open: a cross-fork PR must target main, so Files changed shows everything below it until #2009 merges. I added a Reviewing link at the top of the description that shows only this PR's changes (and the same in #2045, #2046, #2047).

// IN(...) subquery, error 1235, and a subquery selecting from the table being deleted from, error
// 1093; every test here that deletes commits covers that.)
@Test
public void testCommitThatWaitedForTheLockReadsTheOtherCommit() {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is basically testing the bug that we found with MySQL?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's the MySQL bug from #2008: under MySQL's REPEATABLE READ, a commit that waited for the table lock re-read the table row from its first snapshot and missed the commit that landed in between (m0 instead of m1). #2008 fixed RepositoryUtils.lockTableForCommit to re-read with a locking read and put this test in MySQLDeltaCommitsCRUDTest.

This PR removes that class (it started its own MySQL container) and moves the test here, so it runs on every database. The REPEATABLE READ precondition is checked only on MySQL, where the bug can happen.

return new MySQLContainer<>(image)
.withUsername("root")
.withCommand(
"--innodb-flush-log-at-trx-commit=0", "--skip-log-bin", "--innodb-doublewrite=OFF");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put in the comment for reasoning behind adding each of these in a single line?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, one line each:

// Test-only speed settings (the data is thrown away):
// flush the redo log about once a second instead of at every commit
"--innodb-flush-log-at-trx-commit=0",
// no binary log (no replication or point-in-time recovery needed)
"--skip-log-bin",
// no doublewrite buffer (it only guards against torn pages on a crash)
"--innodb-doublewrite=OFF"

Same for PostgreSQL's fsync, synchronous_commit and full_page_writes, so the two harnesses stay alike.

Done in 459d8aaecd4e

void configureTemplate(Properties hibernateProperties) {
// MySQL rejects the index on uc_staging_tables.staging_location (key too long); carry on
// without it, as a real MySQL install does.
hibernateProperties.setProperty("hibernate.hbm2ddl.halt_on_error", "false");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why false? We would want to know the failure right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed in principle. It's false only because Hibernate's DDL contains one statement MySQL always rejects: the index on uc_staging_tables.staging_location (2048 characters × 4 bytes in utf8mb4 is over InnoDB's 3072-byte key limit). With true, the template build fails on every MySQL run. A real MySQL install hits the same error and carries on, because false is Hibernate's default.

What keeps other failures visible: templateBuilt fails when any mapped table is missing. It doesn't catch a missing index or constraint, though.

PR 1 (#2045) removes this: the MySQL template is then built by the Flyway steps, which leave that index out and stop on any error, so halt_on_error and the table check both go away. If you want it strict here too, Hibernate can write the DDL to a file and the harness runs it statement by statement, allowing only that one error (about 15 lines that PR 1 then deletes).

Added this reasoning and a TODO to remove it once the schema migration steps build the template (PR 1 does) in f1c1d166c220

}

@Override
void templateBuilt(List<String> mappedTables) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed only for mysql?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two reasons, both MySQL-only:

  1. Copying the template. PostgreSQL clones it with CREATE DATABASE … TEMPLATE uc_template. MySQL has no TEMPLATE, so templateBuilt reads the template's SHOW CREATE TABLE statements once, and cloneTemplate replays them into each test database.
  2. The missing-table check. Only MySQL builds with halt_on_error=false (see the comment above), so only there could a failed statement go unnoticed. PostgreSQL stops at the first error.

H2 doesn't use a template: each test gets a new database built directly.

@shba24
shba24 force-pushed the stack/uc-mysql-suite branch from f1c1d16 to 5542c61 Compare October 25, 2026 02:08
@shba24
shba24 force-pushed the stack/uc-mysql-suite branch 4 times, most recently from 566134a to bcd8db4 Compare October 26, 2026 23:22
yili-db pushed a commit that referenced this pull request Oct 27, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2009/files) to
review incremental changes.
-
[stack/uc-one-suite](#2008)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2008/files)]
[MERGED]
-
[**stack/uc-one-suite-ci**](#2009)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2009/files)]
← _this PR_
-
[stack/uc-mysql-suite](#2044)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2044/files/fdb96ee0da3b187dc47908de3f8cfc0eabdb12ac..bcd8db4d29d3c67461fcb045b4ee829e9a62afad)]
-
[stack/uc-flyway-schema](#2045)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2045/files/5542c615b9b5af8925439fe9021ef7c6b2868238..3efb98336a796a03fa69e1699760e5ef646749f5)]
-
[stack/uc-flyway-merge-checks](#2046)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2046/files/3efb98336a796a03fa69e1699760e5ef646749f5..faabc3d450357bdd37a79fe1409a9dfedc0e4ed2)]

---------
**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

**Every pull request now also runs the whole test suite on PostgreSQL
18.**

#2008 lets any test run pick PostgreSQL with
`UC_TEST_DATABASE=POSTGRES_18`. This PR adds that run to CI:

- `unit-tests.yml` gets one blocking row: the primary combo (Spark
4.0.0, Delta 4.3.1, all tests) with `test-database: POSTGRES_18`. Its
job is named `All tests (Spark 4.0.0, Delta 4.3.1, POSTGRES_18)`. The
other rows stay on H2.
- The `run-uc-unit-tests` action takes a `test-database` input (default
`H2`) and passes it to the test step as `UC_TEST_DATABASE`. The license
check runs only on the H2 row, so it isn't duplicated.
- `PostgresDeltaCommitsCRUDTest` is removed. It ran the Delta commit
tests against its own PostgreSQL 16 container; the new row runs those
same tests, and every other test, on PostgreSQL 18. Its index-limit test
moves to `TransactionManagerTest.DatabaseErrorWithRealDatabaseTest` and
runs on every database: it expects `INVALID_ARGUMENT` on PostgreSQL and
a successful insert on H2.

### Testing

- Both workflow files parse as YAML.
- The new row's first real run is this PR's CI.

<details>
<summary>📐 Design notes & details</summary>

**Why one PostgreSQL row, not one per Spark version.** Database behavior
doesn't depend on the Spark version, and the primary combo already runs
every project (server, cli, spark, hadoop). The row adds one "All tests"
job (about 49 minutes) that runs in parallel with the others, so
wall-clock time per PR stays about the same.

**Why the row is blocking from day one.** #2008 fixes the
PostgreSQL-only failure the first full run found (concurrent Iceberg
commits returning 500 instead of 409). A non-blocking row would let new
PostgreSQL-only failures merge unnoticed.

**Why remove `PostgresDeltaCommitsCRUDTest` here and not in #2008.**
Until this row exists, that class is the only PostgreSQL coverage in
default CI. Removing it in the same PR that adds the row means coverage
never drops in between.

</details>

This pull request and its description were written by Isaac.

---------

Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]>
@shba24
shba24 force-pushed the stack/uc-mysql-suite branch from bcd8db4 to ff4e42d Compare October 27, 2026 00:17
shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 27, 2026
…flyway-schema

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@yili-db

yili-db commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

/review

1 similar comment
@shba24

shba24 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

/review

shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 27, 2026
…arness comment fixes into stack/uc-flyway-merge-checks
@shba24

shba24 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] Title: this PR also changes server behavior (the @OrderBy fix for function parameters and the new MySQL collation warning in HibernateConfigurator), but it's titled [Build]. Can we retitle it, e.g. "[Server] Run all tests on MySQL 8.4 and fix the issues it found", or move the @OrderBy fix into its own [Server] PR? Release notes are built from titles.

Comment thread docs/server/deployment.md Resolved
shba24 and others added 3 commits October 28, 2026 16:53
Adds MySQL 8.4 to the test database harness (testMySQL8) and a CI job. Test
databases use the case-sensitive utf8mb4_0900_bin collation. The isolation
test now reads the database's default level instead of assuming
READ_COMMITTED.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Without an ORDER BY, MySQL returned columns (and function parameters) in
its own order.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Storage paths and names are case-sensitive, but MySQL's default collation is
not. Log a warning at startup and document the utf8mb4_0900_bin collation.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 28, 2026
@yili-db

yili-db commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

/review

shba24 and others added 4 commits October 28, 2026 22:50
…-sensitive

Only storage paths are known to compare exactly; how names are compared is not settled yet. The deployment guide, the startup warning and the test database comment now say that MySQL's default collation ignores case, which makes paths that differ only in case collide.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…fails

A failed clone happens before newDatabase returns a TestDatabase, so nothing closed the new database. The clone now drops it, keeps the Could not clone the template error, and replaces the batch lambda with a plain loop.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…CRUD test

They were submitted in position order, so H2 and PostgreSQL returned them in order without ordering by position, and MySQL passed by chance about 1 time in 24. They are now submitted shuffled and the test checks the positions come back ascending, so the test fails without the ordering on every database. The create response keeps the submitted order, so it is compared without the parameter order.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
DeltaCommitRepository's Javadoc already explains why the batch DELETE uses a derived table, so the commit test doesn't repeat it.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@shba24 shba24 changed the title [Build] Run all tests on MySQL 8.4 [Server] Run all tests on MySQL 8.4 and fix the issues it found Oct 28, 2026
shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 28, 2026
…ck/uc-flyway-schema

Keeps the template-row copy of the clone and the schema-from-connection check, and takes unitycatalog#2044's collation wording and failed-clone cleanup.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 28, 2026
…eview fixes into stack/uc-flyway-merge-checks

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@shba24
shba24 requested a review from yili-db October 28, 2026 22:57

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] Thanks, all the earlier comments are addressed. Two more, inline.

… on DROP DATABASE

MySQL's lock_wait_timeout defaults to a year, so DROP DATABASE waits for locks
held by an open transaction. PostgreSQL drops WITH (FORCE). Set a 60s timeout
on the test container so a leaked transaction fails the test.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 29, 2026
shba24 and others added 2 commits October 29, 2026 16:02
The check runs after the pool and session factory are built, outside the
constructor's try block, so an unchecked exception from it would leak the pool
and fail startup because of a warning. Catch RuntimeException as well.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…llations

MySQL compares text with each column's collation, so read
information_schema.COLUMNS instead of the database and table defaults.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 29, 2026
…stack/uc-flyway-schema

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@yili-db

yili-db commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

/review

…isting database

Log a failed check at warn, accept jdbc:mysql+srv URLs, read the collation once,
and reword the garbled Javadoc and comment. Document that an existing database
needs CONVERT TO, and say the warning looks at text columns.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 29, 2026
…into stack/uc-flyway-schema

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@yili-db
yili-db merged commit 12c8241 into unitycatalog:main Oct 29, 2026
19 checks passed
shba24 added a commit to shba24/unitycatalog that referenced this pull request Oct 29, 2026
Main squashed unitycatalog#2044, which this branch already contains; keep this branch's version of the files that both sides added.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants