Skip to content

Comments

IGNITE-18565 Modify getOrCreateMvPartition and getMvPartition of MvTableStorage to return the future#1666

Merged
tkalkirill merged 26 commits intoapache:mainfrom
gridgain:ignite-18565
Feb 24, 2023
Merged

IGNITE-18565 Modify getOrCreateMvPartition and getMvPartition of MvTableStorage to return the future#1666
tkalkirill merged 26 commits intoapache:mainfrom
gridgain:ignite-18565

Conversation

@tkalkirill
Copy link
Contributor

class DestroyStorageOperation implements StorageOperation {
private final CompletableFuture<Void> destroyFuture = new CompletableFuture<>();

private final AtomicReference<CreateStorageOperation> createStorageOperationReference = new AtomicReference<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this can be just AtomicBoolean

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not suitable, I need to atomically replace it with the creation operation when the destruction operation is completed if necessary.

return new DestroyStorageOperation();
});

return completedFuture(null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need a completedFuture here? Can't we just use destroyStorageFunction.apply(storageByPartitionId.getAndSet(partitionId, null))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a trick to make sure the operation gets rid of if it succeeds or fails.


assertThat(createMvPartitionFuture, willCompleteSuccessfully());

return createMvPartitionFuture.join();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be get with timeout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessary because above we make sure that the future completed.

assertThat(createMvPartitionFuture, willCompleteSuccessfully());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about getNow() then?

Copy link
Contributor Author

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 this is necessary, the future is already definitely completed.


/** Partition storages. */
private volatile AtomicReferenceArray<RocksDbMvPartitionStorage> partitions;
private volatile MvPartitionStorages<RocksDbMvPartitionStorage> mvPartitionStorages;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create this object in the constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the point of view of the product code, the answer is "yes we can", but from the point of view of the designs should do in org.apache.ignite.internal.storage.engine.MvTableStorage#start.

Copy link
Contributor

@SammyVimes SammyVimes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tkalkirill tkalkirill merged commit cbe2eb2 into apache:main Feb 24, 2023
@tkalkirill tkalkirill deleted the ignite-18565 branch February 24, 2023 08:07
lowka pushed a commit to gridgain/apache-ignite-3 that referenced this pull request Mar 18, 2023
lowka pushed a commit to gridgain/apache-ignite-3 that referenced this pull request Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants