diff --git a/metadata-io/src/main/java/com/linkedin/metadata/entity/EntityServiceImpl.java b/metadata-io/src/main/java/com/linkedin/metadata/entity/EntityServiceImpl.java index 32c77b66679f9b..c7a9895992d90b 100644 --- a/metadata-io/src/main/java/com/linkedin/metadata/entity/EntityServiceImpl.java +++ b/metadata-io/src/main/java/com/linkedin/metadata/entity/EntityServiceImpl.java @@ -146,7 +146,7 @@ public class EntityServiceImpl implements EntityService { OBJECT_MAPPER.getFactory().setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(maxSize).build()); } - private static final int DEFAULT_MAX_TRANSACTION_RETRY = 3; + private static final int DEFAULT_MAX_TRANSACTION_RETRY = 4; protected final AspectDao _aspectDao; private final EventProducer _producer; @@ -163,6 +163,8 @@ public class EntityServiceImpl implements EntityService { // TODO(iprentic): Move this to a common utils location once used in other places private static final String DELIMITER_SEPARATOR = "␟"; + private final Integer ebeanMaxTransactionRetry; + public EntityServiceImpl( @Nonnull final AspectDao aspectDao, @Nonnull final EventProducer producer, @@ -170,6 +172,17 @@ public EntityServiceImpl( final boolean alwaysEmitChangeLog, final UpdateIndicesService updateIndicesService, final PreProcessHooks preProcessHooks) { + this(aspectDao, producer, entityRegistry, alwaysEmitChangeLog, updateIndicesService, preProcessHooks, DEFAULT_MAX_TRANSACTION_RETRY); + } + + public EntityServiceImpl( + @Nonnull final AspectDao aspectDao, + @Nonnull final EventProducer producer, + @Nonnull final EntityRegistry entityRegistry, + final boolean alwaysEmitChangeLog, + final UpdateIndicesService updateIndicesService, + final PreProcessHooks preProcessHooks, + final Integer retry) { _aspectDao = aspectDao; _producer = producer; @@ -178,8 +191,11 @@ public EntityServiceImpl( _alwaysEmitChangeLog = alwaysEmitChangeLog; _updateIndicesService = updateIndicesService; _preProcessHooks = preProcessHooks; + ebeanMaxTransactionRetry = retry != null ? retry : DEFAULT_MAX_TRANSACTION_RETRY; } + + /** * Retrieves the latest aspects corresponding to a batch of {@link Urn}s based on a provided * set of aspect names. diff --git a/metadata-service/factories/src/main/java/com/linkedin/gms/factory/entity/EntityServiceFactory.java b/metadata-service/factories/src/main/java/com/linkedin/gms/factory/entity/EntityServiceFactory.java index b8edd6918dc6c7..63ac26f124fef5 100644 --- a/metadata-service/factories/src/main/java/com/linkedin/gms/factory/entity/EntityServiceFactory.java +++ b/metadata-service/factories/src/main/java/com/linkedin/gms/factory/entity/EntityServiceFactory.java @@ -14,6 +14,7 @@ import org.apache.avro.generic.IndexedRecord; import org.apache.kafka.clients.producer.Producer; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; @@ -24,6 +25,9 @@ @Configuration public class EntityServiceFactory { + @Value("${EBEAN_MAX_TRANSACTION_RETRY:4}") + private Integer _ebeanMaxTransactionRetry; + @Bean(name = "entityService") @DependsOn({"entityAspectDao", "kafkaEventProducer", "kafkaHealthChecker", TopicConventionFactory.TOPIC_CONVENTION_BEAN, "entityRegistry"}) @@ -40,6 +44,6 @@ protected EntityService createInstance( final KafkaEventProducer eventProducer = new KafkaEventProducer(producer, convention, kafkaHealthChecker); FeatureFlags featureFlags = configurationProvider.getFeatureFlags(); return new EntityServiceImpl(aspectDao, eventProducer, entityRegistry, - featureFlags.isAlwaysEmitChangeLog(), updateIndicesService, featureFlags.getPreProcessHooks()); + featureFlags.isAlwaysEmitChangeLog(), updateIndicesService, featureFlags.getPreProcessHooks(), _ebeanMaxTransactionRetry); } }