-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Bug Report
Versions
- Driver: 0.8.4.RELEASE
- SPI: 0.9.0.M1
- Database: 1.4.200
- Java: openjdk version "11.0.9.1" 2020-11-04
- OS: Microsoft Windows [Version 10.0.19042.867]
Current Behavior
The current implementation of r2dbc-h2 does not execute batches completely if clients don't consume (request?) all the results. In my opinion, a batch is an atomic unit of work, irrespective of whether all update counts are consumed, and must be executed atomically by the server.
Steps to reproduce
Run this code
ConnectionFactory connectionFactory = ConnectionFactories.get(
ConnectionFactoryOptions
.parse("r2dbc:h2:file://localhost/~/x")
.mutate()
.option(ConnectionFactoryOptions.USER, "sa")
.option(ConnectionFactoryOptions.PASSWORD, "")
.build()
);
Flux.from(connectionFactory.create())
.flatMap(c -> c.createStatement("create table t (i int)").execute())
.collectList()
.block();
try {
System.out.println((
Flux.from(connectionFactory.create())
.flatMap(c -> c.createBatch().add("insert into t values (1)").add("insert into t values (2)").execute())
.flatMap(t -> t.getRowsUpdated())
.blockFirst()
));
System.out.println(
Flux.from(connectionFactory.create())
.flatMap(c -> c.createStatement("select * from t").execute())
.flatMap(it -> it.map((r, m) -> r.get(0)))
.collectList()
.block()
);
}
finally {
Flux.from(connectionFactory.create())
.flatMap(c -> c.createStatement("drop table t").execute())
.collectList()
.block();
}
The output is:
1
[1]
As can be seen, the second value 2
is never inserted.
Expected behavior/code
The output in r2dbc-postgresql is the expected one:
1
[1, 2]
Only one update count is consumed as requested, but two insertions are made
Metadata
Metadata
Assignees
Labels
No labels