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/04/05 08:45:49 UTC
[PR] IGNITE-21988 Don't allow reading from index storage if it is in build state [ignite-3]
tkalkirill opened a new pull request, #3561:
URL: https://github.com/apache/ignite-3/pull/3561
https://issues.apache.org/jira/browse/IGNITE-21988
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-21988 Don't allow reading from index storage if it is in build state [ignite-3]
Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #3561:
URL: https://github.com/apache/ignite-3/pull/3561#discussion_r1565299243
##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/TestStorageUtils.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.storage;
+
+import org.apache.ignite.internal.storage.index.IndexStorage;
+
+/** Auxiliary class for tests that contains useful methods, constants, etc. */
+public class TestStorageUtils {
+ /** Completes the building of indexes. */
+ public static void completeBuiltIndexes(MvPartitionStorage partitionStorage, IndexStorage... indexStorages) {
Review Comment:
It's not clear what this method does from its name and its javadoc and whether this is some shortcut for tests (as it looks) and not something useful for production code. Can a better name be devised? Like `makeIndexStoragesLookBuilt`? Or `forceIndexStoragesBuildCompletion`?
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/SortedIndexStorage.java:
##########
@@ -56,13 +57,20 @@ public interface SortedIndexStorage extends IndexStorage {
* {@code null} means unbounded.
* @param flags Control flags. {@link #GREATER} | {@link #LESS} by default. Other available values
* are {@link #GREATER_OR_EQUAL}, {@link #LESS_OR_EQUAL}.
+ * @param onlyBuiltIndex {@code True} if need to scan only from the built index.
* @return Cursor with fetched index rows.
* @throws IllegalArgumentException If backwards flag is passed and backwards iteration is not supported by the storage.
+ * @throws StorageException If failed to read data.
+ * @throws IndexNotBuiltException If the index has not yet been built and {@code onlyBuiltIndex} = {@code true}.
Review Comment:
Otherwise there might be a confusion whether `=` means an assignment or an equality check
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/SortedIndexStorage.java:
##########
@@ -56,13 +57,20 @@ public interface SortedIndexStorage extends IndexStorage {
* {@code null} means unbounded.
* @param flags Control flags. {@link #GREATER} | {@link #LESS} by default. Other available values
* are {@link #GREATER_OR_EQUAL}, {@link #LESS_OR_EQUAL}.
+ * @param onlyBuiltIndex {@code True} if need to scan only from the built index.
* @return Cursor with fetched index rows.
* @throws IllegalArgumentException If backwards flag is passed and backwards iteration is not supported by the storage.
+ * @throws StorageException If failed to read data.
+ * @throws IndexNotBuiltException If the index has not yet been built and {@code onlyBuiltIndex} = {@code true}.
+ * @throws InconsistentIndexStateException If the index is in a readable status, but the index is not built.
*/
+ // TODO: IGNITE-22039 Implement for onlyBuiltIndex == false throw an InconsistentIndexStateException if the index is not in a readable
+ // status and write tests
PeekCursor<IndexRow> scan(
@Nullable BinaryTuplePrefix lowerBound,
@Nullable BinaryTuplePrefix upperBound,
- @MagicConstant(flagsFromClass = SortedIndexStorage.class) int flags
+ @MagicConstant(flagsFromClass = SortedIndexStorage.class) int flags,
+ boolean onlyBuiltIndex
Review Comment:
The usage of `true` and `false` is very unequal in the project. `false` is only used once, and it's in a very special case, while `true` is used 'normally'. How about making 2 methods: one would be a normal `scan()` with the same parameters that it had before this change (and its implementation will imply `onlyBuiltIndex == true`); and another like `tolerantScan()` that would tolerate inconsistencies (again, without the boolean parameter, instead it would just imply `onlyBuiltIndex == false`).
This would allow us to avoid polluting the code with that `true` everywhere we want to just scan the index without bringing any confusion, and the special case would be handled by the special method.
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/SortedIndexStorage.java:
##########
@@ -56,13 +57,20 @@ public interface SortedIndexStorage extends IndexStorage {
* {@code null} means unbounded.
* @param flags Control flags. {@link #GREATER} | {@link #LESS} by default. Other available values
* are {@link #GREATER_OR_EQUAL}, {@link #LESS_OR_EQUAL}.
+ * @param onlyBuiltIndex {@code True} if need to scan only from the built index.
* @return Cursor with fetched index rows.
* @throws IllegalArgumentException If backwards flag is passed and backwards iteration is not supported by the storage.
+ * @throws StorageException If failed to read data.
+ * @throws IndexNotBuiltException If the index has not yet been built and {@code onlyBuiltIndex} = {@code true}.
+ * @throws InconsistentIndexStateException If the index is in a readable status, but the index is not built.
*/
+ // TODO: IGNITE-22039 Implement for onlyBuiltIndex == false throw an InconsistentIndexStateException if the index is not in a readable
+ // status and write tests
PeekCursor<IndexRow> scan(
@Nullable BinaryTuplePrefix lowerBound,
@Nullable BinaryTuplePrefix upperBound,
- @MagicConstant(flagsFromClass = SortedIndexStorage.class) int flags
+ @MagicConstant(flagsFromClass = SortedIndexStorage.class) int flags,
+ boolean onlyBuiltIndex
Review Comment:
It's not clear that `onlyBuiltIndex` means 'throw if it's not built'. Maybe just name it `throwIfNotBuilt`?
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/SortedIndexStorage.java:
##########
@@ -56,13 +57,20 @@ public interface SortedIndexStorage extends IndexStorage {
* {@code null} means unbounded.
* @param flags Control flags. {@link #GREATER} | {@link #LESS} by default. Other available values
* are {@link #GREATER_OR_EQUAL}, {@link #LESS_OR_EQUAL}.
+ * @param onlyBuiltIndex {@code True} if need to scan only from the built index.
* @return Cursor with fetched index rows.
* @throws IllegalArgumentException If backwards flag is passed and backwards iteration is not supported by the storage.
+ * @throws StorageException If failed to read data.
+ * @throws IndexNotBuiltException If the index has not yet been built and {@code onlyBuiltIndex} = {@code true}.
Review Comment:
```suggestion
* @throws IndexNotBuiltException If the index has not yet been built and {@code onlyBuiltIndex} is {@code 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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21988 Don't allow reading from index storage if it is in build state [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill merged PR #3561:
URL: https://github.com/apache/ignite-3/pull/3561
--
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-21988 Don't allow reading from index storage if it is in build state [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #3561:
URL: https://github.com/apache/ignite-3/pull/3561#discussion_r1553308418
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/IndexNotBuiltException.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.storage.index;
+
+import org.apache.ignite.internal.storage.StorageException;
+import org.apache.ignite.lang.ErrorGroups.Storage;
+
+/** Exception occurred while reading from an index that has not yet been built. */
Review Comment:
Fixed it.
I don’t think we need to talk about this here; an error can also occur if the API is used incorrectly.
--
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-21988 Don't allow reading from index storage if it is in build state [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #3561:
URL: https://github.com/apache/ignite-3/pull/3561#discussion_r1574126951
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/SortedIndexStorage.java:
##########
@@ -56,13 +57,20 @@ public interface SortedIndexStorage extends IndexStorage {
* {@code null} means unbounded.
* @param flags Control flags. {@link #GREATER} | {@link #LESS} by default. Other available values
* are {@link #GREATER_OR_EQUAL}, {@link #LESS_OR_EQUAL}.
+ * @param onlyBuiltIndex {@code True} if need to scan only from the built index.
* @return Cursor with fetched index rows.
* @throws IllegalArgumentException If backwards flag is passed and backwards iteration is not supported by the storage.
+ * @throws StorageException If failed to read data.
+ * @throws IndexNotBuiltException If the index has not yet been built and {@code onlyBuiltIndex} = {@code true}.
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-21988 Don't allow reading from index storage if it is in build state [ignite-3]
Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #3561:
URL: https://github.com/apache/ignite-3/pull/3561#discussion_r1553255828
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/IndexNotBuiltException.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.storage.index;
+
+import org.apache.ignite.internal.storage.StorageException;
+import org.apache.ignite.lang.ErrorGroups.Storage;
+
+/** Exception occurred while reading from an index that has not yet been built. */
Review Comment:
```suggestion
/** Exception occurring while reading from an index that has not yet been built. */
```
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/IndexNotBuiltException.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.storage.index;
+
+import org.apache.ignite.internal.storage.StorageException;
+import org.apache.ignite.lang.ErrorGroups.Storage;
+
+/** Exception occurred while reading from an index that has not yet been built. */
Review Comment:
Should it be mentioned in the javadoc that this might be a result of data loss (like majority loss), so that the Catalog thinks the index built was finished, but the partition does not have the index fully built?
--
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-21988 Don't allow reading from index storage if it is in build state [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #3561:
URL: https://github.com/apache/ignite-3/pull/3561#discussion_r1574127097
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/SortedIndexStorage.java:
##########
@@ -56,13 +57,20 @@ public interface SortedIndexStorage extends IndexStorage {
* {@code null} means unbounded.
* @param flags Control flags. {@link #GREATER} | {@link #LESS} by default. Other available values
* are {@link #GREATER_OR_EQUAL}, {@link #LESS_OR_EQUAL}.
+ * @param onlyBuiltIndex {@code True} if need to scan only from the built index.
* @return Cursor with fetched index rows.
* @throws IllegalArgumentException If backwards flag is passed and backwards iteration is not supported by the storage.
+ * @throws StorageException If failed to read data.
+ * @throws IndexNotBuiltException If the index has not yet been built and {@code onlyBuiltIndex} = {@code true}.
+ * @throws InconsistentIndexStateException If the index is in a readable status, but the index is not built.
*/
+ // TODO: IGNITE-22039 Implement for onlyBuiltIndex == false throw an InconsistentIndexStateException if the index is not in a readable
+ // status and write tests
PeekCursor<IndexRow> scan(
@Nullable BinaryTuplePrefix lowerBound,
@Nullable BinaryTuplePrefix upperBound,
- @MagicConstant(flagsFromClass = SortedIndexStorage.class) int flags
+ @MagicConstant(flagsFromClass = SortedIndexStorage.class) int flags,
+ boolean onlyBuiltIndex
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-21988 Don't allow reading from index storage if it is in build state [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #3561:
URL: https://github.com/apache/ignite-3/pull/3561#discussion_r1574154840
##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/TestStorageUtils.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.storage;
+
+import org.apache.ignite.internal.storage.index.IndexStorage;
+
+/** Auxiliary class for tests that contains useful methods, constants, etc. */
+public class TestStorageUtils {
+ /** Completes the building of indexes. */
+ public static void completeBuiltIndexes(MvPartitionStorage partitionStorage, IndexStorage... indexStorages) {
Review Comment:
Yes, this method is used only in tests, it is located in the class for tests `TestStorageUtils`, I think that the name is quite clear.
--
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