Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction propagation breaks when io.micrometer#context-propagation added to classpath #2835

Open
turneand opened this issue Mar 11, 2024 · 0 comments
Labels
type: bug Something isn't working

Comments

@turneand
Copy link

Expected Behavior

When io.micrometer#context-propagation is added to the classpath, transaction propagation should still work. As this is frequently referenced as how we need to support context propagation (for example sharing MDC, OTEL, etc)

Actual Behaviour

For a simple new application connecting to a postgres testcontainer, when context-propagation is NOT added, then the simple test case listed below works. However, if io.micrometer#context-propagation is added, then we get an error as it is unable to lookup a transaction:

Rolling back transaction on error: Expected an existing transaction, but none was found in the Reactive context.
io.micronaut.transaction.exceptions.NoTransactionException: Expected an existing transaction, but none was found in the Reactive context.
        at io.micronaut.transaction.support.AbstractReactorTransactionOperations.expectedTransaction(AbstractReactorTransactionOperations.java

Steps To Reproduce

New project created via the launcher, with "data-r2dbc" and "postgres" added.
Create a controller with "@Transation" annotation, that calls a service with "@transaction(MANDATORY)" that simply returns an explicit Mono

  @Controller
  public static class SimpleController {
    @Inject MyService service;

    @Get("/hello")
	@Transactional
    public Publisher<String> hello() {
	  return service.getMessage();
    }
  }

  @Singleton
  public static class MyService {
    @Transactional(Transactional.TxType.MANDATORY)
	public Mono<String> getMessage() {
	  return Mono.just("hello");
    }
  }

Hit the /hello endpoint, and you get the server exception listed above.

Environment Information

Windows/Unix

Example Application

https://github.com/turneand/micronaut-transactional-propagation/blob/main/src/main/java/com/example/Application.java

Version

4.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants