You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
ConnectionFactoryconnectionFactory = 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
The text was updated successfully, but these errors were encountered:
Bug Report
Versions
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
The output is:
As can be seen, the second value
2
is never inserted.Expected behavior/code
The output in r2dbc-postgresql is the expected one:
Only one update count is consumed as requested, but two insertions are made
The text was updated successfully, but these errors were encountered: