ptupitsyn commented on code in PR #5383: URL: https://github.com/apache/ignite-3/pull/5383#discussion_r2020784912
########## modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientTransaction.java: ########## @@ -124,11 +256,26 @@ public CompletableFuture<Void> rollbackAsync() { return finishFut.get(); } - setState(STATE_ROLLED_BACK); + CompletableFuture<Void> mainFinishFut = ch.serviceAsync(ClientOp.TX_ROLLBACK, w -> { + w.out().packLong(id); + if (!isReadOnly) { + w.out().packInt(enlisted.size()); Review Comment: Same as above. ########## modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientTransaction.java: ########## @@ -98,15 +208,37 @@ public void commit() throws TransactionException { /** {@inheritDoc} */ @Override public CompletableFuture<Void> commitAsync() { - if (!finishFut.compareAndSet(null, new CompletableFuture<>())) { - return finishFut.get(); + enlistPartitionLock.writeLock().lock(); + + try { + if (!finishFut.compareAndSet(null, new CompletableFuture<>())) { + return finishFut.get(); + } + } finally { + enlistPartitionLock.writeLock().unlock(); } - setState(STATE_COMMITTED); + CompletableFuture<Void> mainFinishFut = ch.serviceAsync(ClientOp.TX_COMMIT, w -> { + w.out().packLong(id); + if (!isReadOnly) { Review Comment: Missing feature check. While this will work (the server ignores the tail of the message), I think it is cleaner to have the check in place. ########## modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordSerializer.java: ########## @@ -126,10 +134,11 @@ void writeRecs( @Nullable R rec2, ClientSchema schema, PayloadOutputChannel out, + WriteContext ctx, TuplePart part ) { - out.out().packInt(tableId); - writeTx(tx, out); + out.out().packInt(tableId); // TODO move to writeTx Review Comment: TODO without ticket. ########## modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientTransactions.java: ########## @@ -73,19 +78,35 @@ static CompletableFuture<ClientTransaction> beginAsync( w -> { w.out().packBoolean(readOnly); w.out().packLong(timeout); - w.out().packLong(observableTimestamp); + w.out().packLong(observableTimestamp.get().longValue()); + if (!readOnly) { + w.out().packInt(pm == null ? -1 : pm.tableId()); Review Comment: Missing feature check. ########## modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientTransactions.java: ########## @@ -73,19 +78,35 @@ static CompletableFuture<ClientTransaction> beginAsync( w -> { w.out().packBoolean(readOnly); w.out().packLong(timeout); - w.out().packLong(observableTimestamp); + w.out().packLong(observableTimestamp.get().longValue()); + if (!readOnly) { + w.out().packInt(pm == null ? -1 : pm.tableId()); + w.out().packInt(pm == null ? -1 : pm.partition()); + } }, - r -> readTx(r, readOnly), - preferredNodeName, + r -> readTx(r, readOnly, pm, observableTimestamp, timeout), + pm == null ? null : pm.nodeConsistentId(), + null, null, false); } - private static ClientTransaction readTx(PayloadInputChannel r, boolean isReadOnly) { + private static ClientTransaction readTx( + PayloadInputChannel r, + boolean isReadOnly, + @Nullable PartitionMapping pm, + HybridTimestampTracker tracker, + long timeout + ) { ClientMessageUnpacker in = r.in(); long id = in.unpackLong(); - - return new ClientTransaction(r.clientChannel(), id, isReadOnly); + if (isReadOnly) { // TODO we can split to client read/write txns. + return new ClientTransaction(r.clientChannel(), id, isReadOnly, EMPTY, null, EMPTY, null, timeout); + } else { + UUID txId = in.unpackUuid(); Review Comment: Missing feature check - this will fail on older servers. ########## modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientTransactions.java: ########## @@ -73,19 +78,35 @@ static CompletableFuture<ClientTransaction> beginAsync( w -> { w.out().packBoolean(readOnly); w.out().packLong(timeout); - w.out().packLong(observableTimestamp); + w.out().packLong(observableTimestamp.get().longValue()); + if (!readOnly) { + w.out().packInt(pm == null ? -1 : pm.tableId()); + w.out().packInt(pm == null ? -1 : pm.partition()); + } }, - r -> readTx(r, readOnly), - preferredNodeName, + r -> readTx(r, readOnly, pm, observableTimestamp, timeout), + pm == null ? null : pm.nodeConsistentId(), + null, null, false); } - private static ClientTransaction readTx(PayloadInputChannel r, boolean isReadOnly) { + private static ClientTransaction readTx( + PayloadInputChannel r, + boolean isReadOnly, + @Nullable PartitionMapping pm, + HybridTimestampTracker tracker, + long timeout + ) { ClientMessageUnpacker in = r.in(); long id = in.unpackLong(); - - return new ClientTransaction(r.clientChannel(), id, isReadOnly); + if (isReadOnly) { // TODO we can split to client read/write txns. Review Comment: TODO without ticket. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org