Skip to content
Merged
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 @@ -192,11 +192,20 @@ public static <Response extends ReplicationResponse & WriteResponse> ActionListe

@Override
protected void doExecute(Task task, BulkRequest bulkRequest, ActionListener<BulkResponse> outerListener) {
// As a work-around to support `?refresh`, explicitly replace the refresh policy with a call to the Refresh API.
// As a work-around to support `?refresh`, explicitly replace the refresh policy with a call to the Refresh API,
// and always set forced_refresh to true.
// TODO: Replace with a less hacky approach.
ActionListener<BulkResponse> listener = outerListener;
if (DiscoveryNode.isStateless(clusterService.getSettings()) && bulkRequest.getRefreshPolicy() != WriteRequest.RefreshPolicy.NONE) {
listener = outerListener.delegateFailure((l, r) -> { client.admin().indices().prepareRefresh().execute(l.map(ignored -> r)); });
listener = outerListener.delegateFailure((l, r) -> client.admin().indices().prepareRefresh().execute(l.map(ignored -> {
for (BulkItemResponse response : r.getItems()) {
DocWriteResponse docWriteResponse = response.getResponse();
if (docWriteResponse != null) {
docWriteResponse.setForcedRefresh(true);
}
}
return r;
})));
bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.NONE);
}
/*
Expand Down