AMashenkov commented on code in PR #2811:
URL: https://github.com/apache/ignite-3/pull/2811#discussion_r1386495981
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/api/SessionImpl.java:
##########
@@ -274,33 +294,59 @@ public CompletableFuture<long[]>
executeBatchAsync(@Nullable Transaction transac
touchAndCloseIfExpired();
if (!busyLock.enterBusy()) {
- return CompletableFuture.failedFuture(new
SqlException(SESSION_CLOSED_ERR, "Session is closed."));
+ return CompletableFuture.failedFuture(sessionIsClosedException());
}
try {
- QueryContext ctx = QueryContext.create(Set.of(SqlQueryType.DML),
transaction);
+ SqlProperties properties = SqlPropertiesHelper.newBuilder()
+ .set(QueryProperty.ALLOWED_QUERY_TYPES,
EnumSet.of(SqlQueryType.DML))
+ .build();
var counters = new LongArrayList(batch.size());
- CompletableFuture<Void> tail =
CompletableFuture.completedFuture(null);
- ArrayList<CompletableFuture<Void>> batchFuts = new
ArrayList<>(batch.size());
+ CompletableFuture<?> tail =
CompletableFuture.completedFuture(null);
+ ArrayList<CompletableFuture<?>> batchFuts = new
ArrayList<>(batch.size());
for (int i = 0; i < batch.size(); ++i) {
Object[] args = batch.get(i).toArray();
- final var qryFut = tail
- .thenCompose(v -> qryProc.querySingleAsync(sessionId,
ctx, transactions, query, args));
-
- tail = qryFut.thenCompose(cur -> cur.requestNextAsync(1))
- .thenAccept(page -> {
- validateDmlResult(page);
-
- counters.add((long) page.items().get(0).get(0));
- })
- .whenComplete((v, ex) -> {
- if (ExceptionUtils.unwrapCause(ex) instanceof
CancellationException) {
- qryFut.cancel(false);
- }
- });
+ tail = tail.thenCompose(v -> {
+ if (!busyLock.enterBusy()) {
+ return
CompletableFuture.failedFuture(sessionIsClosedException());
+ }
+
+ try {
+ return qryProc.querySingleAsync(properties,
transactions, (InternalTransaction) transaction, query, args)
+ .thenCompose(cursor -> {
+ if (!busyLock.enterBusy()) {
+ return
CompletableFuture.failedFuture(sessionIsClosedException());
Review Comment:
Should we close cursor here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]