-
Notifications
You must be signed in to change notification settings - Fork 135
IGNITE-17132 [Native Persistence 3.0] Implement partition destruction for persistent PageMemory #1325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| static { | ||
| try { | ||
| COUNTER = MethodHandles.lookup().findVarHandle(PartitionProcessingCounter.class, "counter", int.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a replacement for an AtomicInteger. AtomicInteger would make the code more concise and easier to understand, you could use incrementAndGet() and decrementAndGet() below.
You probably wanted to spare object instances using this approach, but it's just one instance per partition. It seems unlikely that someone will have even a million partitions in the same JVM, so the saving is not worth code complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, we will save memory and at the same time the complexity of the code will not increase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complexity increases in both creation (static block with try and MethodHandles invocation vs new AtomicInteger()) and usage (incrementAndGet() vs getAndAdd(this, 1) + 1). It is slightly simpler, but simpler. And even slight simplification is wortha lot (surely more than saving 10k objects per JVM).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think that for us it greatly complicates the code.
| public void onStartPartitionProcessing() { | ||
| assert !future.isDone(); | ||
|
|
||
| int updatedValue = (int) COUNTER.getAndAdd(this, 1) + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks analogous to counter.incrementAndGet() (when using AtomicInteger)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, but it's not complex code.
| public void onFinishPartitionProcessing() { | ||
| assert !future.isDone(); | ||
|
|
||
| int updatedValue = (int) COUNTER.getAndAdd(this, -1) - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks analogous to counter.decrementAndGet() (when using AtomicInteger)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, but it's not complex code.
.../main/java/org/apache/ignite/internal/pagememory/persistence/PartitionProcessingCounter.java
Outdated
Show resolved
Hide resolved
...in/java/org/apache/ignite/internal/pagememory/persistence/PartitionProcessingCounterMap.java
Show resolved
Hide resolved
...org/apache/ignite/internal/storage/pagememory/index/sorted/PageMemorySortedIndexStorage.java
Outdated
Show resolved
Hide resolved
...org/apache/ignite/internal/storage/pagememory/index/sorted/PageMemorySortedIndexStorage.java
Outdated
Show resolved
Hide resolved
|
|
||
| static { | ||
| try { | ||
| STARTED = MethodHandles.lookup().findVarHandle(PageMemoryHashIndexStorage.class, "started", boolean.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use AtomicBoolean instead. It makes the code simpler and the price we pay (one object per index per partition) is tiny. The same relates to all pagemem-based index and MvPartitionStorage implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave it as it is, we use less memory, and the complexity here is minimal.
| */ | ||
| @ExtendWith(WorkDirectoryExtension.class) | ||
| @ExtendWith(ConfigurationExtension.class) | ||
| @ExtendWith({ConfigurationExtension.class, WorkDirectoryExtension.class}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both styles seem ok, but why is this (one annotation with an array) seems better to you? It brings some syntactic noise (braces).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just that I like it better, I suggest leaving it as it is.
...va/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryMvTableStorageTest.java
Outdated
Show resolved
Hide resolved
|
Also, I wonder, why |
.../main/java/org/apache/ignite/internal/pagememory/persistence/PartitionProcessingCounter.java
Outdated
Show resolved
Hide resolved
.../main/java/org/apache/ignite/internal/pagememory/persistence/PartitionProcessingCounter.java
Outdated
Show resolved
Hide resolved
...ain/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointManager.java
Outdated
Show resolved
Hide resolved
...ain/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointManager.java
Outdated
Show resolved
Hide resolved
...g/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointPagesWriterFactory.java
Outdated
Show resolved
Hide resolved
...est/java/org/apache/ignite/internal/pagememory/persistence/store/GroupPageStoresMapTest.java
Outdated
Show resolved
Hide resolved
| * @param cause The cause. | ||
| */ | ||
| public StorageClosedException(String message, Throwable cause) { | ||
| super(message, cause); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's the error code? :)
I guess we should make it soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coming soon
| * <p>This method will do nothing if there is no partition by ID, when trying to call methods to read or write (as well as all previous | ||
| * open cursors) for {@link MvPartitionStorage}, {@link HashIndexStorage} and {@link SortedIndexStorage}, {@link StorageClosedException} | ||
| * will be thrown. | ||
| * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description is close to impossible to understand, please use re-structure your text and expand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is not clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grammatical structure is very convoluted. Maybe something like
This method will ... if:
- blah
- foo
- bar
will be easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted this comment.
| assertThrows(StorageClosedException.class, storage::lastAppliedIndex); | ||
| assertThrows(StorageClosedException.class, storage::lastAppliedTerm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two don't have to throw exceptions, but ok
...ain/java/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryTableStorage.java
Show resolved
Hide resolved
.../main/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreManager.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/Checkpointer.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/Checkpointer.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/Checkpointer.java
Outdated
Show resolved
Hide resolved
...ry/src/main/java/org/apache/ignite/internal/pagememory/persistence/compaction/Compactor.java
Outdated
Show resolved
Hide resolved
| return; | ||
| } | ||
|
|
||
| if (filePageStore.isMarkedToDestroy()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These checks (whether it's cancelled, whether the store is marked for destroy) are always done together in this method. How about uniting them in a single method like shouldNotProceedWith(FilePageStore) and call it in all places in this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure that we always do these checks together in this method. After modifications someone might accidentally add just one check instead of 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do not need a separate method for two slightly different checks, this complicates the code a bit.
|
|
||
| CompletableFuture<Void> previousFuture = destroyFutureByPartitionId.put(partitionId, new CompletableFuture<>()); | ||
|
|
||
| assert previousFuture == null : "Previous destruction of the partition has not completed: " + partitionId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just return the old future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's up with the future anyway? No one uses it, what's the point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t understand why return the current future while no one uses it, but later they will be on the assignment recalculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, didn't notice the other usage
.../main/java/org/apache/ignite/internal/storage/pagememory/VolatilePageMemoryTableStorage.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/ignite/internal/storage/pagememory/index/hash/PageMemoryHashIndexStorage.java
Outdated
Show resolved
Hide resolved
...org/apache/ignite/internal/storage/pagememory/index/sorted/PageMemorySortedIndexStorage.java
Outdated
Show resolved
Hide resolved
...a/org/apache/ignite/internal/storage/pagememory/mv/AbstractPageMemoryMvPartitionStorage.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/Checkpointer.java
Outdated
Show resolved
Hide resolved
...ry/src/main/java/org/apache/ignite/internal/pagememory/persistence/compaction/Compactor.java
Outdated
Show resolved
Hide resolved
...ry/src/main/java/org/apache/ignite/internal/pagememory/persistence/compaction/Compactor.java
Outdated
Show resolved
Hide resolved
...api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java
Outdated
Show resolved
Hide resolved
.../main/java/org/apache/ignite/internal/storage/pagememory/AbstractPageMemoryTableStorage.java
Outdated
Show resolved
Hide resolved
.../apache/ignite/internal/table/distributed/raft/snapshot/incoming/IncomingSnapshotCopier.java
Show resolved
Hide resolved
rpuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
...src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/Checkpointer.java
Show resolved
Hide resolved
.../main/java/org/apache/ignite/internal/storage/pagememory/AbstractPageMemoryTableStorage.java
Outdated
Show resolved
Hide resolved
...ge-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbTableStorage.java
Show resolved
Hide resolved
… for persistent PageMemory (apache#1325)
… for persistent PageMemory (apache#1325)
https://issues.apache.org/jira/browse/IGNITE-17132