更改 Spring 批处理控制 Table 锁定策略
Change Spring Batch Control Table Locking Strategy
我们有一个系统允许操作员停止长 运行 Spring 批处理作业,方法是使用 JobExplorer
获取对 JobExecution
的引用并调用stop()
就可以了。然后,我们的作业中有代码使用 JobExplorer
获取 JobExecution
的最新副本,以检查它是否已被标记为 STOPPING。
我们的问题是 Microsoft SQL Server 2016 中元数据表的死锁。每个 select 都在进行共享页面锁定。我能够找到的关于更改锁定级别的所有内容都与在 SELECT
语句上使用提示有关。但是 Spring Batch 正在创建语句,而不是我们的代码。
有没有办法告诉 Spring Batch 在创建 SELECT
语句时使用只读并发?如果没有,是否有一些机制可以编写我们自己的 JobExplorer
来完成此任务?
stop a long running Spring Batch job by using the JobExplorer to get a reference to the JobExecution and calling stop() on it.
JobExecution#stop
将在下一个次要版本 4.3 中弃用并在下一个主要版本中删除(参见 https://github.com/spring-projects/spring-batch/issues/1605)。停止作业执行的正确方法是使用 JobOperator#stop
。
Is there a way to tell Spring Batch to use read-only concurrency when making SELECT statements? If not, is there some mechanism short of writing our own JobExplorer to accomplish this?
将作业浏览器设置为事务性(只读)存在未决问题:https://github.com/spring-projects/spring-batch/issues/1307。同时,您可以使 SimpleJobExplorer
具有事务性(通过 AOP 或扩展它以在方法上添加 @Transactional(readOnly = true)
)。
我们有一个系统允许操作员停止长 运行 Spring 批处理作业,方法是使用 JobExplorer
获取对 JobExecution
的引用并调用stop()
就可以了。然后,我们的作业中有代码使用 JobExplorer
获取 JobExecution
的最新副本,以检查它是否已被标记为 STOPPING。
我们的问题是 Microsoft SQL Server 2016 中元数据表的死锁。每个 select 都在进行共享页面锁定。我能够找到的关于更改锁定级别的所有内容都与在 SELECT
语句上使用提示有关。但是 Spring Batch 正在创建语句,而不是我们的代码。
有没有办法告诉 Spring Batch 在创建 SELECT
语句时使用只读并发?如果没有,是否有一些机制可以编写我们自己的 JobExplorer
来完成此任务?
stop a long running Spring Batch job by using the JobExplorer to get a reference to the JobExecution and calling stop() on it.
JobExecution#stop
将在下一个次要版本 4.3 中弃用并在下一个主要版本中删除(参见 https://github.com/spring-projects/spring-batch/issues/1605)。停止作业执行的正确方法是使用 JobOperator#stop
。
Is there a way to tell Spring Batch to use read-only concurrency when making SELECT statements? If not, is there some mechanism short of writing our own JobExplorer to accomplish this?
将作业浏览器设置为事务性(只读)存在未决问题:https://github.com/spring-projects/spring-batch/issues/1307。同时,您可以使 SimpleJobExplorer
具有事务性(通过 AOP 或扩展它以在方法上添加 @Transactional(readOnly = true)
)。