Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MySQLIdentityColumnMaxValueIncrementer #31784

Merged
merged 1 commit into from Dec 8, 2023

Conversation

hpoettker
Copy link
Contributor

The PR adds MySQLIdentityColumnMaxValueIncrementer to resolve #18989.

Using a MySQL auto-increment column as a sequence with AbstractIdentityColumnMaxValueIncrementer was not practical before MySQL 8 as the auto-increment counter was only stored in memory but not persisted. With MySQL 8.0 and InnoDB, this behavior has changed: https://dev.mysql.com/doc/refman/8.0/en/innodb-auto-increment-handling.html#innodb-auto-increment-initialization

With MySQL 8 and InnoDB, the new incrementer can be used safely in a setup with active-active replication. If the database parameters auto_increment_increment and auto_increment_offset are configured appropriately, the incrementer will not produce duplicate ids even if different database instances are queried.

I've assembled a toy setup with a multi-threaded test against two MySQL instances with active-active replication here: https://github.com/hpoettker/mysql-incrementer-demo

The new `DataFieldMaxValueIncrementer` can be used with identity columns in MySQL 8.0 or later.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 7, 2023
@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 7, 2023
@jhoeller jhoeller self-assigned this Dec 7, 2023
@jhoeller jhoeller added this to the 6.1.2 milestone Dec 7, 2023
@jhoeller jhoeller merged commit b3a3b79 into spring-projects:main Dec 8, 2023
5 checks passed
@hpoettker hpoettker deleted the mysql-incrementer branch December 8, 2023 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MySQLMaxValueIncrementer is not multi-master replication-safe [SPR-14418]
3 participants