@@ -1051,7 +1051,8 @@ This condition is specifically for an older conditional write ingestAspectIfNotP
1051
1051
}
1052
1052
} else {
1053
1053
MetricUtils .counter (EntityServiceImpl .class , "batch_empty_transaction" ).inc ();
1054
- log .warn ("Empty transaction detected. {}" , inputBatch );
1054
+ // This includes no-op batches. i.e. patch removing non-existent items
1055
+ log .debug ("Empty transaction detected. {}" , inputBatch );
1055
1056
}
1056
1057
1057
1058
return upsertResults ;
@@ -2533,9 +2534,6 @@ private UpdateAspectResult ingestAspectToLocalDB(
2533
2534
.setLastRunId (writeItem .getSystemMetadata ().getRunId (GetMode .NULL ), SetMode .IGNORE_NULL );
2534
2535
2535
2536
// 2. Compare the latest existing and new.
2536
- final RecordTemplate databaseValue =
2537
- databaseAspect == null ? null : databaseAspect .getRecordTemplate ();
2538
-
2539
2537
final EntityAspect .EntitySystemAspect previousBatchAspect =
2540
2538
(EntityAspect .EntitySystemAspect ) writeItem .getPreviousSystemAspect ();
2541
2539
final RecordTemplate previousValue =
@@ -2544,43 +2542,49 @@ private UpdateAspectResult ingestAspectToLocalDB(
2544
2542
// 3. If there is no difference between existing and new, we just update
2545
2543
// the lastObserved in system metadata. RunId should stay as the original runId
2546
2544
if (previousValue != null
2547
- && DataTemplateUtil .areEqual (databaseValue , writeItem .getRecordTemplate ())) {
2545
+ && DataTemplateUtil .areEqual (previousValue , writeItem .getRecordTemplate ())) {
2548
2546
2549
2547
SystemMetadata latestSystemMetadata = previousBatchAspect .getSystemMetadata ();
2550
2548
latestSystemMetadata .setLastObserved (writeItem .getSystemMetadata ().getLastObserved ());
2551
2549
latestSystemMetadata .setLastRunId (
2552
2550
writeItem .getSystemMetadata ().getLastRunId (GetMode .NULL ), SetMode .IGNORE_NULL );
2553
2551
2554
- previousBatchAspect
2555
- .getEntityAspect ()
2556
- .setSystemMetadata (RecordUtils .toJsonString (latestSystemMetadata ));
2557
-
2558
- log .info (
2559
- "Ingesting aspect with name {}, urn {}" ,
2560
- previousBatchAspect .getAspectName (),
2561
- previousBatchAspect .getUrn ());
2562
- aspectDao .saveAspect (txContext , previousBatchAspect .getEntityAspect (), false );
2563
-
2564
- // metrics
2565
- aspectDao .incrementWriteMetrics (
2566
- previousBatchAspect .getAspectName (),
2567
- 1 ,
2568
- previousBatchAspect .getMetadataRaw ().getBytes (StandardCharsets .UTF_8 ).length );
2569
-
2570
- return UpdateAspectResult .builder ()
2571
- .urn (writeItem .getUrn ())
2572
- .oldValue (previousValue )
2573
- .newValue (previousValue )
2574
- .oldSystemMetadata (previousBatchAspect .getSystemMetadata ())
2575
- .newSystemMetadata (latestSystemMetadata )
2576
- .operation (MetadataAuditOperation .UPDATE )
2577
- .auditStamp (writeItem .getAuditStamp ())
2578
- .maxVersion (0 )
2579
- .build ();
2552
+ if (!latestSystemMetadata .equals (previousBatchAspect .getSystemMetadata ())) {
2553
+
2554
+ previousBatchAspect
2555
+ .getEntityAspect ()
2556
+ .setSystemMetadata (RecordUtils .toJsonString (latestSystemMetadata ));
2557
+
2558
+ log .debug (
2559
+ "Update aspect with name {}, urn {}" ,
2560
+ previousBatchAspect .getAspectName (),
2561
+ previousBatchAspect .getUrn ());
2562
+ aspectDao .saveAspect (txContext , previousBatchAspect .getEntityAspect (), false );
2563
+
2564
+ // metrics
2565
+ aspectDao .incrementWriteMetrics (
2566
+ previousBatchAspect .getAspectName (),
2567
+ 1 ,
2568
+ previousBatchAspect .getMetadataRaw ().getBytes (StandardCharsets .UTF_8 ).length );
2569
+
2570
+ return UpdateAspectResult .builder ()
2571
+ .urn (writeItem .getUrn ())
2572
+ .oldValue (previousValue )
2573
+ .newValue (previousValue )
2574
+ .oldSystemMetadata (previousBatchAspect .getSystemMetadata ())
2575
+ .newSystemMetadata (latestSystemMetadata )
2576
+ .operation (MetadataAuditOperation .UPDATE )
2577
+ .auditStamp (writeItem .getAuditStamp ())
2578
+ .maxVersion (0 )
2579
+ .build ();
2580
+ } else {
2581
+ MetricUtils .counter (EntityServiceImpl .class , "batch_with_noop_sysmetadata" ).inc ();
2582
+ return null ;
2583
+ }
2580
2584
}
2581
2585
2582
2586
// 4. Save the newValue as the latest version
2583
- if (!DataTemplateUtil .areEqual (databaseValue , writeItem .getRecordTemplate ())) {
2587
+ if (!DataTemplateUtil .areEqual (previousValue , writeItem .getRecordTemplate ())) {
2584
2588
log .debug (
2585
2589
"Ingesting aspect with name {}, urn {}" , writeItem .getAspectName (), writeItem .getUrn ());
2586
2590
String newValueStr = EntityApiUtils .toJsonAspect (writeItem .getRecordTemplate ());
0 commit comments