ptupitsyn commented on code in PR #7844:
URL: https://github.com/apache/ignite-3/pull/7844#discussion_r3009697481
##########
modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientSql.java:
##########
@@ -377,6 +381,18 @@ public <T> CompletableFuture<AsyncResultSet<T>>
executeAsyncInternal(
tx.recordOperationFailure(err);
}
+ // We should reconcile this code with ClientTable. Should be
the same.
Review Comment:
Can we do that as part of current PR?
##########
modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientLazyTransaction.java:
##########
@@ -94,12 +100,30 @@ public void rollback() throws TransactionException {
public CompletableFuture<Void> rollbackAsync() {
var tx0 = tx;
+ // This is really fishy. It will probably let you reuse a transaction
after calling a rollback :(
Review Comment:
Good catch. Let's create a ticket to address this.
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/DirectTransactionWithFirstRequest.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.client.handler.requests.table;
+
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.internal.hlc.HybridTimestamp;
+import org.apache.ignite.internal.replicator.ZonePartitionId;
+import org.apache.ignite.internal.tx.InternalTransaction;
+import org.apache.ignite.internal.tx.PendingTxPartitionEnlistment;
+import org.apache.ignite.internal.tx.TxState;
+import org.apache.ignite.internal.wrapper.Wrapper;
+import org.apache.ignite.tx.TransactionException;
+import org.jetbrains.annotations.Nullable;
+
+class DirectTransactionWithFirstRequest implements InternalTransaction,
Wrapper {
+ private final InternalTransaction base;
+
+ // We could alos just accept a lambda.
Review Comment:
```suggestion
// We could also just accept a lambda.
```
##########
modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientLazyTransaction.java:
##########
@@ -94,12 +100,30 @@ public void rollback() throws TransactionException {
public CompletableFuture<Void> rollbackAsync() {
var tx0 = tx;
+ // This is really fishy. It will probably let you reuse a transaction
after calling a rollback :(
if (tx0 == null) {
// No operations were performed, nothing to rollback.
return nullCompletedFuture();
}
- return tx0.thenCompose(ClientTransaction::rollbackAsync);
+ // If the transaction is not started. Issue the rollback and wait for
the server response.
+ if (!tx0.isDone() && cancelled.compareAndSet(false, true)) {
+ return requestInfoFuture
+ .thenCompose(reqInfo ->
+ reqInfo.ch.serviceAsync(ClientOp.TX_ROLLBACK, w ->
w.out().packLong(-reqInfo.firstReqId), r -> null)
Review Comment:
Protocol compat: what will happen with an older server that does not
understand negative resource ids?
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientInboundMessageHandler.java:
##########
@@ -292,6 +293,25 @@ public class ClientInboundMessageHandler
private final HandshakeEventLoopSwitcher handshakeEventLoopSwitcher;
+ /**
+ * Tracks mappings between the first {@code requestId} and the {@code
resourceId}
+ * holding the Tx object for directly mapped transactions. The process is
not localized.
+ *
+ * <p><b>Mappings are created:</b>
+ * <ul>
+ * <li>When a direct transaction is created in {@link
ClientTableCommon#readTx(ClientMessageUnpacker, HybridTimestampTracker,
+ * ClientResourceRegistry, TxManager, IgniteTables,
NotificationSender, long[], long, Map)}.
+ * </li>
+ * </ul>
+ *
+ * <p><b>Mappings are removed:</b>
+ * <ul>
+ * <li>During a rollback request.</li>
+ * <li>After the first request response is sent to the client.</li>
Review Comment:
Is this still true?
--
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]