Updating task execution id next val to use sequence for sqlserver

resolves TASK-782

Updated PR to resolve issue when no task tables exist

Updated PR based on review comments.
This does not include updated tests.
This resolves a problem where task would fail because the incrementer selection occured before the tables were created.

Added unit test for SqlServerSequenceIncrementer

updated based on code review
This commit is contained in:
Glenn Renfro
2021-05-07 14:11:37 -04:00
committed by Glenn Renfro
parent 5d26173837
commit 17415eaed5
5 changed files with 162 additions and 19 deletions

View File

@@ -83,3 +83,16 @@ Used for the `single-instance-enabled` feature discussed <<features-single-insta
NOTE: The DDL for setting up tables for each database type can be found https://github.com/spring-cloud/spring-cloud-task/tree/master/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task[here].
--
=== SQL Server
By default Spring Cloud Task uses a sequence table for determining the `TASK_EXECUTION_ID` for the `TASK_EXECUTION` table.
However, when launching multiple tasks simultaneously while using SQL Server, this can cause a deadlock to occur on the `TASK_SEQ` table.
The resolution is to drop the `TASK_EXECUTION_SEQ` table and create a sequence using the same name. For example:
```
DROP TABLE TASK_SEQ;
CREATE SEQUENCE [DBO].[TASK_SEQ] AS BIGINT
START WITH 1
INCREMENT BY 1;
```
NOTE: Set the `START WITH` to a higher value than your current execution id.