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
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,14 @@ protected <ASPECT extends RecordTemplate> void insert(@Nonnull URN urn, @Nullabl
// 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);
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;
    }
}

if (e.getMessage() != null && e.getMessage().contains("Duplicate entry")) {
// silently fail and log the error
log.warn("Insert to metadata_aspect failed due to duplicate entry exception. Exception: {}", e.toString());
}
}
}
}

Expand Down
Loading