ibessonov commented on code in PR #7019:
URL: https://github.com/apache/ignite-3/pull/7019#discussion_r2577238006
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/MvPartitionStorage.java:
##########
@@ -344,6 +344,21 @@ AddWriteCommittedResult addWriteCommitted(
*/
long estimatedSize();
+ /**
+ * Returns a cursor that traverses all rod IDs of write intents registered
with the write intents' list.
Review Comment:
```suggestion
* Returns a cursor that traverses all row IDs of write intents
registered with the write intents' list.
```
##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/AbstractPageMemoryMvPartitionStorage.java:
##########
@@ -504,20 +504,21 @@ public CommitResult commitWrite(RowId rowId,
HybridTimestamp timestamp, UUID txI
assert rowIsLocked(rowId) : commitWriteInfo(rowId, timestamp,
txId);
+ CommitResult commitResult;
+
Review Comment:
I suppose it's an artifact of some changes that you already removed from the
code. Could you please move the declaration back to the line where it's
initialized?
##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMeta.java:
##########
@@ -317,6 +322,24 @@ public long leaseStartTime() {
return leaseStartTime;
}
+ /**
+ * Updates the link to the head of the write intent list.
+ *
+ * @param link Link to the head of the write intent list.
+ */
+ public void updateWiHead(long link) {
+ this.wiHeadLink = link;
+ }
Review Comment:
Every update operation in `*Meta` must execute the
`updateSnapshot(checkpointId);` before mutating the state of an instance. This
is an essential part of the mechanism of consistently checkpointing meta pages
of partitions. I know it is a headache to pass `checkpointId` here, but we
simply must find some good way to do this.
##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/AddWriteLinkingWiInvokeClosure.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.pagememory.mv;
+
+import static org.apache.ignite.internal.pagememory.util.PageIdUtils.NULL_LINK;
+
+import java.util.UUID;
+import org.apache.ignite.internal.lang.IgniteInternalCheckedException;
+import org.apache.ignite.internal.pagememory.freelist.FreeList;
+import org.apache.ignite.internal.pagememory.tree.BplusTree;
+import org.apache.ignite.internal.pagememory.tree.IgniteTree.InvokeClosure;
+import org.apache.ignite.internal.schema.BinaryRow;
+import org.apache.ignite.internal.storage.RowId;
+import org.apache.ignite.internal.storage.StorageException;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of {@link InvokeClosure} for {@link
AbstractPageMemoryMvPartitionStorage#addWrite(RowId, BinaryRow, UUID, int, int)}
+ * which additionally maintains links between write intents.
+ *
+ * <p>See {@link AbstractPageMemoryMvPartitionStorage} about synchronization.
+ *
+ * <p>Operation may throw {@link StorageException} which will cause form
{@link BplusTree#invoke(Object, Object, InvokeClosure)}.
+ */
+class AddWriteLinkingWiInvokeClosure extends AddWriteInvokeClosure {
+ private final PersistentPageMemoryMvPartitionStorage persistentStorage;
+
+ private final FreeList freeList;
+
+ AddWriteLinkingWiInvokeClosure(
+ RowId rowId,
+ @Nullable BinaryRow row,
+ UUID txId,
+ int commitZoneId,
+ int commitPartitionId,
+ PersistentPageMemoryMvPartitionStorage storage
+ ) {
+ super(rowId, row, txId, commitZoneId, commitPartitionId, storage);
+
+ persistentStorage = storage;
+
+ this.freeList = storage.renewableState.freeList();
+ }
+
+ @Override
+ protected RowVersion insertFirstRowVersion() {
+ long wiListHeadLink = persistentStorage.lockWriteIntentListHead();
+ long newWiListHeadLink = wiListHeadLink;
+
+ try {
+ WiLinkableRowVersion newVersion = insertRowVersion(NULL_LINK,
wiListHeadLink, NULL_LINK);
+
+ newWiListHeadLink = newVersion.link();
+
+ updateWiListLinks(newVersion);
Review Comment:
This code requires a few comments:
- Why do we update links in a linked list if it's a first element?
- Shouldn't we implement a double-checked locking anyway? If we should (I
believe we are) then what would be the difference between `first` and `another`
insertions? My point is - these things should be checked while you're holding a
lock, not before acquiring 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]