Risk alert: InnoDB compressed tables with KEY_BLOCK_SIZE less than 4 KB may cause data corruption
Issue description
PolarDB for MySQL uses a proprietary distributed file system whose minimum atomic write unit is 4 KB. When InnoDB compressed tables (ROW_FORMAT=COMPRESSED) use a KEY_BLOCK_SIZE less than 4 KB (that is, 1 KB or 2 KB), the mismatch between the compressed block size and the underlying atomic write unit may cause data corruption. To avoid data loss, check your table configurations and take the recommended actions described in this topic.
Affected versions
Database engine version | Affected revision versions |
PolarDB for MySQL 5.6 | ≤ 5.6.1.0.46.1 |
PolarDB for MySQL 5.7 | ≤ 5.7.1.0.40 |
PolarDB for MySQL 8.0.1 | ≤ 8.0.1.1.53 |
PolarDB for MySQL 8.0.2 | ≤ 8.0.2.2.33 |
You can check your current database engine version in the page of the PolarDB for MySQL cluster in the console.
Solution
Check whether your cluster has any affected compressed tables.
Run one of the following SQL queries based on your database engine version to identify InnoDB compressed tables with
KEY_BLOCK_SIZEless than 4 KB:For PolarDB for MySQL 5.6 and 5.7:
SELECT * FROM information_schema.innodb_sys_tables WHERE ROW_FORMAT = 'Compressed' AND ZIP_PAGE_SIZE < 4096;For PolarDB for MySQL 8.0.1 and 8.0.2:
SELECT * FROM information_schema.innodb_tables WHERE ROW_FORMAT = 'Compressed' AND ZIP_PAGE_SIZE < 4096;
If the query returns any results, your cluster has affected tables. Submit a ticket for assistance with the affected tables. If the query returns no results, we still recommend upgrading your cluster to a fixed version for automatic protection.
WarningOn affected versions, do not create compressed tables with KEY_BLOCK_SIZE less than 4 KB. If you need to use compressed tables, make sure that KEY_BLOCK_SIZE is set to 4 or greater.
Upgrade the database to a fixed engine version.
WarningUpgrading the database engine version may cause a brief connection interruption. We recommend that you perform this operation during off-peak hours.
Upgrade the database engine to a version later than the affected versions listed in the preceding table. For more information, see Revision version management.
After the upgrade, configure a policy to prevent creation of incompatible compressed tables. Fixed versions introduce the
polar_compressed_table_policyparameter, which controls how the system handles the creation of compressed tables. The following policies are available:Policy
Behavior
NATIVE
Executes the statement as-is without intervention. Not recommended due to the risk of data corruption.
ADJUST_KEY_BLOCK_SIZE
Default policy. Allows compressed table creation but automatically adjusts
KEY_BLOCK_SIZEto 4 if the specified value is less than 4.AUTO_CONVERT_ROW_FORMAT
Silently converts the table to the default row format instead of creating a compressed table.
REJECTED
Rejects the compressed table creation and returns an error.
NoteWe recommend setting
polar_compressed_table_policytoADJUST_KEY_BLOCK_SIZE(default),AUTO_CONVERT_ROW_FORMAT, orREJECTEDto prevent accidental data corruption.