From 90206c86ed8cf6f109d3f4ab2ece070fbe879699 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 17 Sep 2024 14:00:51 -0400 Subject: [PATCH] Fix for duplicate writing in test mode (#428) --- .../java/com/linkedin/metadata/dao/EbeanLocalDAO.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dao-impl/ebean-dao/src/main/java/com/linkedin/metadata/dao/EbeanLocalDAO.java b/dao-impl/ebean-dao/src/main/java/com/linkedin/metadata/dao/EbeanLocalDAO.java index c26974f3f..2f70cac78 100644 --- a/dao-impl/ebean-dao/src/main/java/com/linkedin/metadata/dao/EbeanLocalDAO.java +++ b/dao-impl/ebean-dao/src/main/java/com/linkedin/metadata/dao/EbeanLocalDAO.java @@ -863,8 +863,12 @@ protected void insert(@Nonnull URN urn, @Nullabl _localAccess.add(urn, (ASPECT) value, aspectClass, auditStamp, trackingContext, isTestMode); } - if (_changeLogEnabled) { - // skip appending change log table (metadata_aspect) if not enabled + // DO append change log table (metadata_aspect) if: + // 1. explicitly enabled + // AND + // 2. if NOT in test mode + // -> which is ALWAYS a dual-write operation (meaning this insertion will already happen in the "other" write) + if (_changeLogEnabled && !isTestMode) { _server.insert(aspect); } }