Skip to content

Commit

Permalink
catch duplicate entry errors and silently fail (#492)
Browse files Browse the repository at this point in the history
* catch duplicate entry errors and silently fail

* add null check to error message

* throw other errors

---------

Co-authored-by: Justin Donn <[email protected]>
  • Loading branch information
jsdonn and Justin Donn authored Jan 13, 2025
1 parent d2e3af5 commit 62f596e
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,16 @@ 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) {
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());
} else {
throw e;
}
}
}
}

Expand Down

0 comments on commit 62f596e

Please sign in to comment.