Skip to content

Commit

Permalink
Merge pull request #300 from yrodiere/indexing-retry
Browse files Browse the repository at this point in the history
Indexing retry
  • Loading branch information
yrodiere authored Jul 15, 2024
2 parents 9ca9dbd + 1440490 commit 4ef8627
Show file tree
Hide file tree
Showing 28 changed files with 1,128 additions and 446 deletions.
16 changes: 8 additions & 8 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ By default, in dev mode, any parsing/indexing warnings and errors are going to b
But in case you want to get index errors reported to a GitHub issue, next properties should be added:
[source,properties]
----
_DEV_INDEXING_ERROR_REPORTING_TYPE=github-issue
_DEV_INDEXING_REPORTING_TYPE=github-issue
# see about tokens https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
INDEXING_ERROR_REPORTING_GITHUB_TOKEN={your-generated-github-token}
INDEXING_ERROR_REPORTING_GITHUB_ISSUE_REPOSITORY={your-github-user}/search.quarkus.io
INDEXING_ERROR_REPORTING_GITHUB_ISSUE_ID={github-issue-id-in-your-repository}
INDEXING_ERROR_REPORTING_GITHUB_WARNING_REPEAT_DELAY=10m
INDEXING_REPORTING_GITHUB_TOKEN={your-generated-github-token}
INDEXING_REPORTING_GITHUB_ISSUE_REPOSITORY={your-github-user}/search.quarkus.io
INDEXING_REPORTING_GITHUB_ISSUE_ID={github-issue-id-in-your-repository}
INDEXING_REPORTING_GITHUB_WARNING_REPEAT_DELAY=10m
----

[[testing]]
Expand Down Expand Up @@ -182,7 +182,7 @@ podman container run -it --rm --name search.quarkus.io --pod search.quarkus.io \
-v $REPOS_DIR/es.quarkus.io:/mnt/es.quarkus.io:ro,z \
-v $REPOS_DIR/ja.quarkus.io:/mnt/ja.quarkus.io:ro,z \
-v $REPOS_DIR/pt.quarkus.io:/mnt/pt.quarkus.io:ro,z \
-e INDEXING_ERROR_REPORTING_TYPE=log \
-e INDEXING_REPORTING_TYPE=log \
-e GITHUB_OAUTH=ignored \
-e GITHUB_STATUS_ISSUE_ID=1 \
-e QUARKUSIO_GIT_URI=file:/mnt/quarkus.io \
Expand Down Expand Up @@ -240,7 +240,7 @@ you will need to set up a few things manually:
In particular:
* `GITHUB_STATUS_ISSUE_ID`: The number of an issue on quarkusio/search.quarkus.io
where indexing status should be reported.
See `indexing.error-reporting.github` configuration properties for more details.
See `indexing.reporting.github` configuration properties for more details.
`search-quarkus-io-secret`::
Secret environment variables for the application.
+
Expand All @@ -249,7 +249,7 @@ you will need to set up a few things manually:
In particular:
* `GITHUB_OAUTH`: a GitHub token that allows commenting/reopening/closing a GitHub issue
on quarkusio/search.quarkus.io.
See `indexing.error-reporting.github` configuration properties for more details.
See `indexing.reporting.github` configuration properties for more details.
`search-backend-config`::
Environment variables for the OpenSearch instances.
+
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import jakarta.inject.Inject;

import io.quarkus.search.app.entity.Language;
import io.quarkus.search.app.indexing.FailureCollector;
import io.quarkus.search.app.indexing.reporting.FailureCollector;
import io.quarkus.search.app.quarkusio.QuarkusIO;
import io.quarkus.search.app.quarkusio.QuarkusIOConfig;
import io.quarkus.search.app.util.CloseableDirectory;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.quarkus.search.app.indexing;

import java.util.concurrent.CompletableFuture;

import io.quarkus.logging.Log;

import org.hibernate.search.engine.reporting.impl.LogFailureHandler;
import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureContext;
import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler;
import org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingDelegatingFailureHandler;

class FailFastMassIndexingFailureHandler implements MassIndexingFailureHandler {
private final MassIndexingFailureHandler delegate = new PojoMassIndexingDelegatingFailureHandler(new LogFailureHandler());

volatile boolean failed = false;
volatile CompletableFuture<?> future;

@Override
public void handle(MassIndexingFailureContext context) {
delegate.handle(context);
failed = true;
if (future != null) {
abort();
}
}

public void init(CompletableFuture<?> future) {
this.future = future;
if (failed) {
abort();
}
}

private void abort() {
Log.error("Aborting mass indexing to fail fast.");
future.cancel(true);
}
}
284 changes: 0 additions & 284 deletions src/main/java/io/quarkus/search/app/indexing/FailureCollector.java

This file was deleted.

Loading

0 comments on commit 4ef8627

Please sign in to comment.