CCR: Remove non-primary origin assertions from operation planners#20952
CCR: Remove non-primary origin assertions from operation planners#20952mishail wants to merge 2 commits into
Conversation
Signed-off-by: Mikhail Stepura <mstepura@apple.com>
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit ef96603.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Another option, if we do want to keep those assertions in Planners, would be adding // In InternalEngine:
protected IndexingStrategyPlanner createIndexingStrategyPlanner(...) {
return new IndexingStrategyPlanner(...);
}
protected DeletionStrategyPlanner createDeletionStrategyPlanner(...) {
return new DeletionStrategyPlanner(...);
} |
|
cc @shank9918 |
|
@mishail Can you please sync with main? There are a few test fixes that this feature branch would need to get for CI checks to pass. |
@mishail Can we please fix this typo while at it? maybe even change the text entirely. At least for me, its hard to tell what the purpose is. After inspecting the call sites, I agree these calls are redundant. |
|
@mishail FYI I updated to include the latest commits on main which includes test fixes. You may need to pull before push. I left one comment about updating an error message. That can either be addressed here or a separate PR, its not a blocker. |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 71ab4d4.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
❌ Gradle check result for 71ab4d4: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
@mishail how does this fix the issue in CCR repo exactly? I see that they always call planIndexingAsNonPrimary regardless of origin type. Presumably the fix lies in CCR repo? |
@cwperks The problem is that this piece in their ReplicationEngine doesn't work the way it used to work anymore. override fun assertNonPrimaryOrigin(operation: Operation): Boolean {
return true
}
|
|
@mishail I'm not deep in this area unfortunately, but can the ReplicationEngine in CCR follow same pattern as InternalEngine? See comment here: https://github.com/opensearch-project/cross-cluster-replication/pull/1647/changes#r2982353370 |
|
@cwperks are we going to use opensearch-project/cross-cluster-replication#1647 to fix the issue? |
yes and I think that's the appropriate place to put it because this is logic specific to the CCR repo. My understanding from @mohit10011999 is that in CCR all indexing operations to the follower cluster are to be treated as replicas so the nature of that fix is to "spoof" the index operation to always say its origin replica by nature of it being an indexing op on the following cluster. |
|
Do let me know if you have other thoughts though. |
Disclaimer: portions of this text were reformatted and edited with the assistance of generative AI tools for clarity and readability. The analysis and technical content originate from the author.
Description
OpenSearch commit 59be6ae / #20585 refactored
InternalEngineto extract its two large inner static classes into separate top-level files:InternalEngine.IndexingStrategy→ top-levelIndexingStrategy extends OperationStrategyInternalEngine.DeletionStrategy→ top-levelDeletionStrategy extends OperationStrategyIt also introduced
IndexingStrategyPlannerandDeletionStrategyPlanner— classes that encapsulate the planning logic previously inlined inInternalEngine.The refactor broke CCR's
ReplicationEnginein two ways. See opensearch-project/cross-cluster-replication#1646ReplicationEngine.ktreferencesIndexingStrategyandDeletionStrategy. These were previously inner static classes ofInternalEngine; they are now top-level classes inorg.opensearch.index.engineand require explicit imports. Two lines change on the CCR side.This affects a lot of tests in CCR at the moment.
And that happens because of introduction of
OperationStrategyPlanners and more specifically because those planners now have their ownassertNonPrimaryOrigin, which CCR'sReplicationEnginehas no way to override.The old way:
ReplicationEngine.indexingStrategyForOperationalways callsplanIndexingAsNonPrimaryReplicationEngine.assertNonPrimaryOriginoverridesInternalEngine.assertNonPrimaryOriginto returntrue, bypassing the origin check insideInternalEngine.planIndexingAsNonPrimaryandplanDeletionAsNonPrimaryAfter the refactor,
InternalEngine.planIndexingAsNonPrimaryandplanDeletionAsNonPrimarydelegate to privateIndexingStrategyPlanner/DeletionStrategyPlannerinstances. Both planners callassertNonPrimaryOrigin(operation)internally, which comes fromOperationStrategyPlanner, which is entirely separate fromInternalEngine.assertNonPrimaryOrigin. SoReplicationEngine.assertNonPrimaryOriginis never invoked, and the assertion fires.Proposed solution:
Remove the
assert assertNonPrimaryOrigin(...)calls fromIndexingStrategyPlanner.planOperationAsNonPrimary(line 162) andDeletionStrategyPlanner.planOperationAsNonPrimary(line 117).Rationale: These asserts call
assertNonPrimaryOriginthrough theOperationStrategyPlannerinterface's default method, a path that bypassesInternalEngine.assertNonPrimaryOriginand any overrides defined inInternalEnginesubclasses (such asReplicationEngine). This breaksInternalEngine's established extensibility contract: subclasses that legitimately overrideassertNonPrimaryOrigincan no longer influence this check. Removing the asserts from the planners restores that contract. The check that matters — the one that IS overridable — remains inInternalEngine.planIndexingAsNonPrimaryandplanDeletionAsNonPrimary.Pros:
Cons:
Related Issues
Resolves opensearch-project/cross-cluster-replication#1646
Check List
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.