[reindex] Don't attempt to refresh on noop

If the user asks for a refresh but their reindex or update-by-query
operation touched no indexes we should just skip the resfresh call
entirely. Without this commit we refresh *all* indexes which is totally
wrong.

Closes #17296
This commit is contained in:
Nik Everett 2016-03-23 16:13:11 -04:00
parent e16e113691
commit aaa4d57fff
2 changed files with 14 additions and 8 deletions

View File

@ -354,7 +354,7 @@ public abstract class AbstractAsyncBulkByScrollAction<Request extends AbstractBu
* Start terminating a request that finished non-catastrophically.
*/
void startNormalTermination(List<Failure> indexingFailures, List<ShardSearchFailure> searchFailures, boolean timedOut) {
if (task.isCancelled() || false == mainRequest.isRefresh()) {
if (task.isCancelled() || false == mainRequest.isRefresh() || destinationIndices.isEmpty()) {
finishHim(null, indexingFailures, searchFailures, timedOut);
return;
}

View File

@ -458,23 +458,29 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
}
public void testRefreshIsFalseByDefault() throws Exception {
refreshTestCase(null, false);
refreshTestCase(null, true, false);
}
public void testRefreshFalseDoesntMakeVisible() throws Exception {
refreshTestCase(false, false);
public void testRefreshFalseDoesntExecuteRefresh() throws Exception {
refreshTestCase(false, true, false);
}
public void testRefreshTrueMakesVisible() throws Exception {
refreshTestCase(true, true);
public void testRefreshTrueExecutesRefresh() throws Exception {
refreshTestCase(true, true, true);
}
private void refreshTestCase(Boolean refresh, boolean shouldRefresh) {
public void testRefreshTrueSkipsRefreshIfNoDestinationIndexes() throws Exception {
refreshTestCase(true, false, false);
}
private void refreshTestCase(Boolean refresh, boolean addDestinationIndexes, boolean shouldRefresh) {
if (refresh != null) {
mainRequest.setRefresh(refresh);
}
DummyAbstractAsyncBulkByScrollAction action = new DummyAbstractAsyncBulkByScrollAction();
action.addDestinationIndices(singleton("foo"));
if (addDestinationIndexes) {
action.addDestinationIndices(singleton("foo"));
}
action.startNormalTermination(emptyList(), emptyList(), false);
if (shouldRefresh) {
assertArrayEquals(new String[] {"foo"}, client.lastRefreshRequest.get().indices());