Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
[Elasticsearch] Fix reporting of dropped by duplicate metrics (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuhlha authored Jul 21, 2020
1 parent f2e6baa commit 6353fef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ protected <T> Transform<Throwable, T> handleVersionConflict(
Provider<T> emptyProvider, Runnable reportWriteDroppedByDuplicate
) {
return throwable -> {
if (ExceptionUtils.getRootCause(throwable) instanceof VersionConflictEngineException) {
if (ExceptionUtils.getRootCause(throwable) instanceof VersionConflictEngineException ||
throwable.getMessage().contains("version_conflict_engine_exception")) {
// Index request rejected, document already exists. That's ok, return success.
reportWriteDroppedByDuplicate.run();
return emptyProvider.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.spotify.heroic.elasticsearch.ClientWrapper;
import com.spotify.heroic.elasticsearch.ConnectionModule;
import com.spotify.heroic.elasticsearch.index.RotatingIndexMapping;
import com.spotify.heroic.metric.RequestError;
import com.spotify.heroic.suggest.SuggestModule;
import com.spotify.heroic.suggest.WriteSuggest;
import com.spotify.heroic.test.AbstractSuggestBackendIT;
Expand Down Expand Up @@ -69,5 +70,10 @@ public void writeDuplicatesReturnErrorInResponse() throws Exception {

assertEquals(0, firstWrite.getErrors().size());
assertEquals(2, secondWrite.getErrors().size());

for (final RequestError e : secondWrite.getErrors()) {
assert (e.toString().contains("VersionConflictEngineException") ||
e.toString().contains("version_conflict_engine_exception"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,9 @@ public AsyncFuture<WriteSuggest> write(
errors.add(NodeError.internalError(r.getFailureMessage()));

if (r.getFailure().getCause()
instanceof VersionConflictEngineException) {
instanceof VersionConflictEngineException ||
r.getFailure().getMessage()
.contains("version_conflict_engine_exception")) {
reporter.reportWriteDroppedByDuplicate();
} else if (addFailureAnnotation) {
rootSpan.addAnnotation(r.getFailureMessage());
Expand Down

0 comments on commit 6353fef

Please sign in to comment.