`@ConcurrencyLimit` weird behavior when combined with `@Async` and `@Transactional`
I'm seeing some weird behavior when attempting to combine the 3 annotations from the subject, for example:
@Async @ConcurrencyLimit(1) @Transactional void doWork() throws Exception { logger.info("Starting work"); Thread.sleep(Duration.ofSeconds(10)); logger.info("Finished work"); }
On the first two invocations of such method, @ConcurrencyLimit doesn't appear to work, but from there on it starts working OK. Here's the log output I'm seeing after invoking the service 3 times after startup, with invocations being about a second apart:
2025-11-10T13:15:44.224+01:00 INFO 906182 --- [ task-1] com.example.SampleService : Starting work
2025-11-10T13:15:45.766+01:00 INFO 906182 --- [ task-2] com.example.SampleService : Starting work
2025-11-10T13:15:54.225+01:00 INFO 906182 --- [ task-1] com.example.SampleService : Finished work
2025-11-10T13:15:55.767+01:00 INFO 906182 --- [ task-2] com.example.SampleService : Finished work
2025-11-10T13:15:55.768+01:00 INFO 906182 --- [ task-3] com.example.SampleService : Starting work
2025-11-10T13:16:05.769+01:00 INFO 906182 --- [ task-3] com.example.SampleService : Finished work
Removing @Transactional from the mix makes everything work as expected. I'll attach a reproducer shortly.