-
Notifications
You must be signed in to change notification settings - Fork 58
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
Conversation
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.
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, |
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.
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.
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.
after looking at #410, this addSimple looks the same as the old add function.
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.
+1 to the suggestion.
Also suggest to rename addSimple
to something for descriptive maybe addWithoutPreIngestionLamdba
?
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.
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); |
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.
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.
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.
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(); |
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.
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;
}
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.
DatasetAccountableOwnership
is specially handled? It needs to call urn converter
and then write to TMS?
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.
Somehow I remember DatasetAccountableOwnership
is deprecated and got replaced by AccountableOwnership
?
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.
@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.
restli-resources/src/main/java/com/linkedin/metadata/restli/BaseAspectRoutingResource.java
Outdated
Show resolved
Hide resolved
* Please use the regular add method linked above. | ||
*/ | ||
@Nonnull | ||
public <ASPECT extends RecordTemplate> ASPECT addSimple(@Nonnull URN urn, @Nonnull ASPECT newValue, |
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.
+1 to the suggestion.
Also suggest to rename addSimple
to something for descriptive maybe addWithoutPreIngestionLamdba
?
restli-resources/src/main/java/com/linkedin/metadata/restli/BaseAspectRoutingResource.java
Outdated
Show resolved
Hide resolved
if (_restliPreUpdateAspectRegistry != null && _restliPreUpdateAspectRegistry.isRegistered( | ||
aspect.getClass())) { | ||
aspect = preUpdateRouting(urn, aspect); | ||
} | ||
// Get the fqcn of the aspect class | ||
String aspectFQCN = aspect.getClass().getCanonicalName(); |
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.
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(); |
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.
Somehow I remember DatasetAccountableOwnership
is deprecated and got replaced by AccountableOwnership
?
5fa6df4
to
298e5cc
Compare
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.
Should we conduct some testing in EI before promoting to corp?
restli-resources/src/test/java/com/linkedin/metadata/restli/BaseAspectRoutingResourceTest.java
Outdated
Show resolved
Hide resolved
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.
Looks good, thank you for addressing all the comments
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
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