ivanzlenko commented on code in PR #7500: URL: https://github.com/apache/ignite-3/pull/7500#discussion_r2753141060
########## modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/network/command/UpdateCommandBase.java: ########## @@ -0,0 +1,37 @@ +/* + * 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.internal.partition.replicator.network.command; + +import java.util.UUID; +import org.apache.ignite.internal.hlc.HybridTimestamp; +import org.apache.ignite.internal.network.annotations.PropertyName; +import org.apache.ignite.internal.replicator.message.ReplicationGroupIdMessage; +import org.jetbrains.annotations.Nullable; + +/** + * Base for commands executing updates to the storage. + */ +public interface UpdateCommandBase extends PartitionCommand { + @PropertyName("tablePartitionId") + ReplicationGroupIdMessage commitPartitionId(); + + UUID txCoordinatorId(); Review Comment: Could you add javaDoc on this field? ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/TablePartitionProcessor.java: ########## @@ -378,12 +364,43 @@ private CommandResult handleUpdateAllCommand( advanceLastAppliedIndexConsistently(commandIndex, commandTerm); } - replicaTouch(txId, cmd.txCoordinatorId(), cmd.full() ? safeTimestamp : null, cmd.full()); + replicaTouch(txId, cmd.txCoordinatorId(), cmd.full()); - return new CommandResult( - new UpdateCommandResult(true, isPrimaryInGroupTopology(storageLeaseInfo), safeTimestamp.longValue()), - true + UpdateCommandResult result = new UpdateCommandResult( + true, + isPrimaryInGroupTopology(storageLeaseInfo), + safeTimestamp.longValue(), + failedCompatValidationResult ); + + return new CommandResult(result, true); + } + + private @Nullable CompatibilityValidationResult validateSchemaCompatibilityIfNeeded( + UUID txId, + boolean full, + @Nullable HybridTimestamp commitTsOrNull + ) { + if (!full) { + return null; + } + + HybridTimestamp commitTs = Objects.requireNonNull(commitTsOrNull); + + CompatibilityValidationResult validationResult; + try { + validationResult = schemaCompatibilityValidator + .validateCommit(txId, Set.of(storage.tableId()), commitTs) + .get(); Review Comment: Timeout? ########## modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/schemacompat/CompatibilityValidationResult.java: ########## @@ -154,4 +166,32 @@ public String details() { return details; } + + /** + * Throws an exception produced by the given factory if the validation failed. + * + * @param exceptionFactory Exception factory. + */ + public <X extends Exception> void throwIfSchemaValidationOnCommitFailed(Function<String, ? extends X> exceptionFactory) throws X { + CompatibilityValidationResult validationResult = this; Review Comment: What is the point of this assignment? Just genuine question. ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/TablePartitionProcessor.java: ########## @@ -378,12 +364,43 @@ private CommandResult handleUpdateAllCommand( advanceLastAppliedIndexConsistently(commandIndex, commandTerm); } - replicaTouch(txId, cmd.txCoordinatorId(), cmd.full() ? safeTimestamp : null, cmd.full()); + replicaTouch(txId, cmd.txCoordinatorId(), cmd.full()); - return new CommandResult( - new UpdateCommandResult(true, isPrimaryInGroupTopology(storageLeaseInfo), safeTimestamp.longValue()), - true + UpdateCommandResult result = new UpdateCommandResult( + true, + isPrimaryInGroupTopology(storageLeaseInfo), + safeTimestamp.longValue(), + failedCompatValidationResult ); + + return new CommandResult(result, true); + } + + private @Nullable CompatibilityValidationResult validateSchemaCompatibilityIfNeeded( + UUID txId, + boolean full, + @Nullable HybridTimestamp commitTsOrNull + ) { + if (!full) { + return null; + } + + HybridTimestamp commitTs = Objects.requireNonNull(commitTsOrNull); + + CompatibilityValidationResult validationResult; + try { + validationResult = schemaCompatibilityValidator Review Comment: We can just return it here. Instead of separating assignment and initialization -- 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]
