Skip to content

Commit 69ecf8b

Browse files
committed
rollback commit, allocation should only happen when index is not recovered
1 parent 9a09261 commit 69ecf8b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayNodeAllocation.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,11 @@ public class LocalGatewayNodeAllocation extends NodeAllocation {
154154
RoutingNodes routingNodes = allocation.routingNodes();
155155

156156
for (IndexRoutingTable indexRoutingTable : routingNodes.routingTable()) {
157-
// TODO we need to also handle a case where all shards per replication group are unassigned, in that case, we ignore until we
158-
// manage to find a place to allocate them...
157+
// only do the allocation if there is a local "INDEX NOT RECOVERED" block
158+
if (!routingNodes.blocks().hasIndexBlock(indexRoutingTable.index(), LocalGateway.INDEX_NOT_RECOVERED_BLOCK)) {
159+
continue;
160+
}
161+
159162
if (indexRoutingTable.allPrimaryShardsUnassigned()) {
160163
// all primary are unassigned for the index, see if we can allocate it on existing nodes, if not, don't assign
161164
Set<String> nodesIds = Sets.newHashSet();
@@ -245,7 +248,6 @@ public class LocalGatewayNodeAllocation extends NodeAllocation {
245248
return changed;
246249
}
247250

248-
// go ahead and see if we can optimize replica allocation to an existing node...
249251
Iterator<MutableShardRouting> unassignedIterator = routingNodes.unassigned().iterator();
250252
while (unassignedIterator.hasNext()) {
251253
MutableShardRouting shard = unassignedIterator.next();

0 commit comments

Comments
 (0)