InnoDB Table - Instant Add Column taking a long time
I've a MySQL table, which I'm having trouble to add a column using instant algorithm. There is no error when I run the DDL, but it runs forever.
Type: InnoDB
MySQL Version: 8.0.35 (Hosted on OVH MySQL managed services)
Table Size: 95GB (None partitioned)
Full text indexes: None
Schema: Note that I've masked client data with xxxx
CREATE TABLE `xxxx` (
`column1` binary(16) NOT NULL,
`column2` binary(16) NOT NULL,
`column3` binary(16) NOT NULL,
`column1_type` binary(16) DEFAULT NULL,
`column4` binary(16) NOT NULL,
`column5` int NOT NULL,
`column6` int NOT NULL DEFAULT '0',
`column7` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`column8` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`column9` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`column1`),
UNIQUE KEY `xxxxx_column7` (`column3`,`column7`),
KEY `idx_xxxx_xxxx` (`column2`),
KEY `idx_xxxx_xxxxx` (`column4`),
KEY `idx_xxxx_xxxxxx` (`column7`),
KEY `idx_xxxx_xxxxxxx` (`column8`,`column1_type`,`column4`,`column5`),
KEY `idx_xxxx_column1type_column4_column3_column7` (`column1_type`,`column4`,`column3`,`column7`),
KEY `idx_xxxx_column1_type_column7` (`column1_type`,`column7`) USING BTREE,
CONSTRAINT `xxxx xxxxxx` FOREIGN KEY (`column3`) REFERENCES `bbbb` (`column3`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `xxxx xxxxxx` FOREIGN KEY (`column2`) REFERENCES `aaaaa` (`column2`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `xxxxx column1_type` FOREIGN KEY (`column1_type`) REFERENCES `yyyyy_type` (`column1_type`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `xxxx xxxx` FOREIGN KEY (`column4`) REFERENCES `zzzz` (`column4`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Other settings:
"Engine" : "InnoDB",
"Version" : 10,
"Row_format" : "Dynamic",
"Rows" : 159,829,897,
"Avg_row_length" : 165,
"Data_length" : 26444595200,
"Max_data_length" : 0,
"Index_length" : 76576980992,
"Data_free" : 4194304,
"Auto_increment" : null,
"Check_time" : null,
"Collation" : "utf8mb4_unicode_ci",
"Checksum" : null,
"Create_options" : "",
"Comment" : ""
Versions: 0 (So there are more opportunities to run instant DDL)
The whole MySQL instance has a replica (Through OVH high availability)
DDL command trying to run:
ALTER TABLE xxxx ADD COLUMN createdon_utc DATETIME, ALGORITHM=INSTANT;
Outcome:
1. No errors when executing. Tried with LOCK = EXCLUSIVE, LOCK = NONE etc. (Same)
2. SHOW FULL PROCESSLIST; shows Altering table, not waiting for locks, etc
3. Ran while all writes to the table were stopped (same behaviour)
4. Ran for over 10 - 15 minutes, and can see the database size growing (before stopping it)
5. I've tried with adding NULL as default - Same behaviour
I can't tune any OS level settings as it's in OVH hosting.
I cannot afford to run this on Copy algorithm that's trying to follow.
Anything I can do without causing any outage to add this column?
I'm able to add the same column on another copy of a locally installed DB, but with 20 GB-sized table. (Same schema, same settings)
Best Regards,
Roshan