Commit Graph

60468 Commits

Author SHA1 Message Date
weizijun e321fb024e
Fix template equals when mappings are wrapped (#77008)
When create template v2. mappings will add _doc. This will cause the created template to be inconsistent with the queried template.

In template class, add mappingsEquals method, to deal with this case.

reproduced:
MetadataIndexTemplateServiceTests.testAddComponentTemplate
when mappings are not null, the case will failed.

```
        Template template = new Template(
            Settings.builder().build(),
            new CompressedXContent("{\"properties\":{\"@timestamp\":{\"type\":\"date\"}}}"),
            ComponentTemplateTests.randomAliases()
        );
        ComponentTemplate componentTemplate = new ComponentTemplate(template, 1L, new HashMap<>());
```

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2021-09-03 14:22:56 -06:00
Armin Braun 096b8ccc26
Fix TextFieldMapper Retaining a Reference to its Builder (#77251)
Fixes the text field mapper and the analyzers class that also retained parameter references that go really heavy.
Makes `TextFieldMapper` take hundreds of bytes compared to multiple kb per instance.

closes #73845
2021-09-03 18:44:11 +02:00
Jason Tedor c7130ebb9b
Move die with dignity to be a test module (#77136)
This commit moves the die with dignity tests to be a test module. The
purpose of this is so the _die_with_dignity endpoint is available in
snapshot builds, for the purpose of enabling testing orchestration logic
that manages what happens to a node after it dies with an
OutOfMemoryError.
2021-09-03 12:34:01 -04:00
Jake Landis 26dfe02a0b
Update task names for rest compatiblity (#75267)
This commit updates two task names:
```
yamlRestCompatTest -> yamlRestTestV7CompatTest
transformV7RestTests -> yamlRestTestV7CompatTransform 
```

`7` is the N-1 version and calculated, such that when `8` is 
N-1 version the task names will be  `yamlRestTestV8CompatTest` and 
`yamlRestTestV8CompatTransform`

The motivation for `yamlRestCompatTest -> yamlRestTestV7CompatTest`  is that 
many projects have configured `yamlRestCompatTest` 
but that configuration is specific to the N-1 version. For example, 
if we blacklist tests when running compatibility with v7, we don't also
want to blacklist those tests when running compatibility with v8.

By introducing a version-specific identifier in the name, the task will not
even exist when bumping the version creating the need to (correctly) remove
the version-specific condition.

The motivation for `transformV7RestTests -> yamlRestTestV7CompatTransform` 
is to provide more consistent naming. 

The idea behind the naming is the main task people
are likely familiar with is :

`yamlRestTest` so we will use that as a base.
`yamlRestTestV7CompatTest` to run the version-specific compat tests
`yamlRestTestV7CompatTransform` to run the version-specific transformations for the compat tests

CI should be un-effected since since we introduced a lifecycle task 
name `checkRestCompat` which is what CI should be configured to use.
2021-09-03 11:26:11 -05:00
Benjamin Trent 222d95af53
[ML] adjusting bwc serialization for #77256 (#77257) 2021-09-03 11:25:36 -04:00
Gordon Brown 7c7f312d76
Move `index.hidden` from Static to Dynamic settings (#77218)
The setting `index.hidden` was originally implemented as a static
setting, but when it was converted to be a dynamic setting, the docs
were never updated to reflect that.

This commit moves the docs for `index.hidden` from the section for
static settings to the section for dynamic settings.
2021-09-03 09:15:52 -06:00
Rory Hunter d23837499d
Handle cgroups v2 in `OsProbe` (#77128)
Closes #76812. Closes #77126.

OsProbe was only capable of handle cgroup data in the v1 format.
However, Debian 11 uses cgroups v2 by default, and Elasticsearch isn't
capable of reporting any cgroup information. Therefore, add support for
the v2 layout.

Note that we have to open access to all of /sys/fs/cgroup because with
cgroups v2, the files we need are in an unpredictably location.
2021-09-03 15:49:56 +01:00
Alan Woodward 385b97f92b
Choose postings format from FieldMapper instead of MappedFieldType (#77234)
Currently we configure per-field postings formats by asking the MapperService
for the MappedFieldType of the field in question, and then checking to see if it
is a completion field. If no MappedFieldType is available, we emit a warning.
However, MappedFieldTypes are for search fields only, and so we end up emitting
warnings for hidden sub-fields that have no corresponding field type, such as
prefix or phrase accelerator fields on text mappers.

This commit reworks things so that the MappingLookup is responsible for defining
per-field postings formats, and will detect CompletionFieldMappers at build time.
All fields that are not mapped to a completion field will just get the default postings
format. This also means that we no longer need a logger instance on CodecService.

Fixes #77183
2021-09-03 14:54:43 +01:00
Mayya Sharipova f18b9d5ac8
Add segment sorter for data streams (#75195)
It is beneficial to sort segments within a datastream's index
by desc order of their max timestamp field, so
that the most recent (in terms of timestamp) segments
will be first.

This allows to speed up sort query on @timestamp desc field,
which is the most common type of query for datastreams,
as we are mostly concerned with the recent data.
This patch addressed this for writable indices.

Segments' sorter is different from index sorting.
An index sorter by itself is  concerned about the order of docs
within an individual segment (and not how the segments are organized),
while the segment sorter is only used during search and allows
to start docs collection with the "right" segment,
so we can terminate the collection faster.

This PR adds a property to IndexShard `isDataStreamIndex` that
shows if a shard is a part of datastream.
2021-09-03 09:42:48 -04:00
Nik Everett 574d6439d8
Update skip after backport (#77212)
Now that we've backported #76903 we can run backwards compatibility
tests against all versions that have it.
2021-09-03 09:11:46 -04:00
Benjamin Trent 02e17c3442
[ML] adding new defer_definition_decompression parameter to put trained model API (#77189)
This new parameter is a boolean parameter that allows
users to put in a compressed model without it having
to be inflated on the master node during the put
request

This is useful for system/module set up and then later
having the model validated and fully parsed when it
is being loaded on a node for usage
2021-09-03 09:07:54 -04:00
Benjamin Trent 174e226876
[ML] Fix bug in inference stats persister for when feature reset is called
The test failure originates from an unhandled exception being thrown in the ml_utility threadpool.

This exception was thrown by the results persister service, I found a place where the exception thrown was not ultimately handled.

closes #77182
2021-09-03 09:05:07 -04:00
Howard 962e050d5e
Only check replicas in cancelling existing recoveries. (#60564)
Minor performance improvement when only primaries are initializing.
2021-09-03 14:59:45 +02:00
Nik Everett aa2aa9b1bf
Format `AbstractFilteringTestCase` (#77217)
`AbstractFilteringTestCase` had a ton of carefully formatted
`XContentBuilder` calls that would have been totally unreadable after
the formatter worked its magic. So I formatted a bunch of them by hand
and extracted the rest to json files.
2021-09-03 08:59:00 -04:00
István Zoltán Szabó cdec5228e8
[DOCS] Fixes line breaks. (#77248) 2021-09-03 14:40:43 +02:00
Seth Michael Larson eaf4ac26cc
Convert 'routing' values in REST API tests to strings
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2021-09-03 07:33:26 -05:00
István Zoltán Szabó 70a012b0c7
[DOCS] Fixes section IDs in start/stop trained model deployment APIs. (#77247) 2021-09-03 14:24:37 +02:00
Oleg Smirnov f9b38406f0
Prevent unnecessary boxing, improve code clarity. (#76808)
Use BooleanSupplier, OptionalInt, Consumer and Predicate in places
where more generic types were used.
2021-09-03 13:45:29 +02:00
David Roberts 4bf6a778b7
[Transform] Don't search if all indices are unchanged between checkpoints (#77204)
When every index that a transform is configured to search has
remained completely unchanged between checkpoints the transform
should not do a search at all.

Following #75839 there was a problem where the scenario of all
indices being unchanged between checkpoints could cause an empty
list of indices to be searched, which Elasticsearch treats as
meaning _all_ indices. This change should prevent that happening
in future.

Fixes #77137
2021-09-03 12:42:01 +01:00
Andrei Stefan 44b8c96b3f
Use the document fields only, excluding the metadata fields (#77203) 2021-09-03 14:15:03 +03:00
Rene Groeschke 93f36077f1
Simplify test build output normalization (#77172)
* Simplify test build output normalization
2021-09-03 12:22:28 +02:00
Martijn van Groningen 8dd42313d6
Enable bwc tests after backporting #76800 (#77235) 2021-09-03 11:56:59 +02:00
Dimitris Athanasiou c279b8adfe
[ML] Retain job task upon fail during opening (#77206)
There are a few failures handled in `OpenJobPersistentTasksExecutor`
while the job is opened that are not handled properly. Currently,
the persistent task is marked as failed which effectively completes
the task. Thus the job appears as `closed` and the failure reason
is lost.

This commit changes `OpenJobPersistentTasksExecutor` so that when
failures occur during job opening the job task is not completed.
Instead, the job task's state is updated to `failed` with a
corresponding reason.
2021-09-03 12:12:04 +03:00
Martijn van Groningen d7439208bd
Disable bwc tests for backporting #76800 (#77232) 2021-09-03 11:01:21 +02:00
Armin Braun 38faeefd85
Fix MatchOnlyTextFieldMapper Retaining a Reference to its Builder (#77201)
Just like #77131 but for the `MatchOnlyTextFieldMapper`. Also, cleaned up a few
other minor things in it to make the constructor code for this class easier to follow.
2021-09-03 10:43:40 +02:00
Philip Krauss 6d841043f5
Flip HTTP methods in _mvt rest-api-spec (#77228) 2021-09-03 09:52:28 +02:00
David Turner 45bb29f408
Move PeerFinder inner interfaces to top level (#77194)
Today ConfiguredHostsResolver and TransportAddressConnector are declared
within PeerFinder, for no particular reason. This commit lifts them to
the top level.
2021-09-03 08:36:36 +01:00
Martijn van Groningen 1ae4f3c937
Add enrich node cache (#76800)
Introduce a LRU cache to avoid searches that occur frequently
from the enrich processor.

Relates to #48988
2021-09-03 09:33:44 +02:00
David Turner 1f15764e43
Avoid redundant connections in ClusterConnectionManager (#77196)
Today it's possible to open two connections to a node, and then we
notice when registering the second connection and close it instead.
Fixing #67873 will require us to keep tighter control over the identity
and lifecycle of each connection, and opening redundant connections gets
in the way of this. This commit adds a check for an existing connection
_after_ marking the connection as pending, which guarantees that we
don't open those redundant connections.
2021-09-03 08:09:12 +01:00
David Turner bfcc93a042
Anonymize AbstractRefCounted (#77208)
Today `AbstractRefCounted` has a `name` field which is only used to
construct the exception message when calling `incRef()` after it's been
closed. This isn't really necessary, the stack trace will identify the
reference in question and give loads more useful detail besides. It's
also slightly irksome to have to name every single implementation.

This commit drops the name and the constructor parameter, and also
introduces a handy factory method for use when there's no extra state
needed and you just want to run a method or lambda when all references
are released.
2021-09-03 07:59:44 +01:00
Ignacio Vera 062276f84d
Refactor GeoBoundingBoxQuery integration tests (#77103)
This commit breaks the test to separate the testing of legacy geo_shape field.
2021-09-03 08:51:52 +02:00
Ignacio Vera 63310fd86c
Remove unused geo module (#77016)
Module was used to register geo_shape mapping into the oss distribution.
2021-09-03 07:12:01 +02:00
Armin Braun b7c5293228
Make DataStreamTimestampFieldMapper a Singleton (#77209)
No need to have multiple instances of this one, it's either
disabled or enabled and that's it.
2021-09-02 21:59:10 +02:00
Adam Locke 6f6039877c
Remove ES_PATH_CONF (#77187)
The `$ES_PATH_CONF` variable isn't set at this point when users are first starting Elasticsearch, so changing mentions to the `config/` directory for clarity.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2021-09-02 15:14:45 -04:00
Benjamin Trent f2ea4253f2
Muting test for issue #77182 (#77202) 2021-09-02 11:38:00 -04:00
William Brafford e04e5eba65
AutoCreate should work for non-primary system indices (#77045)
Previously, we handled the case of a write request to a system index
alias without a backing index by auto-creating the primary index. This
had the unfortunate side-effect of making it impossible to auto-create
non-primary system indices. This commit fixes the bug so that we can
handle both cases.

* Add internal cluster test for system index auto create
* Allow auto-creation of non-primary indices for a system index pattern
* Use primary index if autocreate is called with system index alias name
2021-09-02 10:55:02 -04:00
Alan Woodward f70123ff9f
Add methods to retrieve doc and/or metadata fields only from SearchHit (#77192)
The SearchHit.getFields() methods returns both document and metadata
fields commingled. This commit adds new methods to retrieve them
separately.

Fixes #77171
2021-09-02 15:42:22 +01:00
Armin Braun 0305f95d67
Mute ReleaseNotesIndexGeneratorTest (#77193)
This is failing constantly on CI https://github.com/elastic/elasticsearch/issues/77190
2021-09-02 15:45:12 +02:00
Henning Andersen f585a73238
Recovery stats test verify recovered from snapshot (#76974)
Fix test to verify against 7.15+
2021-09-02 15:31:45 +02:00
Ignacio Vera 68e44bd834
Mute test LegacyGeoShapeIT#testBulk (#77175) 2021-09-02 13:18:51 +02:00
Armin Braun e60f7ed96f
Fix Temporarily Leaking Shard Level Metadata Blobs in some Cases (#76562)
When doing out of order finalizations we would leak shard level metadata blobs at times.
This commit enhances the cleanup logic after finalization to catch these leaked blobs
and adds a test that would without this fix trip the leaked blobs assertion in the test
infrastructure.
2021-09-02 13:08:35 +02:00
Francisco Fernández Castaño b7838d680f
Fix FollowingEngineTests#testOptimizeMultipleVersions (#75583)
In certain concurrent indexing scenarios where there are deletes
executed and then a new indexing operation, the following engine
considers those as updates breaking one of the assumed invariants.

Closes #72527
2021-09-02 11:12:14 +02:00
Artem Prigoda a9747988d6
Add a unit test verifying that the IPv6 scope id is optional for node ips (#76889)
Closes #72091
Ref #60172
2021-09-02 11:11:25 +02:00
Martijn van Groningen dd277f6b6d
Adjust bwc logic after backporting #76881 (#77167) 2021-09-02 10:57:07 +02:00
Armin Braun c082c2578a
Fix NumberFieldMapper Referencing its Own Builder (#77131)
Investigating the heap use of mapper instances I found this.
It seems quite a bit of overhead for these instances goes into
the builder field. In other mappers we retain the script service
and the script outright, so I did the same thing here to make these
instances a little smaller.
2021-09-02 10:26:41 +02:00
Ioannis Kakavas 27062e5039
Prioritize IPv4 addresses in the enrollment token (#76898)
The enrollment token contains a list of addresses where the node is
listening for requests in the HTTP layer. This change makes it so
we order that list before serializing it in the token prioritizing
IPv4 addresses vs IPv6 addresses. The reasoning is that
- it is usually more probable for IPv4 addresses to be reachable
so in the case where the consumer of the token needs to iterate
through available addresses, this might lead to getting a response
with fewer attempts
- When persisted to configuration files and/or shown in UIs, IPv4
addresses look more familiar (less surprising) to users
2021-09-02 09:28:29 +03:00
Martijn van Groningen b24a057577
Execute EnrichPolicyRunner on a non dedicated master node. (#76881)
Introduce an internal action that the execute policy action delegates to.
This to ensure that the actual policy execution is never executed on the elected master node
or dedicated master nodes. In case the cluster consists out of a single node then
the internal action will attempt to execute on the current/local node.

The actual enrich policy execution is encapsulated in the `EnrichPolicyRunner` class.
This class manages the execution of several API calls, so this itself isn't doing anything heavy.
However the coordination of these api calls (in particular the reindex api call) may involve
some non-neglectable work/overhead and this shouldn't be performed on the elected master
or any other dedicated master node.

Closes #70436
2021-09-02 08:26:02 +02:00
Yang Wang 6c4df63a2d
Fix randomAuthentication by removing duplicate key (#77159)
randomArray sometimes generates duplicate entries and the subsequent
conversion to a Map hence fails due to the duplicate key. This PR fixes
the failure by ensure array elements are distinct before converting to a
Map. The alternative is to generate distinct array entries from the
beginning. But given how the code is used in the context, a simple
distinct call is easier and sufficient.

Resolves: #77127
2021-09-02 14:29:49 +10:00
Jake Landis edcdd30b62
Compatible REST API - minor build clean up (#77145)
This commit allows the compatible REST API tests to execute on Windows.
They were previously excluded from Windows due to a command line limit
when defining a very large exclusion list. That exclusion list is much
smaller now and they will now execute properly on Windows.

Also, an empty exclusion list has been removed from the build config.
2021-09-01 15:51:14 -05:00
Bogdan Pintea 9570236e4d
EQL: Sequences will now support nano-timestamps (#76953)
With this change nanosecond-resolution timestamps can be used to drive
the EQL sequence query.
2021-09-01 21:20:29 +02:00