Skip to content

Commit 506a630

Browse files
committed
fix: handle ElasticsearchStatusException (429) in RoutedBulkIndexer
The ES coordinating memory limit causes HTTP 429 rejections which throw ElasticsearchStatusException (RuntimeException). submitWithRetry only caught IOException, so 429s killed BP threads silently. Now catches ElasticsearchStatusException with sleep+backoff and requeue instead of thread death.
1 parent c78705f commit 506a630

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

agr_variant_indexer/src/main/java/org/alliancegenome/indexer/variant/es/managers/RoutedBulkIndexer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.alliancegenome.es.util.EsClientFactory;
1313
import org.alliancegenome.es.util.ProcessDisplayHelper;
1414
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
15+
import org.elasticsearch.ElasticsearchStatusException;
1516
import org.elasticsearch.action.bulk.BulkItemResponse;
1617
import org.elasticsearch.action.bulk.BulkRequest;
1718
import org.elasticsearch.action.bulk.BulkResponse;
@@ -177,6 +178,15 @@ private void submitWithRetry(List<byte[]> docs, String routing) {
177178
}
178179
}
179180

181+
} catch (ElasticsearchStatusException e) {
182+
totalRetries++;
183+
log.warn(label + " Bulk request rejected (HTTP " + e.status().getStatus() + "): " + e.getMessage() + ", sleeping and splitting " + docs.size() + " items and requeueing");
184+
try {
185+
Thread.sleep(1000 + ThreadLocalRandom.current().nextInt(2000));
186+
} catch (InterruptedException ie) {
187+
Thread.currentThread().interrupt();
188+
}
189+
requeueSplit(docs);
180190
} catch (IOException e) {
181191
totalRetries++;
182192
log.warn(label + " Bulk request failed: " + e.getMessage() + ", reconnecting and splitting " + docs.size() + " items and requeueing");

0 commit comments

Comments
 (0)