spring-cloud / spring-cloud/spring-cloud-task

Task doesn't use transaction manager on startup

Open
#438 1 comment 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

backport-2.0.x ready type: bug
Dominant language
Java
Stars
446
Forks
310
Avg merge
18h 18m
Merged PRs (30d)
6

Description

This could be intended behavior, but when an spring cloud task is starting up, it doesn't use the transaction manager when initializing the execution.

Take as an example spring-cloud-task-samples/multiple-datasources. If we change the secondDataSource to disable autocommit, the application will immediately fail on startup because the creation of the execution will be rolled back immediately. after creating it.

	@Bean
	public DataSource secondDataSource() throws SQLException {
		DataSource ds = new EmbeddedDatabaseBuilder()
				.setType(EmbeddedDatabaseType.H2)
				.build();
		SimpleDriverDataSource sdds = ds.unwrap(SimpleDriverDataSource.class);
		Properties properties = new Properties();
		properties.setProperty("autoCommit", "false");
		sdds.setConnectionProperties(properties);
		return ds;
	}

So either all the initialization code should get wrapped in transaction(s), or the documentation should be updated to reflect that you only support data sources with auto-commit set to true.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.