Skip to content
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

Dual Replication - Primary changes #152

Closed
wants to merge 3 commits into from

Conversation

shourya035
Copy link
Collaborator

@shourya035 shourya035 commented Mar 8, 2024

Description

[Describe what this change achieves]

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Failing checks are inspected and point to the corresponding known issue(s) (See: Troubleshooting Failing Builds)
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • Public documentation issue/PR created

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@@ -5199,6 +5209,10 @@ public AsyncIOProcessor<Translog.Location> getTranslogSyncProcessor() {
return translogSyncProcessor;
}

public boolean ongoingEngineMigration() {
return RemoteStoreUtils.isMigrationDirectionSet(clusterService) == true;
Copy link
Owner

Choose a reason for hiding this comment

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

This will return true for all the shards during migration . Will that have any side effects ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed this altogether from IndexShard

Comment on lines 46 to 53
&& !shard.indexSettings.isSegRepWithRemoteEnabled()
/*
During remote store migration, the isSegRepWithRemoteEnabled criteria would return false
since we do not alter the remote store based index settings at that stage. Explicitly
blocking checkpoint publication from this refresh listener since it ends up interfering
with the RemoteStoreRefreshListener invocation
*/
&& !shard.ongoingEngineMigration()) {
Copy link
Owner

Choose a reason for hiding this comment

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

can we have isSegRepLocalEnabled instead of negative checks ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed this. Changed the isSegRepLocalEnabled check to ensure that the Checkpoint listeners won't be registered if the node is non-remote

@@ -1248,7 +1254,8 @@ private void createReplicationLagTimers() {
if (cps.inSync
&& replicationGroup.getUnavailableInSyncShards().contains(allocationId) == false
&& isPrimaryRelocation(allocationId) == false
&& latestReplicationCheckpoint.isAheadOf(cps.visibleReplicationCheckpoint)) {
&& latestReplicationCheckpoint.isAheadOf(cps.visibleReplicationCheckpoint)
&& (ongoingEngineMigration && routingTable.getByAllocationId(allocationId).isAssignedToRemoteStoreNode() == true)) {
Copy link
Owner

Choose a reason for hiding this comment

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

why do we need ongoingEngineMigration here ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed this. Relying on the shardRouting and isSegRepLocalEnabled check to ensure that the timers are only created if:

  • The shard copy is hosted on a remote enabled node
  • The index setting has segrep enabled but remote disabled (vanilla segrep)

@@ -1096,4 +1098,14 @@ enum IndexRemovalReason {
REOPENED,
}
}

private void updateShardRoutingWithNode(IndexShardRoutingTable indexShardRoutingTable, DiscoveryNodes nodes) {
Copy link
Owner

Choose a reason for hiding this comment

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

what about createShard flow ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressing that

@@ -75,6 +75,7 @@ public class ShardRouting implements Writeable, ToXContentObject {
private final long expectedShardSize;
@Nullable
private final ShardRouting targetRelocatingShard;
private boolean assignedToRemoteStoreNode;
Copy link
Owner

Choose a reason for hiding this comment

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

this is not populated by master and only data node . Is it intentional ? If yes, should we make it Boolean instead ? Also it is final .

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ideally we don't want to serialize the value for this field since this won't be used anywhere else. I have changed this to Boolean instead of the primitive type, but I have assigned a default value to prevent any possible NPEs when the shardRouting entry sent from the cluster manager nodes are serialized on the data node.

// If the current routing is the primary, then it does not need to be replicated
if (shardRouting.isSameAllocation(primaryRouting)) {
return ReplicationMode.NO_REPLICATION;
}

// Perform full replication during primary failover
Copy link
Owner

Choose a reason for hiding this comment

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

primary relocation.

@@ -642,7 +642,7 @@ public void handleException(TransportException exp) {
primaryRequest.getPrimaryTerm(),
initialRetryBackoffBound,
retryTimeout,
indexShard.isRemoteTranslogEnabled()
indexShard.isRemoteTranslogEnabled() || indexShard.indexSettings().isRemoteNode()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets subsume the check of indexShard.indexSettings().isRemoteNode() inside the indexShard.isRemoteTranslogEnabled() check itself?

@@ -1089,10 +1089,6 @@ private ReplicationGroup calculateReplicationGroup() {
newVersion = replicationGroup.getVersion() + 1;
}

assert indexSettings().isRemoteTranslogStoreEnabled()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets not remove this assertion. Removing this can pose risks to bugs.

We can check first if index is remote enabled, or if there is an inflight migration, or all tracked shards are replicated.

Comment on lines +1247 to +1254
&& latestReplicationCheckpoint.isAheadOf(cps.visibleReplicationCheckpoint)
/*
Handle remote store migration cases. Replication Lag timers would be created if the node on which primary is hosted is either:
- Segrep enabled without remote store
- Destination replica shard is hosted on a remote store enabled node (Remote store enabled nodes have segrep enabled implicitly)
*/
&& (indexSettings.isSegRepLocalEnabled() == true
|| routingTable.getByAllocationId(allocationId).isAssignedToRemoteStoreNode() == true)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really clear on why is this being added?

- If remote translog is enabled, then returns true if given allocation id matches the primary or it's relocation target allocation primary and primary target allocation id.
- During an ongoing remote migration, the above-mentioned checks are considered when the shard is assigned to a remote store backed node
*/
if (indexSettings().isRemoteTranslogStoreEnabled() || assignedToRemoteStoreNode == true) {
return (allocationId.equals(primaryAllocationId) || allocationId.equals(primaryTargetAllocationId));
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we return false if the if condition holds true since the remote translogs would anyways be downloaded on the relocating primary?

Comment on lines +214 to +216
if (RemoteStoreUtils.isMigrationDirectionSet(clusterService)) {
return ReplicationMode.FULL_REPLICATION;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need it on shards that are on remote store already?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question applicable for other actions as well.

@@ -3328,7 +3333,7 @@ public void syncRetentionLeases() {
)
);
} else {
logger.trace("background syncing retention leases [{}] after expiration check", retentionLeases.v2());
logger.info("background syncing retention leases [{}] after expiration check", retentionLeases.v2());
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need this with info level?

Comment on lines 4630 to 4633
// Explicitly disable search idle during remote store migration
if (RemoteStoreUtils.isMigrationDirectionSet(clusterService)) {
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious on why is this required?

@@ -340,7 +340,7 @@ private void onSuccessfulSegmentsSync(
resetBackOffDelayIterator();
// Set the minimum sequence number for keeping translog
indexShard.getEngine().translogManager().setMinSeqNoToKeep(lastRefreshedCheckpoint + 1);
// Publishing the new checkpoint which is used for remote store + segrep indexes
// Publishing the new checkpoint which is used for remote store + segrep indexess
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets remove this unintended change?

DiscoveryNode targetNode = nodes.getLocalNode();
// Set remote attributes on Shard routing if the target node for the shards has remote attributes
if (targetNode.isRemoteStoreNode()) {
shardRouting.setAssignedToRemoteStoreNode(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

appears to be error prone, is there a way to have this as final and set inside ctor?

@@ -1096,4 +1102,14 @@ enum IndexRemovalReason {
REOPENED,
}
}

private void updateShardRoutingWithNode(IndexShardRoutingTable indexShardRoutingTable, DiscoveryNodes nodes) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a way this can be done within ctor only?

Copy link
Collaborator

@ashking94 ashking94 left a comment

Choose a reason for hiding this comment

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

Left some comments, please take a look at them.

Signed-off-by: Shourya Dutta Biswas <[email protected]>
Signed-off-by: Shourya Dutta Biswas <[email protected]>
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