-
Notifications
You must be signed in to change notification settings - Fork 136
IGNITE-21911 Change API usage of Placement driver in Index module from TablePartitionId to ZonePartitionId #3548
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
JAkutenshi
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.
Mostly questions as a review
| boolean unique, | ||
| CatalogIndexStatus status, | ||
| int txWaitCatalogVersion, | ||
| int zoneId, |
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.
Missed zoneId in jdoc like above?
| * @param zoneId Zone id. | ||
| * @param partId Partition id. | ||
| */ | ||
| public ZonePartitionId(int zoneId, int partId, int tableId) { |
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.
May I propose to change args order to (zoneId, tableId, partId) for call consistency? Like in ChangeIndexStatusTask:L238 will look like from more global to less global ids'.
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.
Agree. Moreover, I'd actually adjust the fields order in the same manner.
| TablePartitionId tablePartId = new TablePartitionId(tableId, zonePartitionId.partitionId()); | ||
|
|
||
| if (tableId == indexDescriptor.tableId()) { | ||
| CompletableFuture<?> startBuildIndexFuture = getMvTableStorageFuture(parameters.causalityToken(), tablePartId) |
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.
Shouldn't getMvTableStorageFuture's second argument be changed to ZonePartitionId too?
| @@ -244,7 +258,7 @@ private void tryScheduleBuildIndex( | |||
| * @param replicaId Replica ID. | |||
| */ | |||
| private void stopBuildingIndexesIfPrimaryExpired(TablePartitionId replicaId) { | |||
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 same, shouldn't be there new ZonePartitionId?
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.
As an additional question: isn't one of subtask is to get rid of TablePartitionId?
| ClusterNode leaseholderNode = clusterNodeResolver.getById(replicaMeta.getLeaseholderId()); | ||
|
|
||
| WaitReplicaStateMessage awaitReplicaReq = REPLICA_MESSAGES_FACTORY.waitReplicaStateMessage() | ||
| .groupId(tablePartitionId) |
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 same, as input we got ZPId as groupId, but have to use TPId
| metaStorageMgr, | ||
| indexManager, | ||
| placementDriverMgr.placementDriver(), | ||
| new ReplicaAwareLeaseTracker(placementDriverMgr.placementDriver(), replicaSvc, clusterSvc.topologyService()), |
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 we should use the delegate only for index?
| * The class is used to identify a zone replication group id for a given partition. | ||
| */ | ||
| public class ZonePartitionId implements ReplicationGroupId { | ||
|
|
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.
Please remove the empty line.
| /** Partition id. */ | ||
| private final int partId; | ||
|
|
||
| private final int tableId; |
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.
Please either add javadoc to the tableId field or remove zoneId, partId ones. From my point of view, the latter is better here.
| /** | ||
| * The constructor. | ||
| * | ||
| * @param zoneId Zone id. |
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.
tableId param is missing.
| implementation project(':ignite-raft-api') | ||
| implementation project(':ignite-metastorage-api') | ||
| implementation project(':ignite-placement-driver-api') | ||
| implementation project(':ignite-placement-driver') |
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?
|
|
||
| private void setPrimaryReplica(ClusterNode clusterNode) { | ||
| TablePartitionId groupId = new TablePartitionId(tableId(), 0); | ||
| ZonePartitionId zonePartId = new ZonePartitionId(0, 0, tableId()); |
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.
Here and there. Using 0 is generally not consistent. tableId internally wil retrieve id from CatalogTableDescriptor
public static CatalogTableDescriptor getTableStrict(CatalogService catalogService, String tableName, long timestamp) {
CatalogTableDescriptor table = catalogService.table(tableName, timestamp);
assertNotNull(table, "tableName=" + tableName + ", timestamp=" + timestamp);
return table;
}
Meaning that we should retrieve zoneId from the same descriptor.
| TablePartitionId tablePartId = new TablePartitionId(tableId(), 0); | ||
|
|
||
| assertThat(placementDriver.setPrimaryReplicaMeta(0, groupId, completedFuture(replicaMeta)), willCompleteSuccessfully()); | ||
| ReplicaMeta replicaMeta = newPrimaryReplicaMeta(clusterNode, tablePartId, HybridTimestamp.MIN_VALUE, HybridTimestamp.MAX_VALUE); |
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 it's tablePartId in replicaMeta? We should have new ZonePartitionId there.
| private TablePartitionId replicaId(int partitionId) { | ||
| return new TablePartitionId(tableId(), partitionId); | ||
| private ZonePartitionId replicaId(int partitionId) { | ||
| return new ZonePartitionId(0, partitionId, tableId()); |
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.
Same as above, not valid to use 0 here as zoneId, please retrieve the identifier from catalog descriptor like tableId() does.
| new PrimaryReplicaEventParameters( | ||
| causalityToken, | ||
| replicaId, | ||
| new TablePartitionId(replicaId.tableId(), replicaId.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.
We should use ZonePartitionId here.
| ); | ||
|
|
||
| /** | ||
| * Temporary solution for awaiting {@link ReplicaMeta}. Waits for |
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.
If it's temporary please add todo with a link and mark the method as @deprecated. Please create a ticket if necessary.
| * @throws PrimaryReplicaAwaitException If primary replica await failed with any other reason except timeout. | ||
| */ | ||
| default CompletableFuture<ReplicaMeta> awaitPrimaryReplicaForTable( | ||
| ZonePartitionId groupId, |
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 it's ZonePartitionId? It should be ReplicationGroupId.
| * @return Future that contains a result. | ||
| */ | ||
| private CompletableFuture<Void> processWaitReplicaStateMessage(WaitReplicaStateMessage msg) { | ||
| LOG.info("Received LeaseGrantedMessage for replica belonging to group=" + groupId()); |
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 not LeaseGrantedMessage.
| private CompletableFuture<Void> processWaitReplicaStateMessage(WaitReplicaStateMessage msg) { | ||
| LOG.info("Received LeaseGrantedMessage for replica belonging to group=" + groupId()); | ||
|
|
||
| return waitForActualState(FastTimestamps.coarseCurrentTimeMillis() + TimeUnit.SECONDS.toMillis(msg.timeout())); |
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 also required to sendPrimaryReplicaChangeToReplicationGroup after waitForActualState. Please check Replica#processLeaseGrantedMessage for more details.
https://issues.apache.org/jira/browse/IGNITE-21911
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
- 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.
Notes