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

Fix ES call timeout incorrectly working with Vertx context #1409

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all 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 @@ -8,6 +8,7 @@
import static com.gentics.mesh.search.verticle.eventhandler.RxUtil.retryWithDelay;
import static com.gentics.mesh.search.verticle.eventhandler.Util.logElasticSearchError;

import java.net.SocketTimeoutException;
import java.time.Duration;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -386,18 +387,26 @@ private Flowable<? extends SearchRequest> generateRequests(MessageEvent messageE
return Flowable.empty();
}
try {
AtomicInteger retried = new AtomicInteger(options.getRetryLimit());
return this.mainEventhandler.handle(messageEvent)
.doOnNext(request -> {
if (log.isTraceEnabled()) {
log.trace("Request+{}", request);
}
idleChecker.addAndGetRequests(request.requestCount());
})
.doOnError(err -> logElasticSearchError(err, () -> {
if (err instanceof SocketTimeoutException && retried.get() > 0) {
log.info("Transforming event " + messageEvent.event + " process timed out on retry #" + retried.getAndDecrement(), err);
idleChecker.decrementAndGetTransformations();
} else {
log.error("Error transforming event " + messageEvent.event, err);
}
}))
.retryWhen(retryWithDelay(
Duration.ofMillis(options.getRetryInterval()),
options.getRetryLimit()))
.doOnComplete(
() -> log.trace("Done transforming event {}. Transformations pending: {}", messageEvent.event, idleChecker.getTransformations()))
.doOnComplete(() -> log.trace("Done transforming event {}. Transformations pending: {}", messageEvent.event, idleChecker.getTransformations()))
.doOnTerminate(idleChecker::decrementAndGetTransformations);
} catch (Exception e) {
// For safety to keep the verticle always running
Expand Down