Commit Graph

6067 Commits

Author SHA1 Message Date
Simon Willnauer 29336b231b Add ref-counting to SearchContext to prevent accessing already closed readers (#20095)
When a SearchContext is closed it's reader / searcher reference is closed too.
If this happens while a search is accessing it's reader reference it can lead
to an unexpected `AlreadyClosedException` or worst case, an already closed MMapDirectory
is access causing a `SIGSEV` like in #20008 (even though the window for this is very small).

SearchContext can be closed concurrently if:
 * an index is deleted / removed from the node
 * a search context is idle for too long and is cleaned by the reaper
 * an explicit freeContext message is received

This change adds reference counting to the SearchContext base class and it's used
inside SearchService each time the context is accessed.

Closes #20008
2016-08-22 15:41:05 +02:00
Ryan Ernst e7393529b1 Merge branch 'master' into remove_index_template_filter 2016-08-19 21:14:12 -07:00
Ryan Ernst 1a7a9d3c62 Merge pull request #20071 from rjernst/pull_shards_allocator
Plugins: Switch custom ShardsAllocators to pull based model
2016-08-19 20:55:31 -07:00
Ryan Ernst 3a9055b55d Merge pull request #20073 from rjernst/deguice_indices_service
Deguice IndicesService
2016-08-19 20:47:07 -07:00
Jason Tedor 6cda12871c Merge pull request #20083 from jasontedor/improve-startup-exception
Improve startup exception
2016-08-19 16:44:41 -04:00
Ali Beyad 1c9b64e09a Adds ignoreUnavailable option to the snapshot status API (#20066)
Adds ignoreUnavailable to the snapshot status API to be consistent
with the get snapshots API which has a similar parameter. If
ignoreUnavailable is set to true, then the snapshot status request
will ignore any snapshots that were not found in the repository,
instead of throwing a SnapshotMissingException.

Closes #18522
2016-08-19 16:19:56 -04:00
Jason Tedor c3849d9e7d Add print stack trace override to StartupException
StartupException overrides Throwable#printStackTrace(PrintStream) but
not Throwable#printStackTrace(PrintWriter). The former override is used
when the JVM terminates with an exception, but the latter override can
be used in some logging frameworks when rendering an exception (e.g.,
log4j). This commit adds an override for the latter, with the behavior
for the two overrides being the same.
2016-08-19 15:10:54 -04:00
Jason Tedor 3a6f7eb07a Rename StartupError to StartupException
This commit renames StartupError to StartupException. This rename is due
to the fact that this class inherits from Exception not Error in the
Throwable class hierarchy.
2016-08-19 14:53:08 -04:00
Ali Beyad cf32f8de34 Fixes tests so allocation ids in IndexMetaData is in sync with
what is in the RoutingTable
2016-08-19 14:42:02 -04:00
Jason Tedor 069fc22696 Remove minimum master nodes bootstrap check
This commit removes the minimum master nodes bootstrap check. The
motivation for this check was to raise awareness of the minimum master
nodes setting but this check gives a false sense of security because
it's too easy to set the setting to one when first standing up a cluster
and never update it when adding master-eligible nodes, or have it out of
sync on various nodes and still pass this check. Since this check does
not have the security that other bootstrap checks provide, it should be
removed in favor of a stronger guarantee in the future. We do log a
warning if an election occurs with minimum master nodes less than a
quorum of master-eligible nodes that participated in an election and
this is the best that we can do right now.

Relates #20082
2016-08-19 14:21:17 -04:00
Yannick Welsch 57c3dcb7d7 Merge pull request #20075 from ywelsch/fix/update-cs-with-routingresult
Some time ago, AllocationService.reroute was changed to not only return updates to the routing table but also to the metadata (which contain primary terms and in-sync allocation ids). A lot of test code still only updates the routing table though, which is fixed by this PR.
2016-08-19 18:18:30 +02:00
Yannick Welsch 771668f380 Use routingResult method to update cluster state after reroute
This ensures that the routing table as well as the metadata (with the primary terms and in-sync allocation ids) is updated.
2016-08-19 17:15:02 +02:00
Adrien Grand b586465a4c Make generics explicit to please ECJ. 2016-08-19 15:55:24 +02:00
Yannick Welsch a74f77b632 Check that all active shards have their allocation id in the in-sync set 2016-08-19 10:41:11 +02:00
Ryan Ernst 59636a0844 Internal: Deguice IndicesService
Almost all the dependencies of indices service are already created outside of
guice. This change deguices MetaStateService, and then IndicesService.
2016-08-19 00:27:37 -07:00
Adrien Grand a4ea7e7223 Switch indices.exists_type from `{index}/{type}` to `{index}/_mapping/{type}`. #20055
This will help remove types as we will need `{index}/{id}` to tell whether a
document exists.

Relates #15613
2016-08-19 09:18:24 +02:00
Ryan Ernst 207d3a60e7 Fix staging url for official plugins
This was incorrectly setup in #19996, without the version in the staging
build id.
2016-08-18 23:06:14 -07:00
Ryan Ernst 00c123b59f Plugins: Remove IndexTemplateFilter
How index templates match is currently controlled by the
IndexTemplateFilter interface. It is pluggable, to add additional
filter implementations to the default glob matcher.

This change removes the IndexTemplateFilter interface completely. This
is a very esoteric extension point, and not worth maintaining. Instead,
any improvements should be made to all of our glob matching.
2016-08-18 22:41:25 -07:00
Ryan Ernst ab404d90ed Plugins: Switch custom ShardsAllocators to pull based model
This change moves custom ShardsAllocators from registration on
ClusterModule, to implementing getShardsAllocators() in ClusterPlugin.
It also removes the legacy alias "even_shard" for the balanced allocator
which was removed in 2.0.
2016-08-18 22:18:33 -07:00
Thiago Souza 8281a3ce79 Merge pull request #20041 from tsouza/fix/issue-19142
Make exception message more descriptive
2016-08-18 17:31:16 -03:00
Ryan Ernst 165565a817 Merge pull request #20040 from rjernst/pull_allocation_deciders
Make custom allocation deciders use pull based extensions
2016-08-18 12:07:09 -07:00
Ryan Ernst 45144edd73 Fix cat allocation test line length violations 2016-08-18 10:51:59 -07:00
Adrien Grand 8f8ae8f577 Mapping updates on objects should propagate `include_an_all`. #20051
Today you can't update `include_an_all` on an existing object. The bug affects
2.x too.
2016-08-18 12:45:28 +02:00
Martijn van Groningen 825edd8dba tests for Script parsing and serialization 2016-08-18 12:19:43 +02:00
Adrien Grand d805266d94 Revert "Save one utf8 conversion in KeywordFieldMapper. #19867"
This reverts commit c44679d952.

Conflicts:
	core/src/main/java/org/elasticsearch/index/mapper/BaseGeoPointFieldMapper.java
	core/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapperLegacy.java
	core/src/test/java/org/elasticsearch/index/mapper/GeoPointFieldMapperTests.java
2016-08-18 08:17:28 +02:00
Adrien Grand a7a7123d74 Simplify inclusion in `_all`. #20028
Currently, when you set `include_in_all` on an object, it will propagate the
information to its sub mappers immediately. This is annoying because this is
done using a different mechanism than regular mapping updates.

This PR changes object fields to propagate the information at document parsing
time rather than when `include_an_all` is updated. While moving this cost to
document parsing time rather than mapping update time is probably a bad
trade-off, I am confident that this cost is very low and think this new way
makes things simpler.
2016-08-18 08:13:55 +02:00
Ryan Ernst 1ff348ed7f Plugins: Make custom allocation deciders use pull based extensions
This change converts AllocationDecider registration from push based on
ClusterModule to implementing with a new ClusterPlugin interface.
AllocationDecider instances are allowed to use only Settings and
ClusterSettings.
2016-08-17 15:55:31 -07:00
Thiago Souza 8e8614483b Make exception message more descriptive
Exception message should be more descriptive about what to do when
inner_hit names colides.

Fixes https://github.com/elastic/elasticsearch/issues/19142
2016-08-17 19:54:42 -03:00
Lee Hinman f6b166f19e Merge remote-tracking branch 'dakrone/forbid-simpleregex-in-index-name' 2016-08-17 16:01:09 -06:00
Lee Hinman 6030acb43b Disallow creating indices starting with '-' or '+'
Previously this was possible, which was problematic when issuing a
request like `DELETE /-myindex`, which was interpretted as "delete
everything except for myindex".

Resolves #19800
2016-08-17 15:13:03 -06:00
Ryan Ernst 2ea50bc162 Merge pull request #20018 from rjernst/split_disk_threshold
Internal: Split disk threshold monitoring from decider
2016-08-17 07:57:50 -07:00
Ryan Ernst efd8d837e8 Make disk threshold settings final 2016-08-17 07:58:27 -07:00
Yannick Welsch 27a760f9c1 Add routing changes API to RoutingAllocation (#19992)
Adds a class that records changes made to RoutingAllocation, so that at the end of the allocation round other values can be more easily derived based on these changes. Most notably, it:

- replaces the explicit boolean flag that is passed around everywhere to denote changes to the routing table. The boolean flag is automatically updated now when changes actually occur, preventing issues where it got out of sync with actual changes to the routing table.
- records actual changes made to RoutingNodes so that primary term and in-sync allocation ids, which are part of index metadata, can be efficiently updated just by looking at the shards that were actually changed.
2016-08-17 10:46:59 +02:00
Adrien Grand d894db1590 Only use `PUT` for index creation, not POST. #20001
Currently both `PUT` and `POST` can be used to create indices. This commit
removes support for `POST index_name` so that we can use it to index documents
with auto-generated ids once types are removed.

Relates #15613
2016-08-17 10:15:42 +02:00
Adrien Grand ffee9e8833 Automatically upgrade analyzed string fields that have `index_options` or `position_increment_gap` set. #20002
Closes #19974
2016-08-17 10:14:25 +02:00
Ryan Ernst b2c0f2d08f Internal: Split disk threshold monitoring from decider
In addition to be an allocation decider, DiskThresholdDecider also
monitors the used disk in order to trigger a reroute when the thresholds
are crossed. This change splits out the settings for disk thresholds
into DiskThresholdSettings, and moves the monitoring to a new
DiskThresholdMonitor.  DiskThresholdDecider is then in line with other
allocation deciders, needing only Settings and ClusterSettings for
construction, which will allow deguicing allocation deciders.
2016-08-17 00:22:16 -07:00
Lee Hinman 1825d8060c Merge remote-tracking branch 'dakrone/lockobtainfailed-replacement' 2016-08-16 14:41:27 -06:00
Lee Hinman 1de3388fa3 Switching LockObtainFailedException over to ShardLockObtainFailedException
`LobObtainFailedException` should be reserved for on-disk locks that
Lucene attempts (like `write.lock`). This switches our in-memory
semaphore locks for shards to use a different exception. Additionally,
ShardLockObtainFailedException no longer subclasses IOException, since
no IO is being done is this case.

Resolves #19978
2016-08-16 14:37:36 -06:00
Areek Zillur 75d4a9f6e4 Allow plugins to upgrade global custom metadata on startup
Currently plugins can not inspect or upgrade custom
meta data on startup. This commit allow plugins
to check and/or upgrade global custom meta data on startup.
Plugins can stop a node if any custom meta data is not supported.
2016-08-16 16:24:43 -04:00
Ryan Ernst 743d9fd008 Merge branch 'master' into search_parser 2016-08-16 11:28:59 -07:00
Ryan Ernst f716a86f40 Add comment about making parser members private instead of public 2016-08-16 11:25:34 -07:00
Nik Everett fdd50612ae Fix reindex under the transport client
The big change here is cleaning up the `TaskListResponse` so it doesn't
have a breaky `toString` implementation. That was causing the reindex
tests to break.

Also removed `NetworkModule#registerTaskStatus` which is part of the
Plugin API. Use `Plugin#getNamedWriteables` instead.
2016-08-16 12:15:15 -04:00
Ali Beyad 88aff40eef Primary shard allocator observes limits in forcing allocation (#19811)
Primary shard allocation observes limits in forcing allocation

Previously, during primary shards allocation of shards
with prior allocation IDs, if all nodes returned a
NO decision for allocation (e.g. the settings blocked
allocation on that node), we would chose one of those
nodes and force the primary shard to be allocated to it.

However, this meant that primary shard allocation
would not adhere to the decision of the MaxRetryAllocationDecider,
which would lead to attempting to allocate a shard
which has failed N number of times already (presumably
due to some configuration issue).

This commit solves this issue by introducing the
notion of force allocating a primary shard to a node
and each decider implementation must implement whether
this is allowed or not. In the case of MaxRetryAllocationDecider,
it just forwards the request to canAllocate.

Closes #19446
2016-08-16 11:25:45 -04:00
Nik Everett 46bf8baf2e Switch aggregation registration for push to pull
Adds `getAggregations` to `SearchPlugin` which can be used to register
aggregations.

Fixup MockNode which wasn't createing MockBigArrays.
2016-08-16 09:08:36 -04:00
Ryan Ernst 7fde410586 Internal: Consolidate search parser registries
Parsing a search request is currently split up among a number of
classes, using multiple public static methods, which take multiple
regstries of elements that may appear in the search request like query
parsers and aggregations. This change begins consolidating all this code
by collapsing the registries normally used for parsing search requests
into a single SearchRequestParsers class. It is also made available to
plugin services to enable templating of search requests.  Eventually all
of the actual parsing logic should move to the class, and the registries
should be hidden, but for now they are at least co-located to reduce the
number of objects that must be passed around.
2016-08-16 01:59:24 -07:00
Ryan Ernst 0996ae03a4 Merge pull request #19996 from rjernst/plugin_location
Plugins: Update official plugin location with unified release
2016-08-15 20:36:01 -07:00
Nik Everett 1452ab4b9f Squash the rest of o.e.rest.action
Squashes all the subpackages of `org.elasticsearch.rest.action` down to
the following:
* `o.e.rest.action.admin` - Administrative actions
* `o.e.rest.action.cat` - Actions that make tables for `grep`ing
* `o.e.rest.action.document` - Actions that act on documents
* `o.e.rest.action.ingest` - Actions that act on ingest pipelines
* `o.e.rest.action.search` - Actions that search

I'm tempted to merge `search` into `document` but the `document`
package feels fairly complete as is and `Suggest` isn't actually always
about documents either....

I'm also tempted to merge `ingest` into `admin.cluster` because the
latter contains the actions for dealing with stored scripts.

I've moved the `o.e.rest.action.support` into `o.e.rest.action`.

I've also added `package-info.java`s to all packges in `o.e.rest`. I
figure if the package is too small to deserve a `package-info.java` file
then it is too small to deserve to be a package....

Also fixes checkstyle in all moved classes.
2016-08-15 21:06:32 -04:00
chengpohi 2adc2a1971 Enable BoostingQuery with FVH highlighter (#19984)
* Enable BoostingQuery with FVH highlighter
* apply boost with negativeBoost
* flatten boosting query with its own boost and update boost query to a single layer
2016-08-15 21:00:16 -04:00
Nik Everett 4f262ce11e Clear some more static state in tests
This was causing CI build failures that didn't reproduce consistently
locally. Hopefully this will fix the error on CI.
2016-08-15 18:51:17 -04:00
Nik Everett eb9b84e6c3 Fix broken test
Randomized testing requires that we clean all the static state
in test classess.
2016-08-15 17:27:01 -04:00