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

Reactive Oracle client fails session propagation test #24501

Closed
jsmrcka opened this issue Mar 23, 2022 · 3 comments
Closed

Reactive Oracle client fails session propagation test #24501

jsmrcka opened this issue Mar 23, 2022 · 3 comments
Assignees
Labels
area/vertx kind/bug Something isn't working

Comments

@jsmrcka
Copy link
Contributor

jsmrcka commented Mar 23, 2022

Describe the bug

In our test suite, we run a test:

    @Test
    @Order(4)
    public void ensureSessionIsPropagatedOnReactiveTransactions() {
        getApp().given()
                .contentType(ContentType.JSON)
                .post("hibernate/books/pablo/suntzu")
                .then()
                .body(is(""))
                .statusCode(HttpStatus.SC_CREATED);
    }

(https://github.com/jsmrcka/quarkus-test-suite/blob/6a659826bd8fd4c7dfdc21d398d063fdb32527f3/sql-db/hibernate-reactive/src/test/java/io/quarkus/ts/reactive/AbstractReactiveDatabaseIT.java#L66)

which calls an endpoint:

@Path("/hibernate")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class GroundedEndpoint {

    Mutiny.SessionFactory factory;

    ...

    @POST
    @Path("books/{authorName}/{name}")
    public Uni<Response> createBook(String authorName, String name) {
        return factory.withTransaction((session, transaction) -> {
            Author author = new Author();
            author.setName(authorName);
            return session.persist(author)
                    .map(nothing -> session.getReference(author).getId())
                    .map(authorId -> {
                        Book book = new Book();
                        book.setAuthor(authorId);
                        book.setTitle(name);
                        return book;
                    })
                    .flatMap(session::persist);
        })
                .map(nothing -> Response.status(Response.Status.CREATED))
                .onFailure().recoverWithItem(error -> Response.status(Response.Status.BAD_REQUEST).entity(error.getMessage()))
                .map(Response.ResponseBuilder::build);
    }
}

(https://github.com/jsmrcka/quarkus-test-suite/blob/6a659826bd8fd4c7dfdc21d398d063fdb32527f3/sql-db/hibernate-reactive/src/main/java/io/quarkus/ts/reactive/http/GroundedEndpoint.java#L83)

The module (see reproducer) is configured to run against various DBs using reactive clients (quarkus-reactive-oracle-client, quarkus-reactive-pg-client, ...) and Hibernate Reactive (quarkus-hibernate-reactive, quarkus-hibernate-reactive-panache).

It fails on aforementioned test using Oracle, while it passes for other DBs.

There is some sort of isolation issue, because the failure only occurs in the specific setup shown in the reproducer branch. The test must be run in combination with other tests in the scenario and in a specific order. When executed in isolation, the test passes.

I tried several 2.7.* versions, the reproducer fails with all of them: 2.7.5.Final, 2.7.3.Final, 2.7.0.Final.

Expected behavior

Test should pass like in case of other DBs.

Actual behavior

Test fails using Oracle DB with following error:

[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 78.008 s <<< FAILURE! - in io.quarkus.ts.reactive.OracleDatabaseIT
[ERROR] ensureSessionIsPropagatedOnReactiveTransactions  Time elapsed: 1.107 s  <<< FAILURE!
java.lang.AssertionError: 
1 expectation failed.
Response body doesn't match expectation.
Expected: is ""
  Actual: Multiple exceptions caught:
	[Exception 0] io.vertx.core.VertxException: Error : 1453, Position : 0, Sql = SET TRANSACTION ISOLATION LEVEL READ COMMITTED, OriginalSql = SET TRANSACTION ISOLATION LEVEL READ COMMITTED, Error Msg = ORA-01453: SET TRANSACTION must be first statement of transaction

	[Exception 1] java.lang.NullPointerException

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72)
	at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:59)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)
	at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:493)
	at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure$validate$1.call(Unknown Source)
	at io.restassured.internal.ResponseSpecificationImpl.validateResponseIfRequired(ResponseSpecificationImpl.groovy:674)
        ...

How to Reproduce?

git clone git@github.com:jsmrcka/quarkus-test-suite.git
cd ./quarkus-test-suite
git checkout QUARKUS-1407-hibernate-reactive

Failure on Oracle:

mvn clean verify -pl sql-db/hibernate-reactive -Dinclude.tests=OracleDatabaseIT

Pass on another DB

mvn clean verify -pl sql-db/hibernate-reactive -Dinclude.tests=Postgresql13DatabaseIT

Output of uname -a or ver

Linux 5.15.6-200.fc35.x86_64

Output of java -version

openjdk version "11.0.14" 2022-01-18 OpenJDK Runtime Environment Temurin-11.0.14+9 (build 11.0.14+9) OpenJDK 64-Bit Server VM Temurin-11.0.14+9 (build 11.0.14+9, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.5.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.3

Additional information

No response

@jsmrcka
Copy link
Contributor Author

jsmrcka commented Mar 31, 2022

@Sanne @tsegismont
Bringing this to your attention, in case you have any idea.

@tsegismont
Copy link
Contributor

@jsmrcka most probably related to eclipse-vertx/vertx-sql-client#1169

A fix is in preparation and we hope to be able to upgrade Vert.x to 4.2.7 in Quarkus soon after the release

@jsmrcka
Copy link
Contributor Author

jsmrcka commented Jun 30, 2022

Fixed in eclipse-vertx/vertx-sql-client#1170.
Brought into Quarkus in #24937.
Verified on 2.10.0.Final.

@jsmrcka jsmrcka closed this as completed Jun 30, 2022
jsmrcka added a commit to jsmrcka/quarkus-test-suite that referenced this issue Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertx kind/bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

4 participants