Skip to content

Conversation

@alievmirza
Copy link
Contributor

@alievmirza alievmirza commented Apr 3, 2024

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

  • 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

@alievmirza alievmirza changed the title IGNITE-21911 WIP IGNITE-21911 Change API usage of Placement driver in Index module from TablePartitionId to ZonePartitionId Apr 9, 2024
Copy link
Contributor

@JAkutenshi JAkutenshi left a 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,
Copy link
Contributor

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) {
Copy link
Contributor

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'.

Copy link
Contributor

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)
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor

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)
Copy link
Contributor

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()),
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 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 {

Copy link
Contributor

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;
Copy link
Contributor

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.
Copy link
Contributor

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')
Copy link
Contributor

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());
Copy link
Contributor

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);
Copy link
Contributor

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());
Copy link
Contributor

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()),
Copy link
Contributor

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
Copy link
Contributor

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,
Copy link
Contributor

@sanpwc sanpwc Apr 10, 2024

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());
Copy link
Contributor

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()));
Copy link
Contributor

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.

@alievmirza alievmirza closed this Apr 30, 2024
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.

3 participants