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

implement dual write in BaseAspectRoutingResource #420

Merged
merged 5 commits into from
Sep 16, 2024

Conversation

jsdonn
Copy link
Contributor

@jsdonn jsdonn commented Sep 11, 2024

Summary

Change the behavior of BaseAspectRoutingResource's ingestInternal method to write any routed aspects locally in addition to routing the request to another GMS.

Details

  1. Update ingestInternal and ingestAssetInternal with the same logic
  2. Move resource-level pre-ingestion lambdas into the if statement which checks if an aspect has a registered routing client.
  3. In the aspect routing branch of the if statement, also call a new local DAO API addSimple which will store the aspect locally without executing any pre-ingestion lambdas within BaseLocalDAO. This is to prevent the case where a pre-ingestion lambda is executed twice in one ingestion (one before the routing, one within the local DAO).

Testing Done

Update existing unit tests to expect dual-write behavior. Added some comments for context.

Checklist

Copy link
Contributor

@ybz1013 ybz1013 left a comment

Choose a reason for hiding this comment

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

I dont really have the context from #410. Just left some comments.

* Please use the regular add method linked above.
*/
@Nonnull
public <ASPECT extends RecordTemplate> ASPECT addSimple(@Nonnull URN urn, @Nonnull ASPECT newValue,
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 further reduce duplicate code (864-866) by adding a param like isPreupdateLambasEnabled in a new add function? Then the old add and this addSimple can both call that.

Copy link
Contributor

Choose a reason for hiding this comment

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

after looking at #410, this addSimple looks the same as the old add function.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to the suggestion.
Also suggest to rename addSimple to something for descriptive maybe addWithoutPreIngestionLamdba?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to addSkipPreIngestionUpdates

@@ -315,10 +316,6 @@ protected Task<Void> ingestInternal(@Nonnull SNAPSHOT snapshot,
final AuditStamp auditStamp = getAuditor().requestAuditStamp(getContext().getRawRequestContext());
ModelUtils.getAspectsFromSnapshot(snapshot).forEach(aspect -> {
if (!aspectsToIgnore.contains(aspect.getClass())) {
if (_restliPreUpdateAspectRegistry != null && _restliPreUpdateAspectRegistry.isRegistered(
aspect.getClass())) {
aspect = preUpdateRouting(urn, aspect);
Copy link
Contributor

Choose a reason for hiding this comment

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

question: does this mean the old code will execute preUpdateRouting twice if the aspect is registered in the _restliPreUpdateAspectRegistry AND not a routed aspect? Once here, and once in the add function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes exactly, old code would have executed preUpdateRouting twice in the case you mentioned.

if (_restliPreUpdateAspectRegistry != null && _restliPreUpdateAspectRegistry.isRegistered(
aspect.getClass())) {
aspect = preUpdateRouting(urn, aspect);
}
// Get the fqcn of the aspect class
String aspectFQCN = aspect.getClass().getCanonicalName();
Copy link
Contributor

Choose a reason for hiding this comment

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

This was added specifically for DatasetAccountableOwnership aspect to skip the normal ingestion once the preUpdateRouting is done and not go to OwnershipGMS. Can you move this lines after we call preUpdateRouting (Line 330).

// Get the fqcn of the aspect class
          String aspectFQCN = aspect.getClass().getCanonicalName();
          //TODO: META-21112: Remove this check after adding annotations at model level; to handle SKIP/PROCEED for preUpdateRouting
          if (SKIP_INGESTION_FOR_ASPECTS.contains(aspectFQCN)) {
            return;
          }

Copy link
Contributor

Choose a reason for hiding this comment

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

DatasetAccountableOwnership is specially handled? It needs to call urn converter and then write to TMS?

Copy link
Contributor

Choose a reason for hiding this comment

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

Somehow I remember DatasetAccountableOwnership is deprecated and got replaced by AccountableOwnership?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rakhiagr will do thanks for the pointer.

@hongliu2024 afaik DatasetAccountableOwnership is not deprecated, it's only used by Dataset entity type. But I don't have any doc on that, that's just what I know from before. Is the deprecation a recent thing? I checked dataset entity table schema, there's no AccountableOwnership column and also there's no MCE_Dataset_AccountableOwnership topic registered in nuage.

* Please use the regular add method linked above.
*/
@Nonnull
public <ASPECT extends RecordTemplate> ASPECT addSimple(@Nonnull URN urn, @Nonnull ASPECT newValue,
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to the suggestion.
Also suggest to rename addSimple to something for descriptive maybe addWithoutPreIngestionLamdba?

if (_restliPreUpdateAspectRegistry != null && _restliPreUpdateAspectRegistry.isRegistered(
aspect.getClass())) {
aspect = preUpdateRouting(urn, aspect);
}
// Get the fqcn of the aspect class
String aspectFQCN = aspect.getClass().getCanonicalName();
Copy link
Contributor

Choose a reason for hiding this comment

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

DatasetAccountableOwnership is specially handled? It needs to call urn converter and then write to TMS?

if (_restliPreUpdateAspectRegistry != null && _restliPreUpdateAspectRegistry.isRegistered(
aspect.getClass())) {
aspect = preUpdateRouting(urn, aspect);
}
// Get the fqcn of the aspect class
String aspectFQCN = aspect.getClass().getCanonicalName();
Copy link
Contributor

Choose a reason for hiding this comment

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

Somehow I remember DatasetAccountableOwnership is deprecated and got replaced by AccountableOwnership?

@jsdonn jsdonn force-pushed the dual-write branch 2 times, most recently from 5fa6df4 to 298e5cc Compare September 11, 2024 18:50
Copy link
Contributor

@hongliu2024 hongliu2024 left a comment

Choose a reason for hiding this comment

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

Should we conduct some testing in EI before promoting to corp?

Copy link
Contributor

@rakhiagr rakhiagr left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for addressing all the comments

@jsdonn jsdonn merged commit af0995a into linkedin:master Sep 16, 2024
2 checks passed
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.

4 participants