Skip to content
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

catch duplicate entry errors and silently fail #492

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

jsdonn
Copy link
Contributor

@jsdonn jsdonn commented Jan 13, 2025

Summary

Catch duplicate entry exceptions during server.insert() due to race conditions.
Log at WARN level.

Exceptions from before:

Error[Duplicate entry 'urn:li:mlFeatureAnchor:(urn:li:mlFeatureVersion:(urn:li:mlFeatur' for key 'metadata_aspect.PRIMARY']
at io.ebean.config.dbplatform.SqlCodeTranslator.translate(SqlCodeTranslator.java:46)
at io.ebean.config.dbplatform.DatabasePlatform.translate(DatabasePlatform.java:223)
at io.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:83)
at io.ebeaninternal.server.persist.dml.DmlBeanPersister.insert(DmlBeanPersister.java:49)
at io.ebeaninternal.server.core.PersistRequestBean.executeInsert(PersistRequestBean.java:1295)
at io.ebeaninternal.server.core.PersistRequestBean.executeNow(PersistRequestBean.java:797)
at io.ebeaninternal.server.core.PersistRequestBean.executeNoBatch(PersistRequestBean.java:852)
at io.ebeaninternal.server.core.PersistRequestBean.executeOrQueue(PersistRequestBean.java:843)
at io.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:525)
at io.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:471)
at io.ebeaninternal.server.core.DefaultServer.insert(DefaultServer.java:1773)
at io.ebeaninternal.server.core.DefaultServer.insert(DefaultServer.java:1765)
at com.linkedin.metadata.dao.EbeanLocalDAO.insert(EbeanLocalDAO.java:855)
at com.linkedin.metadata.dao.EbeanLocalDAO.saveLatest(EbeanLocalDAO.java:627)
at com.linkedin.metadata.dao.BaseLocalDAO.addCommon(BaseLocalDAO.java:523)

Testing Done

N/A

Checklist

@jsdonn jsdonn marked this pull request as ready for review January 13, 2025 23:11
_server.insert(aspect);
try {
_server.insert(aspect);
} catch (Exception e) {
Copy link
Contributor

@yangyangv2 yangyangv2 Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you only silent the known error:

catch (Exception e) {
    Throwable cause = e.getCause();
    if (cause != null && cause.getMessage().contains("Duplicate entry")) {
        log.warn("Duplicate key error during insert. Exception: {}", e.toString());
    } else {
       throw e;
    }
}

Copy link
Contributor

@yangyangv2 yangyangv2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please copy the stack trace info the PR description for tracking purposes. Thanks!

Error[Duplicate entry 'urn:li:mlFeatureAnchor:(urn:li:mlFeatureVersion:(urn:li:mlFeatur' for key 'metadata_aspect.PRIMARY']
at io.ebean.config.dbplatform.SqlCodeTranslator.translate(SqlCodeTranslator.java:46)
at io.ebean.config.dbplatform.DatabasePlatform.translate(DatabasePlatform.java:223)
at io.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:83)
at io.ebeaninternal.server.persist.dml.DmlBeanPersister.insert(DmlBeanPersister.java:49)
at io.ebeaninternal.server.core.PersistRequestBean.executeInsert(PersistRequestBean.java:1295)
at io.ebeaninternal.server.core.PersistRequestBean.executeNow(PersistRequestBean.java:797)
at io.ebeaninternal.server.core.PersistRequestBean.executeNoBatch(PersistRequestBean.java:852)
at io.ebeaninternal.server.core.PersistRequestBean.executeOrQueue(PersistRequestBean.java:843)
at io.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:525)
at io.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:471)
at io.ebeaninternal.server.core.DefaultServer.insert(DefaultServer.java:1773)
at io.ebeaninternal.server.core.DefaultServer.insert(DefaultServer.java:1765)
at com.linkedin.metadata.dao.EbeanLocalDAO.insert(EbeanLocalDAO.java:855)
at com.linkedin.metadata.dao.EbeanLocalDAO.saveLatest(EbeanLocalDAO.java:627)
at com.linkedin.metadata.dao.BaseLocalDAO.addCommon(BaseLocalDAO.java:523)

@jsdonn jsdonn merged commit 62f596e into linkedin:master Jan 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants