Commit Graph

9244 Commits

Author SHA1 Message Date
Boaz Leskes adb49efe17
Non-peer recovery should set the global checkpoint (#27965)
Non-Peer recoveries should restore the global checkpoint rather than wait for the activation of the primary. This brings us a step closer to a universe where a recovered shard always has a valid global checkpoint. Concretely:

1) Recovery from store can read the checkpoint from the translog
2) Recovery from local shards and snapshots can set the global checkpoint to the local checkpoint as this is the only copy of the shard.
3) Recovery of an empty shard can set it to `NO_OPS_PERFORMED`

Peer recoveries will follow but require more work and thus will have their own PR.

I also used the moment to clean up `IndexShard`'s api around starting the engine and doing recovery from the translog. The current naming are a relic of the past and don't align with the current naming schemes in the engine.
2017-12-22 21:39:12 +01:00
Nhat Nguyen 6435928c4f Remove no existing commits assertion in onInit()
This assertion does not hold if a shard is recovered from an empty store
but failed then retries. Moreover, if the openMode is CREATE_INDEX_*, we
pass CREATE mode to the IndexWriterConfig to create a new index and
overwrite the existing one.

Closes #27960
2017-12-22 15:04:16 -05:00
Ryan Ernst 0375d887f2
Plugins: Add validation to plugin descriptor parsing (#27951)
This commit checks there are no leftover unparsed elements when parsing
a plugin descriptor.
2017-12-22 10:02:11 -08:00
Tanguy Leroux bd9daf422e
Do not start snapshots that are deleted during initialization (#27931)
When a new snapshot is created it is added to the cluster state as a
snapshot-in-progress in INIT state, and the initialization is kicked
off in a new runnable task by SnapshotService.beginSnapshot(). The
initialization writes multiple files before updating the cluster state
to change the snapshot-in-progress to STARTED state. This leaves a
short window in which the snapshot could be deleted (let's say, because
the snapshot is stuck in INIT or because it takes too much time to
upload all the initialization files for all snapshotted indices). If
the INIT snapshot is deleted, the snapshot-in-progress becomes ABORTED
but once the initialization in SnapshotService.beginSnapshot() finished
it is change back to STARTED state again.

This commit avoids an ABORTED snapshot to be started if it has been
deleted during initialization. It also adds a test that would have failed
with the previous behavior, and changes few method names here and there.
2017-12-22 12:59:36 +01:00
Tanguy Leroux 098f82f086
[Test] Do not rely on MockZenPing for Azure tests (#27945)
This commit changes some Azure tests so that they do not rely on
MockZenPing and TestZenDiscovery anymore, but instead use a mocked
AzureComputeService that exposes internal test cluster nodes as if
they were real Azure nodes.

Related to #27859

Closes #27917, #11533
2017-12-22 09:58:02 +01:00
Ryan Ernst da703a7383
Tests: Update plugin info unit tests to use expectThrows (#27953) 2017-12-21 14:23:40 -08:00
Nhat Nguyen 7e3dc122fd Revert "Mute testRetentionPolicyChangeDuringRecovery"
This test is fixed by https://github.com/elastic/elasticsearch/pull/27947
This reverts commit cba80f3972d76f655a1a048aab1121b56f2b3a56.
2017-12-21 16:58:07 -05:00
Nhat Nguyen c831442352
Persist global checkpoint when finalizing peer recovery (#27947)
Today we don't persist the global checkpoint when finishing a peer 
recovery even though we advance an in memory value. This commit persists
the global checkpoint in RecoveryTarget#finalizeRecovery.

Closes #27861
2017-12-21 16:51:30 -05:00
Jim Ferenczi e5f0852d5f
Remove unused search plugin extension (#27943)
Search response listeners should not be exposed in search plugin.
Support was added but reverted right after (not present in any release).
Though the SearchPlugin still contains a default definition for search response listeners
due to a broken revert. This change removes this extension point that is basically no-op.
2017-12-21 22:15:55 +01:00
Martijn van Groningen a54798354b
simplify methods 2017-12-21 19:42:32 +01:00
Martijn van Groningen 791c5ddd7e
aggs: Add a method that is invoked before the `getLeafCollector(...)` of children aggregators is invoked.
In the case of nested aggregator this allows it to push down buffered child docs down to children aggregator.
Before this was done as part of the `NestedAggregator#getLeafCollector(...)`, but by then the children aggregators
have already moved on to the next segment and this causes incorrect results to be produced.

Closes #27912
2017-12-21 19:28:28 +01:00
Mayya Sharipova cbd271e497
Limit the analyzed text for highlighting (#27934)
* Limit the analyzed text for highlighting

- Introduce index level settings to control the max number of character
to be analyzed for highlighting
- Throw an error if analysis is required on a larger text

Closes #27517
2017-12-21 10:19:58 -05:00
Jim Ferenczi 5ac5fd95ae
Move early termination based on index sort to TopDocs collector (#27666)
Lucene TopDocs collector are now able to early terminate the collection
based on the index sort. This change plugs this new functionality directly in the
query phase instead of relying on a dedicated early terminating collector.
2017-12-21 08:57:06 +01:00
Tim Brooks 06b313025c
Add elasticsearch-nio jar for base nio classes (#27801)
This is related to #27802. This commit adds a jar called
elasticsearch-nio that contains the base nio classes that will be used
for the tcp nio transport and eventually the http nio transport.

The jar does not depend on elasticsearch:core, so all references to core
have been removed.
2017-12-20 16:29:16 -06:00
Maxime Gréau d9fff6d8f2 Add unreleased v6.1.2 version 2017-12-20 19:51:29 +01:00
Nhat Nguyen 54b6885844
Check index under the store metadata lock (#27768)
Today when we get a metadata snapshot directly from a store directory, 
we acquire a metadata lock, then acquire an IndexWriter lock. However,
we create a CheckIndex in IndexShard without acquiring the metadata lock 
first. This causes a recovery failed because the IndexWriter lock can be
still held by method snapshotStoreMetadata. This commit makes sure to
create a CheckIndex under the metadata lock.

Closes #24481
Closes #27731
Relates #24787
2017-12-20 11:26:06 -05:00
Colin Goodheart-Smithe 4cbbe3ed93
Fixes DocStats to not report index size < -1 (#27863)
Previously to this change when DocStats are added together (for example when adding the index size of all primary shards for an index)  we naively added the `totalSizeInBytes` together. This worked most of the time but not when the index size on one or multiple shards was reported to be `-1` (no value).

This change improves the logic by considering if the current value or the value to be added is `-1`:
* If the current and new value are both `-1` the value remains at `-1`
* If the current value is `-1` and the new value is not `-1`, current value is changed to be equal to the new value
* If the current value is not `-1` and the new value is `-1` the new value is ignored and the current value is not changed
* If both the current and new values are not `-1` the current value is changed to be equal to the sum of the current and new values.

The change also re-enables the failing rollover YAML test that was failing due to this bug.
2017-12-20 14:45:09 +00:00
Adrien Grand 77711508b0
Upgrade to Lucene 7.2.0. (#27910) 2017-12-20 14:17:40 +01:00
Simon Willnauer 5b229c31d6
Use `_refresh` to shrink the version map on inactivity (#27918)
We used to shrink the version map under an external lock. This is
quite ambigious and instead we can simply issue an empty refresh to
shrink it.

Closes #27852
2017-12-20 13:53:41 +01:00
Simon Willnauer c4fae375b0
Make KeyedLock reentrant (#27920)
Today we prevent that the same thread acquires the same lock more than once.
This restriction is a relict form the early days of this concurrency construct
and can be removed.
2017-12-20 13:53:03 +01:00
Simon Willnauer 0779af6dd2
Move uid lock into LiveVersionMap (#27905)
While the LiveVersionMap is an internal class that belongs to the engine we do
rely on some external locking to enforce the desired semantics.  Yet, in tests
we mimic the outer locking but we don't have any way to enforce or assert on
that the lock is actually hold.  This change moves the KeyedLock inside the
LiveVersionMap that allows the engine to access it as before but enables
assertions in the LiveVersionMap to ensure the lock for the modifying or
reading key is actually hold.
2017-12-20 08:34:58 +01:00
Christoph Büscher fb2fd4e8ee
Fix preserving FiltersAggregationBuilder#keyed field on rewrite (#27900)
Currently FiltersAggregationBuilder#doRewrite creates a new FiltersAggregationBuilder which doesn't correctly copy the original "keyed" field if a non-keyed filter gets rewritten.
This can cause rendering bugs of the output aggregations like the one reported in #27841.

Closes #27841
2017-12-19 19:56:12 +01:00
Tim Brooks 41677b0b9e
Default to no http read timeout (#27879)
Elasticsearch offers a number of http requests that can take a while to
execute. In #27713 we introduced an http read timeout that defaulted to
30 seconds. This means that if no reads happened for 30 seconds (even
after a request is received), the connection would be closed due to
timeout.

This commit disables the read timeout by default to allow us to evaluate
the impact of read timeouts and to avoid introducing distruptive
behavior.
2017-12-19 11:44:48 -07:00
Nhat Nguyen 0c1ac2e700 Revert "testCorruptTranslogTruncation: add logging"
We can reduce logging for this test as it's fixed in https://github.com/elastic/elasticsearch/pull/27887
This reverts commit e0e698bc26.
2017-12-19 12:13:23 -05:00
Nhat Nguyen 6b0d90b9d4
TEST: Corrupt some translog files used in recovery (#27887)
Currently, method corruptTranslogFiles corrupts some translog files
whose translog_gen are at least the min_required_translog_gen from the
translog checkpoint. However this condition is not enough for
recoverFromTranslog to be always failed.  If we corrupt only translog
operations from only translog files whose translog_gen are smaller than
the min_translog_gen of a recovering index commit, recoverFromTranslog
will be ok as we won't read translog operations from those files.

This commit makes sure corruptTranslogFiles to corrupt some translog 
files that will be used in recoverFromTranslog.

Closes #27538
2017-12-19 12:01:49 -05:00
Nhat Nguyen 25b0a7b20f Revert "Add @AwaitsFix for #27890"
This test was fixed in e9a3932dbc.

This reverts commit 1383cab267.
2017-12-19 11:27:03 -05:00
Nhat Nguyen e9a3932dbc Fix incorrectly assign local checkpoint from max_seqno
Relates #27837
2017-12-19 11:18:36 -05:00
kel 192b263e31 Make AbstractQueryBuilder.declareStandardFields to be protected (#27894) 2017-12-19 16:34:08 +01:00
David Turner b26cc36928 Mute testRetentionPolicyChangeDuringRecovery
Relates #27861.
2017-12-19 12:05:45 +00:00
Albert Zaharovits 01a47baa10
Retain originalIndex info when rewriting FieldCapabilities requests (#27761)
A FieldCapabilities request can cover multiple indices (or aliases pointing to multiple indices).
When rewriting the request for each index, store the original requested indices.
2017-12-19 13:38:41 +02:00
David Turner 1383cab267 Add @AwaitsFix for #27890 2017-12-19 08:41:42 +00:00
Boaz Leskes bea9471b2f
Use port 0 InternalTestCluster nodes (#27859)
We currently have a complicated port assignment scheme to make sure that the nodes span off by the internal test cluster will be assigned fixed port ranges that will also not collide between clusters. The port ranges need to be fixed in advance so that the nodes will be able to find each other via `UnicastZenPing`.

This approach worked well for the last few years but we are now at a point that our testing has grown beyond it and we exceed the 5 reusable ranges per JVM. This means that nodes are not always assigned the first 5 ports in their range which causes cluster formation issues. On top of that, most of the clusters that are span up don't even rely on `UnicastZenPing` but rather `MockZenPings` that uses in memory maps for discovery (with the down side that they are not influenced by network disruption simulations).

This PR changes `InternalTestCluster` to use port 0 as a fixed assignment. This will allow the OS to manage ports and will ensure we don't have collisions. For tests that need to simulate network disruptions (and thus can't use `MockZenPings`), a new `UnicastHostProvider` is introduced that is based on the current state of the test cluster. Since that is only resolved at run time, it is aware of the port assignments of the OS.

Closes #27818
Closes #27762
2017-12-19 08:43:03 +01:00
Alexander Kazakov d9a0b50893 Using DocValueFormat::parseBytesRef for parsing missing value parameter (#27855) 2017-12-18 20:50:58 +01:00
Jason Tedor 054711dd88 More refinement of version is compatible test
This test further refines the version is compatible test, adding
additional handling of edge cases.
2017-12-18 13:20:22 -05:00
Nhat Nguyen 0d99fadd2a Put back lastSyncedGlobalCheckpoint in deletion policy
The PR #27837 unintentionally changed to an in memory global checkpoint.
2017-12-18 11:54:50 -05:00
Jason Tedor fa1159a854 Tighten version compatibility test
This commit tightens the version compatibility test, generalizing it
beyond a hard-coded 7.0.0.
2017-12-18 10:40:06 -05:00
Yannick Welsch a5e8a221ec
Move GlobalCheckpointTracker and remove SequenceNumbersService (#27837)
This commit moves GlobalCheckpointTracker from the engine to IndexShard, where it better fits logically: Tracking the global checkpoint based on the local checkpoints of all shards in the replication group is not a property of the engine, but rather a property fulfilled by the current primary shard. The LocalCheckpointTracker on the other hand is driven by the contents of the local translog. By moving GlobalCheckpointTracker to IndexShard, it makes little sense to keep the SequenceNumbersService class around - it would only wrap the LocalCheckpointTracker. This commit therefore removes the class and replaces occurrences of SequenceNumbersService in the engine directly by LocalCheckpointTracker.
2017-12-18 15:27:44 +01:00
Jason Tedor 76771242e8 Fix version tests for release tests
This commit fixes the version tests for release tests. The problem here
is that during release tests all version should be treated as released
so the assertions must be modified accordingly.

Relates #27815
2017-12-18 08:51:37 -05:00
Boaz Leskes 9cd69e7ec1
recovery from snapshot should fill gaps (#27850)
When snapshotting the primary we capture a lucene commit at an arbitrary moment from a sequence number perspective. This means that it is possible that the commit misses operations and that there is a gap between the local checkpoint in the commit and the maximum sequence number.

When we restore, this will create a primary that "misses" operations and currently will mean that the sequence number system is stuck (i.e., the local checkpoint will be stuck). To fix this we should fill in gaps when we restore, in a similar fashion to normal store recovery.
2017-12-18 13:33:39 +01:00
kel 26fc717ddd Remove unused class PreBuiltTokenFilters (#27839) 2017-12-18 11:48:38 +01:00
kel 7a27a2770b Reject scroll query if size is 0 (#22552) (#27842) 2017-12-18 10:38:41 +01:00
David Turner e6da564eb1
Handle case where the hole vertex is south of the containing polygon(s) (#27685)
Normally the hole is assigned to the component of the first edge to the south
of one of its vertices, but if the chosen hole vertex is south of everything
then the binary search returns -1 yielding an ArrayIndexOutOfBoundsException.
Instead, assign the vertex to the component of the first edge to its north.
Subsequent validation catches the fact that the hole is outside its component.

Fixes #25933
2017-12-18 08:50:40 +00:00
Jason Tedor 75c0cd0672
Move range field mapper back to core
This commit moves the range field mapper back to core so that we can
remove the compile-time dependency of percolator on mapper-extras which
compilcates dependency management for the percolator client JAR, and
modules should not be intertwined like this anyway.

Relates #27854
2017-12-17 14:27:10 -05:00
Jason Tedor fade828c50
Fix publication of elasticsearch-cli to Maven
This commit addresses the publication of the elasticsearch-cli to
Maven. For now for simplicity we publish this to Maven so that it is
available as a transitive dependency for any artifacts that depend on
the core elasticsearch artifact. It is possible that in the future we
can simply exclude this dependency but for now this is the safest and
simplest approach that can happen in a patch release.

Relates #27853
2017-12-17 11:51:18 -05:00
Nhat Nguyen 4f62b51c87
Use lastSyncedGlobalCheckpoint in deletion policy (#27826)
Today we use the in-memory global checkpoint from SequenceNumbersService
to clean up unneeded commit points, however the latest global checkpoint
may haven't fsynced to the disk yet. If the translog checkpoint fsync
failed and we already use a higher global checkpoint to clean up commit
points, then we may have removed a safe commit which we try to keep for
recovery.

This commit updates the deletion policy using lastSyncedGlobalCheckpoint
from Translog rather the in memory global checkpoint.

Relates #27606
2017-12-16 11:03:31 -05:00
kel f5e0932c8d Add version support for inner hits in field collapsing (#27822) (#27833)
Add version support for inner hits in field collapsing
2017-12-15 18:00:40 +01:00
Jason Tedor 7945848dd6 Register HTTP read timeout setting
This commit registers the HTTP read timeout setting so that it can
actually be set.
2017-12-15 10:56:00 -05:00
Simon Willnauer 481d98b8d5
Remove `operationThreaded` from Java API (#27836)
This option is completely unused. Some places set it but we never read
the value neither respect it.
2017-12-15 15:20:55 +01:00
Colin Goodheart-Smithe c93cc1bb8f
Fix ByteSizeValue serialisation test 2017-12-15 12:10:10 +00:00
Simon Willnauer d941c64edb
Optimize version map for append-only indexing (#27752)
Today we still maintain a version map even if we only index append-only
or in other words, documents with auto-generated IDs. We can instead maintain
an un-safe version map that will be swapped to a safe version map only if necessary
once we see the first document that requires access to the version map. For instance:
 * a auto-generated id retry
 * any kind of deletes
 * a document with a foreign ID (non-autogenerated

In these cases we forcefully refresh then internal reader and start maintaining
a version map until such a safe map wasn't necessary for two refresh cycles.
Indices / shards that never see an autogenerated ID document will always meintain a version
map and in the case of a delete / retry in a pure append-only index the version map will be
de-optimized for a short amount of time until we know it's safe again to swap back. This
will also minimize the requried refeshes.

Closes #19813
2017-12-15 12:13:10 +01:00