r2dbc-h2 icon indicating copy to clipboard operation
r2dbc-h2 copied to clipboard

Batch is broken in `0.9.1.RELEASE`

Open dstepanov opened this issue 2 years ago • 4 comments

Found a lot of tests failed when updating Micronaut Data to the latest version https://github.com/micronaut-projects/micronaut-data/pull/1385

The main problem is here https://github.com/r2dbc/r2dbc-h2/blob/main/src/main/java/io/r2dbc/h2/H2Statement.java#L102 I think the problem is that some of the bind methods like bind with index, bindNull don't set open = false.

dstepanov avatar Mar 18 '22 07:03 dstepanov

This also pops up in the jOOQ integration tests. Simple reproducer:

create table t (i int)

And then:

System.out.println(
    Flux.from(cf.create())
        .flatMap(c -> c.createStatement("insert into t values ($1)")
            .bind(0, 1).add()
            .bind(0, 2).execute())
        .flatMap(it -> it.getRowsUpdated())
        .collectList()
        .block()
    );
;

Exception:

Exception in thread "main" java.lang.IllegalArgumentException: No unfinished bindings!
	at io.r2dbc.h2.util.Assert.requireTrue(Assert.java:50)
	at io.r2dbc.h2.H2Statement.execute(H2Statement.java:102)
	at io.r2dbc.h2.H2Statement.execute(H2Statement.java:39)
	at org.jooq.testscripts.R2DBC.lambda$0(R2DBC.java:48)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:386)
	at org.jooq.test.setup.DatabaseSetup$1.lambda$2(DatabaseSetup.java:289)
	at org.jooq.impl.Internal$1.onNext(Internal.java:454)
	at reactor.core.publisher.StrictSubscriber.onNext(StrictSubscriber.java:89)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:127)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1815)
	at reactor.core.publisher.MonoSupplier.subscribe(MonoSupplier.java:61)
	at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
	at org.jooq.test.setup.DatabaseSetup$1.lambda$0(DatabaseSetup.java:285)
	at reactor.core.publisher.FluxSource.subscribe(FluxSource.java:66)
	at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
	at reactor.core.publisher.Mono.block(Mono.java:1702)
	at org.jooq.testscripts.R2DBC.main(R2DBC.java:51)
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
		at reactor.core.publisher.Mono.block(Mono.java:1703)
		... 1 more

An attempted fix is here: https://github.com/r2dbc/r2dbc-h2/pull/229

lukaseder avatar Apr 28 '22 08:04 lukaseder

@lukaseder Does #229 fix this issue?

gregturn avatar Jun 24 '22 19:06 gregturn

@gregturn I think it should be safe to assume it fixes @lukaseder's issue, since he raised the PR?

As to the original issue with the micronaut-data tests, the fix was done with the same identified root cause, so seems likely.

Still hoping to get a 0.9.2.RELEASE and/or Borca-SR2 with this included, as it's still not possible to use the 0.9/Borca release train (or later) with H2 due to this issue.

chadlwilson avatar Jun 25 '22 08:06 chadlwilson

@gregturn My PR did, at the time, I think? I'm sorry, I have a lot on my plate, can't prioritise building the next snapshot of this for another test spin right now. If you don't hear from me (via new issues), then you can assume things are fine :)

lukaseder avatar Jun 27 '22 07:06 lukaseder

Looking into the 1.0.0.RELEASE upgrade now, and I can confirm that this issue seems to have been fixed.

lukaseder avatar Jan 11 '23 12:01 lukaseder

It’s fixed for me too

dstepanov avatar Jan 11 '23 13:01 dstepanov