我在grails 2.4.4中使用spring batch 3.0.3.RELEASE
我执行下面的代码时发现异常。
"当@@ GLOBAL.ENFORCE_GTID_CONSISTENCY = 1时,非事务性表的更新只能在自动提交的语句或单语句事务中完成,并且永远不会在与事务表的更新相同的语句中完成。&# 34;
代码是
List<Flow> flowList = Lists.newArrayList()
Shop.findAllByCityIdAndTypeAndStatus(cityId, 1 as byte, 1 as byte).each {
Shop stationShop ->
TaskletStep taskletStep = stepBuilderFactory.get("copy_city_item_to_station").tasklet(new Tasklet() {
@Override
RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
copyCityItemToStationItem(item, stationShop)
return RepeatStatus.FINISHED
}
}).build()
Flow flow = new FlowBuilder<Flow>("subflow").from(taskletStep).end();
flowList.add(flow)
}
Flow splitFlow = new FlowBuilder<Flow>("split_city_item_to_station").split(eventTaskExecutor).add(flowList.toArray(new Flow[0])).build();
FlowJobBuilder builder = jobBuilderFactory.get("push_item_to_all_station").start(splitFlow).end();
Job job = builder.preventRestart().build()
jobLauncher.run(job, new JobParametersBuilder().addLong("city.item.id", item.id).toJobParameters())
google说问题可能存在于&#34; https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-restrictions.html&#34;,所以我将所有的ENGINE表格MyISAM替换为文件&#39; schema-mysql.sql&#39;中的InnoDB,它有效。
现在我想知道我做了什么是对的,我的方式是否存在潜在的错误?
答案 0 :(得分:2)
你所做的是正确的。这是Spring Batch为MySql生成的SQL文件中的一个错误。我在Jira中创建了一个问题,您可以在此处关注:https://jira.spring.io/browse/BATCH-2373。