You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "tkalkirill (via GitHub)" <gi...@apache.org> on 2024/02/23 10:49:54 UTC

[PR] IGNITE-21591 Add tuple updates during index backfill process [ignite-3]

tkalkirill opened a new pull request, #3280:
URL: https://github.com/apache/ignite-3/pull/3280

   https://issues.apache.org/jira/browse/IGNITE-21591
   
   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21591 Add tuple updrades during index backfill process [ignite-3]

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #3280:
URL: https://github.com/apache/ignite-3/pull/3280#discussion_r1502664551


##########
modules/schema/src/test/java/org/apache/ignite/internal/schema/BinaryRowUpdaterTest.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.schema;
+
+import static org.apache.ignite.internal.schema.BinaryRowMatcher.equalToRow;
+import static org.apache.ignite.internal.type.NativeTypes.INT32;
+import static org.apache.ignite.internal.type.NativeTypes.INT64;
+import static org.apache.ignite.internal.type.NativeTypes.STRING;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.sameInstance;
+
+import org.apache.ignite.internal.schema.registry.SchemaRegistryImpl;
+import org.apache.ignite.internal.schema.row.RowAssembler;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/** For {@link BinaryRowUpdater} testing. */
+public class BinaryRowUpdaterTest {
+    private static final SchemaDescriptor SCHEMA_V_1 = new SchemaDescriptor(

Review Comment:
   I suggest to rename these `SCHEMA_V_N` fields to `ORIGINAL_SCHEMA`, `NULLABLE_COLUMN_ADDED` and `DEFAULTED_COLUMN_ADDED`, respectively. This will describe the intention behind them. 'V_1' and 'V_2' does not tell too much about how they interrelate, and it's not clear from the named how V_3 is different from V_2.



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/PartitionListener.java:
##########
@@ -621,4 +640,27 @@ private BuildIndexRowVersionChooser createBuildIndexRowVersionChooser(BuildIndex
 
         return new BuildIndexRowVersionChooser(storage, indexCreationCatalog.time(), startBuildingIndexCatalog.time());
     }
+
+    private BinaryRowUpdater createBinaryRowUpdater(BuildIndexCommand command) {
+        int startBuildingIndexCatalogVersion = command.requiredCatalogVersion();

Review Comment:
   If I'm not mistaken, this code takes the version when the index became `BUILDING`. But it seems that we should take the version in which it started existing, that is, when it was `REGISTERED`. Otherwise, if a default on the indexed column is changed between these two versions, we'll write the value corresponding to the second default to the index, but we should write the one corresponding to the first default (which was defined right before the index was created).



##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryRowUpdater.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.schema;
+
+import org.apache.ignite.internal.schema.row.Row;
+import org.apache.ignite.internal.schema.row.RowAssembler;
+
+/** {@link BinaryRowUpdater} updater to the required schema version. */
+public class BinaryRowUpdater {

Review Comment:
   Upgrader



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21591 Add tuple updrades during index backfill process [ignite-3]

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #3280:
URL: https://github.com/apache/ignite-3/pull/3280#discussion_r1503089775


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryRowUpgrader.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.schema;
+
+import org.apache.ignite.internal.schema.row.Row;
+import org.apache.ignite.internal.schema.row.RowAssembler;
+
+/** {@link BinaryRow} upgrader to the required schema version. */
+public class BinaryRowUpgrader {
+    private final SchemaRegistry schemaRegistry;
+
+    private final SchemaDescriptor targetSchema;
+
+    /** Constructor. */
+    public BinaryRowUpgrader(SchemaRegistry schemaRegistry, int targetSchemaVersion) {
+        this(schemaRegistry, schemaRegistry.schema(targetSchemaVersion));
+    }
+
+    /** Constructor. */
+    public BinaryRowUpgrader(SchemaRegistry schemaRegistry, SchemaDescriptor targetSchema) {
+        this.schemaRegistry = schemaRegistry;
+        this.targetSchema = targetSchema;
+    }
+
+    /**
+     * Returns an upgraded {@link BinaryRow} to the required schema version, or the {@code source} if its schema version is equal to the
+     * required schema version.
+     *
+     * @param source Source binary row.
+     */
+    public BinaryRow upgrade(BinaryRow source) {
+        if (source.schemaVersion() == targetSchema.version()) {

Review Comment:
   It might happen that the source version is greater than the target version. For index building, this can only happen if a table was ALTERed between REGISTERED and BUILDING of the index and a transaction was started, tuple written and committed after the ALTER TABLE and before BUILDING. In such cases, we don't need to upgrade the row as it will actually be a downgrade. So we should skip upgrading for such cases.
   
   I'm not sure if it's better to handle this inside this method or on the side of the caller.



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21591 Add tuple updrades during index backfill process [ignite-3]

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #3280:
URL: https://github.com/apache/ignite-3/pull/3280#discussion_r1502711707


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryRowUpdater.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.schema;
+
+import org.apache.ignite.internal.schema.row.Row;
+import org.apache.ignite.internal.schema.row.RowAssembler;
+
+/** {@link BinaryRowUpdater} updater to the required schema version. */
+public class BinaryRowUpdater {

Review Comment:
   Fix it



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21591 Add tuple updrades during index backfill process [ignite-3]

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #3280:
URL: https://github.com/apache/ignite-3/pull/3280#discussion_r1502725091


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/PartitionListener.java:
##########
@@ -621,4 +640,27 @@ private BuildIndexRowVersionChooser createBuildIndexRowVersionChooser(BuildIndex
 
         return new BuildIndexRowVersionChooser(storage, indexCreationCatalog.time(), startBuildingIndexCatalog.time());
     }
+
+    private BinaryRowUpdater createBinaryRowUpdater(BuildIndexCommand command) {
+        int startBuildingIndexCatalogVersion = command.requiredCatalogVersion();

Review Comment:
   fix it



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21591 Add tuple updrades during index backfill process [ignite-3]

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #3280:
URL: https://github.com/apache/ignite-3/pull/3280#discussion_r1502715014


##########
modules/schema/src/test/java/org/apache/ignite/internal/schema/BinaryRowUpdaterTest.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.schema;
+
+import static org.apache.ignite.internal.schema.BinaryRowMatcher.equalToRow;
+import static org.apache.ignite.internal.type.NativeTypes.INT32;
+import static org.apache.ignite.internal.type.NativeTypes.INT64;
+import static org.apache.ignite.internal.type.NativeTypes.STRING;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.sameInstance;
+
+import org.apache.ignite.internal.schema.registry.SchemaRegistryImpl;
+import org.apache.ignite.internal.schema.row.RowAssembler;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/** For {@link BinaryRowUpdater} testing. */
+public class BinaryRowUpdaterTest {
+    private static final SchemaDescriptor SCHEMA_V_1 = new SchemaDescriptor(

Review Comment:
   Why not



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21591 Add tuple updrades during index backfill process [ignite-3]

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #3280:
URL: https://github.com/apache/ignite-3/pull/3280#discussion_r1503611996


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryRowUpgrader.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.schema;
+
+import org.apache.ignite.internal.schema.row.Row;
+import org.apache.ignite.internal.schema.row.RowAssembler;
+
+/** {@link BinaryRow} upgrader to the required schema version. */
+public class BinaryRowUpgrader {
+    private final SchemaRegistry schemaRegistry;
+
+    private final SchemaDescriptor targetSchema;
+
+    /** Constructor. */
+    public BinaryRowUpgrader(SchemaRegistry schemaRegistry, int targetSchemaVersion) {
+        this(schemaRegistry, schemaRegistry.schema(targetSchemaVersion));
+    }
+
+    /** Constructor. */
+    public BinaryRowUpgrader(SchemaRegistry schemaRegistry, SchemaDescriptor targetSchema) {
+        this.schemaRegistry = schemaRegistry;
+        this.targetSchema = targetSchema;
+    }
+
+    /**
+     * Returns an upgraded {@link BinaryRow} to the required schema version, or the {@code source} if its schema version is equal to the
+     * required schema version.
+     *
+     * @param source Source binary row.
+     */
+    public BinaryRow upgrade(BinaryRow source) {
+        if (source.schemaVersion() == targetSchema.version()) {

Review Comment:
   I think it’s better to handle this situation here, added a unit test.



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21591 Add tuple updrades during index backfill process [ignite-3]

Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill merged PR #3280:
URL: https://github.com/apache/ignite-3/pull/3280


-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org