Skip to content

Commit b55aca7

Browse files
committed
Merge branch 'master' into replicated-closed-indices
2 parents 0cd3636 + f15be14 commit b55aca7

File tree

56 files changed

+1849
-345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1849
-345
lines changed

TESTING.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ These are the linux flavors supported, all of which we provide images for
366366
* debian-9 aka stretch, the current debian stable distribution
367367
* centos-6
368368
* centos-7
369-
* fedora-27
370369
* fedora-28
370+
* fedora-29
371371
* oel-6 aka Oracle Enterprise Linux 6
372372
* oel-7 aka Oracle Enterprise Linux 7
373373
* sles-12

Vagrantfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ Vagrant.configure(2) do |config|
109109
rpm_common config, box
110110
end
111111
end
112-
'fedora-27'.tap do |box|
112+
'fedora-28'.tap do |box|
113113
config.vm.define box, define_opts do |config|
114-
config.vm.box = 'elastic/fedora-27-x86_64'
114+
config.vm.box = 'elastic/fedora-28-x86_64'
115115
dnf_common config, box
116116
end
117117
end
118-
'fedora-28'.tap do |box|
118+
'fedora-29'.tap do |box|
119119
config.vm.define box, define_opts do |config|
120120
config.vm.box = 'elastic/fedora-28-x86_64'
121121
dnf_common config, box

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class VagrantTestPlugin implements Plugin<Project> {
2525
'centos-7',
2626
'debian-8',
2727
'debian-9',
28-
'fedora-27',
2928
'fedora-28',
29+
'fedora-29',
3030
'oel-6',
3131
'oel-7',
3232
'opensuse-42',

docs/reference/analysis/analyzers/lang-analyzer.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ PUT /persian_example
13581358
"char_filter": {
13591359
"zero_width_spaces": {
13601360
"type": "mapping",
1361-
"mappings": [ "\\u200C=> "] <1>
1361+
"mappings": [ "\\u200C=>\\u0020"] <1>
13621362
}
13631363
},
13641364
"filter": {

docs/reference/search/field-caps.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
The field capabilities API allows to retrieve the capabilities of fields among multiple indices.
55

6-
The field capabilities api by default executes on all indices:
6+
The field capabilities API by default executes on all indices:
77

88
[source,js]
99
--------------------------------------------------
1010
GET _field_caps?fields=rating
1111
--------------------------------------------------
1212
// CONSOLE
1313

14-
... but the request can also be restricted to specific indices:
14+
The request can also be restricted to specific indices:
1515

1616
[source,js]
1717
--------------------------------------------------
@@ -29,7 +29,7 @@ Supported request options:
2929
[float]
3030
=== Field Capabilities
3131

32-
The field capabilities api returns the following information per field:
32+
The field capabilities API returns the following information per field:
3333

3434
[horizontal]
3535
`searchable`::

docs/reference/search/request/source-filtering.asciidoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ GET /_search
5454
// CONSOLE
5555

5656
Finally, for complete control, you can specify both `includes` and `excludes`
57-
patterns:
57+
patterns. If `includes` is not empty, then only fields that match one of the
58+
patterns in `includes` but none of the patterns in `excludes` are provided in
59+
`_source`. If `includes` is empty, then all fields are provided in `_source`,
60+
except for those that match a pattern in `excludes`.
5861

5962
[source,js]
6063
--------------------------------------------------

server/src/main/java/org/elasticsearch/ElasticsearchException.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,17 @@ private enum ElasticsearchExceptionHandle {
10121012
SNAPSHOT_IN_PROGRESS_EXCEPTION(org.elasticsearch.snapshots.SnapshotInProgressException.class,
10131013
org.elasticsearch.snapshots.SnapshotInProgressException::new, 151, Version.V_6_7_0),
10141014
NO_SUCH_REMOTE_CLUSTER_EXCEPTION(org.elasticsearch.transport.NoSuchRemoteClusterException.class,
1015-
org.elasticsearch.transport.NoSuchRemoteClusterException::new, 152, Version.V_6_7_0);
1015+
org.elasticsearch.transport.NoSuchRemoteClusterException::new, 152, Version.V_6_7_0),
1016+
RETENTION_LEASE_ALREADY_EXISTS_EXCEPTION(
1017+
org.elasticsearch.index.seqno.RetentionLeaseAlreadyExistsException.class,
1018+
org.elasticsearch.index.seqno.RetentionLeaseAlreadyExistsException::new,
1019+
153,
1020+
Version.V_6_7_0),
1021+
RETENTION_LEASE_NOT_FOUND_EXCEPTION(
1022+
org.elasticsearch.index.seqno.RetentionLeaseNotFoundException.class,
1023+
org.elasticsearch.index.seqno.RetentionLeaseNotFoundException::new,
1024+
154,
1025+
Version.V_6_7_0);
10161026

10171027
final Class<? extends ElasticsearchException> exceptionClass;
10181028
final CheckedFunction<StreamInput, ? extends ElasticsearchException, IOException> constructor;

server/src/main/java/org/elasticsearch/action/ActionModule.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
package org.elasticsearch.action;
2121

22-
import org.apache.logging.log4j.Logger;
2322
import org.apache.logging.log4j.LogManager;
23+
import org.apache.logging.log4j.Logger;
2424
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainAction;
2525
import org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction;
2626
import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsAction;
@@ -209,6 +209,7 @@
209209
import org.elasticsearch.common.settings.IndexScopedSettings;
210210
import org.elasticsearch.common.settings.Settings;
211211
import org.elasticsearch.common.settings.SettingsFilter;
212+
import org.elasticsearch.index.seqno.RetentionLeaseActions;
212213
import org.elasticsearch.indices.breaker.CircuitBreakerService;
213214
import org.elasticsearch.persistent.CompletionPersistentTaskAction;
214215
import org.elasticsearch.persistent.RemovePersistentTaskAction;
@@ -220,6 +221,7 @@
220221
import org.elasticsearch.rest.RestHandler;
221222
import org.elasticsearch.rest.action.RestFieldCapabilitiesAction;
222223
import org.elasticsearch.rest.action.RestMainAction;
224+
import org.elasticsearch.rest.action.admin.cluster.RestAddVotingConfigExclusionAction;
223225
import org.elasticsearch.rest.action.admin.cluster.RestCancelTasksAction;
224226
import org.elasticsearch.rest.action.admin.cluster.RestClearVotingConfigExclusionsAction;
225227
import org.elasticsearch.rest.action.admin.cluster.RestClusterAllocationExplainAction;
@@ -251,7 +253,6 @@
251253
import org.elasticsearch.rest.action.admin.cluster.RestRestoreSnapshotAction;
252254
import org.elasticsearch.rest.action.admin.cluster.RestSnapshotsStatusAction;
253255
import org.elasticsearch.rest.action.admin.cluster.RestVerifyRepositoryAction;
254-
import org.elasticsearch.rest.action.admin.cluster.RestAddVotingConfigExclusionAction;
255256
import org.elasticsearch.rest.action.admin.indices.RestAnalyzeAction;
256257
import org.elasticsearch.rest.action.admin.indices.RestClearIndicesCacheAction;
257258
import org.elasticsearch.rest.action.admin.indices.RestCloseIndexAction;
@@ -529,6 +530,11 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
529530
actions.register(CompletionPersistentTaskAction.INSTANCE, CompletionPersistentTaskAction.TransportAction.class);
530531
actions.register(RemovePersistentTaskAction.INSTANCE, RemovePersistentTaskAction.TransportAction.class);
531532

533+
// retention leases
534+
actions.register(RetentionLeaseActions.Add.INSTANCE, RetentionLeaseActions.Add.TransportAction.class);
535+
actions.register(RetentionLeaseActions.Renew.INSTANCE, RetentionLeaseActions.Renew.TransportAction.class);
536+
actions.register(RetentionLeaseActions.Remove.INSTANCE, RetentionLeaseActions.Remove.TransportAction.class);
537+
532538
return unmodifiableMap(actions.getRegistry());
533539
}
534540

server/src/main/java/org/elasticsearch/action/search/SearchResponseMerger.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,25 @@ public int compare(ShardSearchFailure o1, ShardSearchFailure o2) {
204204
if (shardId2 == null) {
205205
return 1;
206206
}
207-
return shardId1.compareTo(shardId2);
207+
int shardIdCompare = shardId1.compareTo(shardId2);
208+
//we could assume that the same shard id cannot come back from multiple clusters as even with same index name and shard index,
209+
//the index uuid does not match. But the same cluster can be registered multiple times with different aliases, in which case
210+
//we may get failures from the same index, yet with a different cluster alias in their shard target.
211+
if (shardIdCompare != 0) {
212+
return shardIdCompare;
213+
}
214+
String clusterAlias1 = o1.shard() == null ? null : o1.shard().getClusterAlias();
215+
String clusterAlias2 = o2.shard() == null ? null : o2.shard().getClusterAlias();
216+
if (clusterAlias1 == null && clusterAlias2 == null) {
217+
return 0;
218+
}
219+
if (clusterAlias1 == null) {
220+
return -1;
221+
}
222+
if (clusterAlias2 == null) {
223+
return 1;
224+
}
225+
return clusterAlias1.compareTo(clusterAlias2);
208226
}
209227

210228
private ShardId extractShardId(ShardSearchFailure failure) {

server/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package org.elasticsearch.cluster.routing;
2121

22-
import org.apache.logging.log4j.LogManager;
23-
import org.apache.logging.log4j.Logger;
2422
import org.elasticsearch.Version;
2523
import org.elasticsearch.cluster.ClusterState;
2624
import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -33,7 +31,6 @@
3331
import org.elasticsearch.common.settings.Settings;
3432
import org.elasticsearch.index.IndexNotFoundException;
3533
import org.elasticsearch.index.shard.ShardId;
36-
import org.elasticsearch.index.shard.ShardNotFoundException;
3734
import org.elasticsearch.node.ResponseCollectorService;
3835

3936
import java.util.ArrayList;
@@ -47,8 +44,6 @@
4744

4845
public class OperationRouting {
4946

50-
private static final Logger logger = LogManager.getLogger(OperationRouting.class);
51-
5247
public static final Setting<Boolean> USE_ADAPTIVE_REPLICA_SELECTION_SETTING =
5348
Setting.boolSetting("cluster.routing.use_adaptive_replica_selection", true,
5449
Setting.Property.Dynamic, Setting.Property.NodeScope);
@@ -129,7 +124,7 @@ private Set<IndexShardRoutingTable> computeTargetedShards(ClusterState clusterSt
129124
for (String r : effectiveRouting) {
130125
final int routingPartitionSize = indexMetaData.getRoutingPartitionSize();
131126
for (int partitionOffset = 0; partitionOffset < routingPartitionSize; partitionOffset++) {
132-
set.add(shardRoutingTable(indexRouting, calculateScaledShardId(indexMetaData, r, partitionOffset)));
127+
set.add(RoutingTable.shardRoutingTable(indexRouting, calculateScaledShardId(indexMetaData, r, partitionOffset)));
133128
}
134129
}
135130
} else {
@@ -146,15 +141,7 @@ private ShardIterator preferenceActiveShardIterator(IndexShardRoutingTable index
146141
@Nullable ResponseCollectorService collectorService,
147142
@Nullable Map<String, Long> nodeCounts) {
148143
if (preference == null || preference.isEmpty()) {
149-
if (awarenessAttributes.isEmpty()) {
150-
if (useAdaptiveReplicaSelection) {
151-
return indexShard.activeInitializingShardsRankedIt(collectorService, nodeCounts);
152-
} else {
153-
return indexShard.activeInitializingShardsRandomIt();
154-
}
155-
} else {
156-
return indexShard.preferAttributesActiveInitializingShardsIt(awarenessAttributes, nodes);
157-
}
144+
return shardRoutings(indexShard, nodes, collectorService, nodeCounts);
158145
}
159146
if (preference.charAt(0) == '_') {
160147
Preference preferenceType = Preference.parse(preference);
@@ -181,15 +168,7 @@ private ShardIterator preferenceActiveShardIterator(IndexShardRoutingTable index
181168
}
182169
// no more preference
183170
if (index == -1 || index == preference.length() - 1) {
184-
if (awarenessAttributes.isEmpty()) {
185-
if (useAdaptiveReplicaSelection) {
186-
return indexShard.activeInitializingShardsRankedIt(collectorService, nodeCounts);
187-
} else {
188-
return indexShard.activeInitializingShardsRandomIt();
189-
}
190-
} else {
191-
return indexShard.preferAttributesActiveInitializingShardsIt(awarenessAttributes, nodes);
192-
}
171+
return shardRoutings(indexShard, nodes, collectorService, nodeCounts);
193172
} else {
194173
// update the preference and continue
195174
preference = preference.substring(index + 1);
@@ -232,12 +211,17 @@ private ShardIterator preferenceActiveShardIterator(IndexShardRoutingTable index
232211
}
233212
}
234213

235-
private IndexShardRoutingTable shardRoutingTable(IndexRoutingTable indexRouting, int shardId) {
236-
IndexShardRoutingTable indexShard = indexRouting.shard(shardId);
237-
if (indexShard == null) {
238-
throw new ShardNotFoundException(new ShardId(indexRouting.getIndex(), shardId));
214+
private ShardIterator shardRoutings(IndexShardRoutingTable indexShard, DiscoveryNodes nodes,
215+
@Nullable ResponseCollectorService collectorService, @Nullable Map<String, Long> nodeCounts) {
216+
if (awarenessAttributes.isEmpty()) {
217+
if (useAdaptiveReplicaSelection) {
218+
return indexShard.activeInitializingShardsRankedIt(collectorService, nodeCounts);
219+
} else {
220+
return indexShard.activeInitializingShardsRandomIt();
221+
}
222+
} else {
223+
return indexShard.preferAttributesActiveInitializingShardsIt(awarenessAttributes, nodes);
239224
}
240-
return indexShard;
241225
}
242226

243227
protected IndexRoutingTable indexRoutingTable(ClusterState clusterState, String index) {

server/src/main/java/org/elasticsearch/cluster/routing/RoutingChangesObserver.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ public interface RoutingChangesObserver {
5959
*/
6060
void relocationSourceRemoved(ShardRouting removedReplicaRelocationSource);
6161

62-
/**
63-
* Called on started primary shard after it has been promoted from replica to primary and is reinitialized due to shadow replicas.
64-
*/
65-
void startedPrimaryReinitialized(ShardRouting startedPrimaryShard, ShardRouting initializedShard);
66-
6762
/**
6863
* Called when started replica is promoted to primary.
6964
*/
@@ -117,11 +112,6 @@ public void relocationSourceRemoved(ShardRouting removedReplicaRelocationSource)
117112

118113
}
119114

120-
@Override
121-
public void startedPrimaryReinitialized(ShardRouting startedPrimaryShard, ShardRouting initializedShard) {
122-
123-
}
124-
125115
@Override
126116
public void replicaPromoted(ShardRouting replicaShard) {
127117

@@ -190,13 +180,6 @@ public void relocationSourceRemoved(ShardRouting removedReplicaRelocationSource)
190180
}
191181
}
192182

193-
@Override
194-
public void startedPrimaryReinitialized(ShardRouting startedPrimaryShard, ShardRouting initializedShard) {
195-
for (RoutingChangesObserver routingChangesObserver : routingChangesObservers) {
196-
routingChangesObserver.startedPrimaryReinitialized(startedPrimaryShard, initializedShard);
197-
}
198-
}
199-
200183
@Override
201184
public void replicaPromoted(ShardRouting replicaShard) {
202185
for (RoutingChangesObserver routingChangesObserver : routingChangesObservers) {

server/src/main/java/org/elasticsearch/cluster/routing/RoutingException.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@
2929
*/
3030
public class RoutingException extends ElasticsearchException {
3131

32-
public RoutingException(String message) {
33-
super(message);
34-
}
35-
3632
public RoutingException(String message, Throwable cause) {
3733
super(message, cause);
3834
}
3935

4036
public RoutingException(StreamInput in) throws IOException{
4137
super(in);
4238
}
43-
}
39+
}

server/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,7 @@ assert getByAllocationId(failedShard.shardId(), failedShard.allocationId().getId
577577
if (failedShard.relocatingNodeId() == null) {
578578
if (failedShard.primary()) {
579579
// promote active replica to primary if active replica exists (only the case for shadow replicas)
580-
ShardRouting activeReplica = activeReplicaWithHighestVersion(failedShard.shardId());
581-
if (activeReplica == null) {
582-
moveToUnassigned(failedShard, unassignedInfo);
583-
} else {
584-
movePrimaryToUnassignedAndDemoteToReplica(failedShard, unassignedInfo);
585-
promoteReplicaToPrimary(activeReplica, routingChangesObserver);
586-
}
580+
unassignPrimaryAndPromoteActiveReplicaIfExists(failedShard, unassignedInfo, routingChangesObserver);
587581
} else {
588582
// initializing shard that is not relocation target, just move to unassigned
589583
moveToUnassigned(failedShard, unassignedInfo);
@@ -601,32 +595,36 @@ assert getByAllocationId(failedShard.shardId(), failedShard.allocationId().getId
601595
cancelRelocation(sourceShard);
602596
remove(failedShard);
603597
}
604-
routingChangesObserver.shardFailed(failedShard, unassignedInfo);
605598
} else {
606599
assert failedShard.active();
607600
if (failedShard.primary()) {
608601
// promote active replica to primary if active replica exists
609-
ShardRouting activeReplica = activeReplicaWithHighestVersion(failedShard.shardId());
610-
if (activeReplica == null) {
611-
moveToUnassigned(failedShard, unassignedInfo);
612-
} else {
613-
movePrimaryToUnassignedAndDemoteToReplica(failedShard, unassignedInfo);
614-
promoteReplicaToPrimary(activeReplica, routingChangesObserver);
615-
}
602+
unassignPrimaryAndPromoteActiveReplicaIfExists(failedShard, unassignedInfo, routingChangesObserver);
616603
} else {
617-
assert failedShard.primary() == false;
618604
if (failedShard.relocating()) {
619605
remove(failedShard);
620606
} else {
621607
moveToUnassigned(failedShard, unassignedInfo);
622608
}
623609
}
624-
routingChangesObserver.shardFailed(failedShard, unassignedInfo);
625610
}
611+
routingChangesObserver.shardFailed(failedShard, unassignedInfo);
626612
assert node(failedShard.currentNodeId()).getByShardId(failedShard.shardId()) == null : "failedShard " + failedShard +
627613
" was matched but wasn't removed";
628614
}
629615

616+
private void unassignPrimaryAndPromoteActiveReplicaIfExists(ShardRouting failedShard, UnassignedInfo unassignedInfo,
617+
RoutingChangesObserver routingChangesObserver) {
618+
assert failedShard.primary();
619+
ShardRouting activeReplica = activeReplicaWithHighestVersion(failedShard.shardId());
620+
if (activeReplica == null) {
621+
moveToUnassigned(failedShard, unassignedInfo);
622+
} else {
623+
movePrimaryToUnassignedAndDemoteToReplica(failedShard, unassignedInfo);
624+
promoteReplicaToPrimary(activeReplica, routingChangesObserver);
625+
}
626+
}
627+
630628
private void promoteReplicaToPrimary(ShardRouting activeReplica, RoutingChangesObserver routingChangesObserver) {
631629
// if the activeReplica was relocating before this call to failShard, its relocation was cancelled earlier when we
632630
// failed initializing replica shards (and moved replica relocation source back to started)
@@ -1168,10 +1166,6 @@ private static final class Recoveries {
11681166
private int incoming = 0;
11691167
private int outgoing = 0;
11701168

1171-
int getTotal() {
1172-
return incoming + outgoing;
1173-
}
1174-
11751169
void addOutgoing(int howMany) {
11761170
assert outgoing + howMany >= 0 : outgoing + howMany+ " must be >= 0";
11771171
outgoing += howMany;

0 commit comments

Comments
 (0)