mysql - innodb中复合主键的表是否支持组复制

标签 mysql innodb mysql-group-replication

我有一个包含两列 col1、col2 的表,它们是复合主键。请问,该表支持 MySQL InnoDB 集群中的组复制吗?

错误消息:

org.springframework.jdbc.UncategorizedSQLException: Hibernate flushing: Could not execute JDBC batch update; uncategorized SQLException for SQL [/* insert collection row com.domain.BatchClass.documentTypes */ insert into batch_class_document_type (batch_class_id, document_type_id) values (?, ?)]; SQL state [HY000]; error code [3098]; The table does not comply with the requirements by an external plugin.; nested exception is

显示创建表:

CREATE TABLE `batch_class_document_type` (
    `batch_class_id` bigint(20) NOT NULL, 
    `document_type_id` bigint(20) NOT NULL, 
    PRIMARY KEY (`batch_class_id`,`document_type_id`), 
    KEY `FKB72AFCD2997AC796` (`document_type_id`), 
    KEY `FKB72AFCD2C473EFCA` (`batch_class_id`), 
    CONSTRAINT `FKB72AFCD2997AC796` FOREIGN KEY (`document_type_id`)
                 REFERENCES `document_type` (`id`), 
    CONSTRAINT `FKB72AFCD2C473EFCA` FOREIGN KEY (`batch_class_id`)
                 REFERENCES `batch_class` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

最佳答案

您在更新时出错,而不是在创建表时出错,对吧?

insert into batch_class_document_type (batch_class_id, document_type_id) values (?, ?)

我的猜测是,您正在以多主模式运行您的组,如下所述:

https://dev.mysql.com/doc/refman/5.7/en/group-replication-deploying-in-multi-primary-or-single-primary-mode.html

If a transaction executes against a table that has foreign keys with cascading constraints, then the transaction fails to commit when synchronizing itself with the group.

您已达到此限制。我的建议是尝试在单主模式下运行它。

关于mysql - innodb中复合主键的表是否支持组复制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54684176/

相关文章:

mysql - 如何通过代码生成新的主键ID?

php - 根据另一个选择填充选择

mysql - 如何在非阻塞环境中修复此 MySQL/Innodb 死锁问题?

mysql - 导入 MySQL 转储文件时如何覆盖 ENGINE=INNODB 参数?

mysql - Laravel 和 MySQL 组复制

php - 使用 mysqli 检索数组

php - 从表中选择,其中列是 PHP 中的外键

mysql - 为什么即使整个数据都在缓冲池中,InnoDB 在全表扫描上却如此缓慢?

mysql - 我们可以在 mysql 组复制中使用 REPEATABLE-READ 隔离级别吗?