-
Notifications
You must be signed in to change notification settings - Fork 59
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
Persist emitTime from IngestionTrackingContext to the new entity tables and use emitTime during backfill #329
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package com.linkedin.metadata.dao; | ||
|
||
import com.linkedin.avro2pegasus.events.UUID; | ||
import com.linkedin.common.AuditStamp; | ||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.data.template.RecordTemplate; | ||
|
@@ -15,6 +14,7 @@ | |
import com.linkedin.metadata.dao.utils.RecordUtils; | ||
import com.linkedin.metadata.dao.utils.SQLSchemaUtils; | ||
import com.linkedin.metadata.dao.utils.SQLStatementUtils; | ||
import com.linkedin.metadata.events.IngestionTrackingContext; | ||
import com.linkedin.metadata.query.ExtraInfo; | ||
import com.linkedin.metadata.query.ExtraInfoArray; | ||
import com.linkedin.metadata.query.IndexFilter; | ||
|
@@ -92,14 +92,18 @@ public void ensureSchemaUpToDate() { | |
@Override | ||
@Transactional | ||
public <ASPECT extends RecordTemplate> int add(@Nonnull URN urn, @Nullable ASPECT newValue, @Nonnull Class<ASPECT> aspectClass, | ||
@Nonnull AuditStamp auditStamp, @Nullable UUID messageId) { | ||
return addWithOptimisticLocking(urn, newValue, aspectClass, auditStamp, null, messageId); | ||
@Nonnull AuditStamp auditStamp, @Nullable IngestionTrackingContext ingestionTrackingContext) { | ||
return addWithOptimisticLocking(urn, newValue, aspectClass, auditStamp, null, ingestionTrackingContext); | ||
} | ||
|
||
@Override | ||
public <ASPECT extends RecordTemplate> int addWithOptimisticLocking(@Nonnull URN urn, @Nullable ASPECT newValue, | ||
@Nonnull Class<ASPECT> aspectClass, @Nonnull AuditStamp auditStamp, @Nonnull Timestamp oldTimestamp, | ||
@Nullable UUID messageId) { | ||
public <ASPECT extends RecordTemplate> int addWithOptimisticLocking( | ||
@Nonnull URN urn, | ||
@Nullable ASPECT newValue, | ||
@Nonnull Class<ASPECT> aspectClass, | ||
@Nonnull AuditStamp auditStamp, | ||
@Nullable Timestamp oldTimestamp, | ||
@Nullable IngestionTrackingContext ingestionTrackingContext) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. messageId was never used before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope. Intellij didn't have much trouble removing that param. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it mean we'll have a new messageId during the backfill? or the backfill's messageId is always null? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the param was before I added the backfill feature. It was an unused param. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. talked offline with @yangyangv2 . For the method |
||
|
||
final long timestamp = auditStamp.hasTime() ? auditStamp.getTime() : System.currentTimeMillis(); | ||
final String actor = auditStamp.hasActor() ? auditStamp.getActor().toString() : DEFAULT_ACTOR; | ||
|
@@ -151,6 +155,9 @@ public <ASPECT extends RecordTemplate> int addWithOptimisticLocking(@Nonnull URN | |
.setLastmodifiedby(actor) | ||
.setLastmodifiedon(new Timestamp(timestamp).toString()) | ||
.setCreatedfor(impersonator, SetMode.IGNORE_NULL); | ||
if (ingestionTrackingContext != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be safer and more clear to still create IngestionTrackingContext in the input and here we check
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think your comment is missing some code? |
||
auditedAspect.setEmitTime(ingestionTrackingContext.getEmitTime(), SetMode.IGNORE_NULL); | ||
} | ||
|
||
final String metadata = toJsonString(auditedAspect); | ||
return sqlUpdate.setParameter("metadata", metadata).execute(); | ||
|
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.
in what scenario trackingContext will be null and we want to enforce it's setBackfill to be false?
Can we log such as enforcement activity to capture unexpected cases?
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.
it's null when someone calls
ingest
instead ofingestWithTracking
. I can't think of a case where we don't want to setbackfill
tofalse.
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 isBackfill field in the ingestionTrackingContext is ONLY used for MCE backfills right? I believe Jinxin added a separate field for MAE backfill. If that's the case then yeah we always want to set it to false during MAE emission. But I hope that this is clear enough for ourselves and future devs...might be a little confusing to have 2 backfill related fields in an MAE.