Skip to content

MariaDB 6.0 migration fails when renaming BATCH_JOB_SEQ #5586

Closed

Description

@ahrytsiuk

Bug description
The MariaDB migration script for upgrading from Spring Batch 5.2 to 6.0 uses the unsupported RENAME SEQUENCE statement:

RENAME SEQUENCE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ;

MariaDB requires RENAME TABLE to rename a sequence. As a result, the migration fails with an SQL syntax error before BATCH_JOB_SEQ can be renamed.

Environment

  • Spring Batch: 6.0 migration script
  • Source schema: Spring Batch 5.2
  • Database: MariaDB 11.8.2
  • MariaDB JDBC driver

Steps to reproduce

  1. Start a MariaDB instance.
  2. Initialize the database with the Spring Batch 5.2 schema.
  3. Run org/springframework/batch/core/migration/6.0/migration-mariadb.sql.
  4. Observe that the migration fails.
org.opentest4j.AssertionFailedError: Unexpected exception thrown: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of file [.../org/springframework/batch/core/migration/6.0/migration-mariadb.sql]: RENAME SEQUENCE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ

	at org.junit.jupiter.api.Assertions.assertDoesNotThrow(Assertions.java:3306)
	at org.springframework.batch.core.repository.migration.MariaDbMigrationScriptIntegrationTests.migrationScriptShouldBeValid(MariaDbMigrationScriptIntegrationTests.java:51)
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of file [.../org/springframework/batch/core/migration/6.0/migration-mariadb.sql]: RENAME SEQUENCE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ
	at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:293)
	at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254)
	at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:54)
	at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.execute(ResourceDatabasePopulator.java:269)
	at org.springframework.batch.core.repository.migration.MariaDbMigrationScriptIntegrationTests.lambda$migrationScriptShouldBeValid$0(MariaDbMigrationScriptIntegrationTests.java:51)
	at org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:52)
	at org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:39)
	... 2 more
Caused by: java.sql.SQLSyntaxErrorException: (conn=4) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SEQUENCE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ' at line 1
	at org.mariadb.jdbc.export.ExceptionFactory.createException(ExceptionFactory.java:308)
	at org.mariadb.jdbc.export.ExceptionFactory.create(ExceptionFactory.java:402)
	at org.mariadb.jdbc.message.ClientMessage.readPacket(ClientMessage.java:196)
	at org.mariadb.jdbc.client.impl.StandardClient.readPacket(StandardClient.java:1524)
	at org.mariadb.jdbc.client.impl.StandardClient.readResults(StandardClient.java:1463)
	at org.mariadb.jdbc.client.impl.StandardClient.readResponse(StandardClient.java:1382)
	at org.mariadb.jdbc.client.impl.StandardClient.execute(StandardClient.java:1306)
	at org.mariadb.jdbc.Statement.executeInternal(Statement.java:1003)
	at org.mariadb.jdbc.Statement.execute(Statement.java:1132)
	at org.mariadb.jdbc.Statement.execute(Statement.java:471)
	at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:261)
	... 8 more

Expected behavior
The migration script should complete successfully and rename BATCH_JOB_SEQ to BATCH_JOB_INSTANCE_SEQ.
For MariaDB, the sequence should be renamed with:

RENAME TABLE BATCH_JOB_SEQ TO BATCH_JOB_INSTANCE_SEQ;

See: Table Operations that Work with Sequences

Minimal Complete Reproducible example
minimal complete verifiable example.

Activity

  1. added
    status: waiting-for-triage
    on Oct 12, 2026
  2. added
    for: backport-to-6.0.x
    and removed
    status: waiting-for-triage
    on Oct 15, 2026
  3. added this to the 6.1.0-RC1 milestone on Oct 15, 2026
  4. added a commit that references this issue on Oct 15, 2026
    fa3d1b6
  5. added a commit that references this issue on Oct 15, 2026
    5e44618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: backport-to-6.0.xin: corerelated-to: ddl-scriptstype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions