Skip to content

[core] Create JDBC catalog table properties table only when sync-all-properties is enabled - #11398

Open
COLDMANYU wants to merge 5 commits into
apache:masterfrom
COLDMANYU:jdbc-table-properties-sync
Open

COLDMANYU wants to merge 5 commits into
apache:masterfrom
COLDMANYU:jdbc-table-properties-sync

Conversation

@COLDMANYU

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #11096

Since 1.4.0 (#7423), the JDBC catalog creates paimon_table_properties at startup. Its primary key has four VARCHAR(255) columns, which take 4080 bytes on MySQL with utf8mb4, above InnoDB's 3072-byte limit, so the catalog fails to start with Specified key was too long.

The table is only used to sync table properties: every read and write of it is already behind sync-all-properties, and the catalog reads table options from the schema files, not from this table. This PR:

  • creates the table only when sync-all-properties is true, so a catalog with the sync disabled starts on MySQL utf8mb4;
  • wraps a failure to create the table in a message that names the table and points to the two ways out: set sync-all-properties to false, or create the table before the catalog starts (for example with shorter key columns). The default stays true, so the default setup on MySQL utf8mb4 still needs one of them.

As discussed in the issue, a length option like lock-key-max-length is left out: it would have to shorten all four key columns, including the database and table names that paimon_tables keeps at 255. Happy to change the approach if you prefer something else.

Tests

JdbcCatalogTest:

  • testTablePropertiesTableCreatedOnlyWhenSyncEnabled: with the sync disabled the table is not created; enabling it later on the same database creates it.
  • testTablePropertiesTableCreationFailure: when creating the table fails, the error names the table and sync-all-properties, and the catalog still starts with the sync disabled.
  • testTablePropertiesSyncDisabled now checks that the table does not exist, instead of reading it.

All 86 tests in JdbcCatalogTest pass. I also ran the catalog against MySQL 8.0.46 with a utf8mb4 database:

Setup Result
Default (sync-all-properties = true) Fails with the new message, caused by Specified key was too long
sync-all-properties = false Starts; paimon_table_properties is not created
Default, table created beforehand with shorter catalog_key and property_key Starts

API and Format

No API or storage format change. With sync-all-properties = false, the JDBC catalog no longer creates paimon_table_properties.

Documentation

No.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I ran all 86 JdbcCatalogTest cases on JDK 8 and exercised the public catalog factory against MySQL 8.0.43 with utf8mb4. With sync disabled, catalog creation, table creation and ALTER, and a committed write/read round trip succeed without paimon_table_properties. Precreating the table with shorter key columns also lets the same catalog reopen with sync enabled and persist an altered option.

}
});
// Check and create table properties table. It is only used to sync table properties.
if (syncTableProperties()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Document the MySQL setup requirement in the JDBC catalog guide. On a fresh MySQL 8.0.43 database using utf8mb4, the CREATE CATALOG example in the JDBC catalog guide still stops at InnoDB error 1071 with the default options. The working configuration introduced here is currently discoverable only after inspecting the nested exception. Please document when to set sync-all-properties=false, what that means for syncing table properties, and how users who need sync can precreate a compatible table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for testing it on MySQL. I added a "MySQL with utf8mb4" section to the JDBC catalog guide. It explains why the catalog fails with the default options, when to set sync-all-properties to false and what that changes (the table is neither created nor written; table options stay in the schema files), and gives a CREATE TABLE with shorter catalog_key and property_key columns for users who need the sync, with the resulting length limits. I checked both setups on MySQL 8.0.46 with utf8mb4.

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.

[Bug] JDBC catalog cannot be created on MySQL with utf8mb4: paimon_table_properties primary key is too long

2 participants