spring-cloud-task icon indicating copy to clipboard operation
spring-cloud-task copied to clipboard

Improve replication friendliness of the MySQL schema

Open hpoettker opened this issue 3 years ago • 0 comments

Status quo

The tables TASK_EXECUTION_PARAMS and TASK_TASK_BATCH currently do not have primary keys.

For a single node MySQL deployment, this does not cause any issue. For a setup of multiple nodes with replication, this is however not ideal as it causes performance problems with row-based replication and leads to ambiguity when calculating check sums over tables to validate the integrity of the replication.

To prevent such issues, MySQL 8 offers the system variable sql_require_primary_key. If set to ON, it is currently not possible to deploy the Spring Cloud Task schema.

I've opened an analogous issue for Spring Batch: spring-projects/spring-batch#4146.

Suggestion

It would be nice if primary keys were defined on TASK_EXECUTION_PARAMS and TASK_TASK_BATCH in the MySQL schema, e.g.

  • on TASK_EXECUTION_ID and TASK_PARAM for TASK_EXECUTION_PARAMS,
  • on JOB_EXECUTION_ID for TASK_TASK_BATCH (uniqueness of job execution ids implied by code in JdbcTaskExecutionDao).

The table TASK_SEQ also has no primary key. As it contains only a single row, this is not a problem in practice. But if the column UNIQUE_KEY were to be declared as primary key, this would allow a seamless deployment to a MySQL instance with sql_require_primary_key=ON.

hpoettker avatar Jul 07 '22 00:07 hpoettker