Commit Graph

7229 Commits

Author SHA1 Message Date
Lee Hinman fed2a1a822 Fix Translog.Delete serialization for sequence numbers (#22543)
* Fix Translog.Delete serialization for sequence numbers

Translog.Delete used `.writeVLong` instead of `.writeLong` for the sequence
number and primary term (and their respective "read" variants). This could lead
to issues where a 5.x node sent a translog operation with a negative sequence
number (-2 for unassigned seq no) that tripped an assertion serializing a
negative number and causing ES to exit.

Adds a unit test for serialization and a mixed-cluster REST test, since that was
how this was originally caught.

* Use more realistic values for random seqNum and primary term

* Add comment with TODO for removal in 7.0

* Change comment into an assert
2017-01-11 10:08:04 -07:00
Ali Beyad 389ffc93d8 Adds debugging information for invalid repository data x-content 2017-01-11 11:27:25 -05:00
Simon Willnauer 6810125a8b Prevent open channel leaks if handshake times out or is interrupted (#22554)
The low level TCP handshake can cause channel / connection leaks if it's interrupted
since the caller doesn't close the channel / connection if the handshake was not successful.
This commit fixes the channel leak and adds general test infrastructure to detect channel leaks
in the future.
2017-01-11 17:02:36 +01:00
Nik Everett abb7d7841f Remove SearchRequestParsers (#22538)
It is empty now that we've moved all the parsing into `namedObject`.
2017-01-11 10:28:14 -05:00
Yannick Welsch baef86b9d3 [TEST] Disable testRamBytesUsed on JDK 9 2017-01-11 10:55:29 +01:00
Luca Cavanna 0f391336f5 Clean up SearchShardTarget (#22468)
* unify shard target setter

* Remove indexText member from SearchShardTarget

* Remove duplicated indexName getter from SearchShardTarget

* Remove duplicated shardId getter from SearchShardTarget

* Remove duplicated nodeIde getter from SearchShardTarget

* Rename SearchShardTarget#nodeIdText getter to getNodeIdText

* Remove unused InternalSearchHit#internalSourceRef unused method

* Remove unused InternalSearchHit#internalHighlightFields unused method

* Make SearchShardTarget members final
2017-01-11 10:08:31 +01:00
Simon Willnauer acb7f7851d Allow affix settings to be dynamic / updatable (#22526)
Today affix settings are not dynamic since it's required to know
it's namespace in order to pull a concrete setting from it. This is not possible
in practice since the namespaces are dynamic by design. This change allows to register
a specialized settings consumer that consumes the namespace and the actual value if
a setting gets updated.
2017-01-11 09:24:47 +01:00
Nik Everett b71b8acf59 Remove ClusterService from ctors in reindex (#22539)
Moves fetching the local node id into `NodeClient` which is a
fairly useful place to put it so you can generate task ids from
`NodeClient#executeLocally`.
2017-01-10 18:26:06 -05:00
Luca Cavanna ddb93946aa use ElasticsearchException#renderException in BytesRestResponse#convert (#22531) 2017-01-10 20:58:31 +01:00
Tanguy Leroux 2dcb05fca8 Add fromxcontent methods to index response (#22229)
This commit adds the parsing fromXContent() methods to the IndexResponse class. The method is based on a ObjectParser because it is easier to use when parsing parent abstract classes like DocWriteResponse.

It also changes the ReplicationResponse.ShardInfo so that it now implements ToXContentObject. This way, the ShardInfo.fromXContent() method can be used by the IndexResponse's ObjectParser.
2017-01-10 20:25:32 +01:00
Ali Beyad 898f5a1e89 Removes remaining snapshot backwards compatibility logic (#22512)
Previously, we removed all unneeded backward compatibility logic 
from the BlobStoreRepository because 6.0 does not need to support
2.x snapshot formats.  During the process of removing this backward
compatibility logic, some code was leftover that is no longer
necessary.  This commit removes all the remaining unnecessary
backwards compatibility code in BlobStoreRepository.
2017-01-10 12:54:29 -06:00
Christoph Büscher 93367fb4a8 [Test] Fix test problem with potentially duplicate keys in rest response highlight section 2017-01-10 18:57:13 +01:00
Nik Everett d50f96e122 Remove InternalAggregation.Type (#22511)
It is no longer needed. It used to contain a lot of strings
used by serialization but those have since been removed. Now
it is just another thing to pass around that we don't really
need.
2017-01-10 11:57:19 -05:00
Yannick Welsch 1cbb97d361 Use general cluster state batching mechanism for snapshot state updates (#22528)
Relates to #14899
2017-01-10 17:54:49 +01:00
Yannick Welsch 8be28aa58a Don't use Guava as compile dependency 2017-01-10 16:33:18 +01:00
Simon Willnauer 081c1ad416 Allow affix settings to delegate to actual settings (#22523)
Affix settings are useful to namespace a certain setting. Yet, affix settings
must be specialized for their concrete type which causes lot of code duplication.
This commit allows to reuse an existing setting with and affix setting as soon as
a concrete key is available.
2017-01-10 15:14:55 +01:00
Matt Weber 28273e0a52 Additional Graph Support in Match Query (#22503)
Make match queries that use phrase prefix or cutoff frequency options
graph aware.

Closes #22490
2017-01-10 08:41:03 -05:00
Boaz Leskes 9aba49c571 ZenDiscoveryUnitTests should close objects in reverse order of creation
One needs to close the higher level objects (like UnicastZenPing) before closing the transport service. The latter can throw assertions w.r.t open connections
2017-01-10 14:11:27 +01:00
Christoph Büscher 5f9dfe3186 Add parsing from xContent to InternalSearchHit and InternalSearchHits (#22429)
This adds methods to parse InternalSearchHit and InternalSearchHits from their
xContent representation. Most of the information in the original object is
preserved when rendering the object to xContent and then parsing it back.
However, some pieces of information are lost which we currently cannot parse
back from the rest response, most notably:

* the "match" property of the lucene explanation is not rendered in the
  "_explain" section and cannot be reconstructed on the client side
* the original "shard" information (SearchShardTarget) is only rendered if the
  "explanation" is also set, also we loose the indexUUID of the contained
  ShardId because we don't write it out. As a replacement we can use
  ClusterState.UNKNOWN_UUID on the receiving side
2017-01-10 14:00:04 +01:00
Yannick Welsch 9fc1a735cc Keep NodeConnectionsService in sync with current nodes in the cluster state (#22509)
The NodeConnectionsService currently determines which nodes to connect to / disconnect from by inspecting cluster state changes and connecting to added nodes / disconnecting from removed nodes. When a master steps down (for example due to another master-eligible node shutting down which brings the number of master-eligible nodes below minimum_master_master), and the connection to other existing nodes was dropped while pinging, however, the connection to these nodes is not re-established while publishing the first cluster state that establishes the node as master.
This commit changes the NodeConnectionsService connect / disconnect logic to always rely on the state that is to be / was published, looking not only at the added / removed nodes, but validating that exactly all nodes that are currently registered in NodeConnectionsService are connected (corresponds to a NOOP if the node is already connected).
2017-01-10 13:29:49 +01:00
Tanguy Leroux b9061c1cc9 [TESTS] Fix GetResultTests.testGetSourceAsBytes() (#22524)
The document in the randomized GetResult can exist with no source (like if the _source was disabled in mappings), that's why the test should not always expect a non null source when the doc exists.
2017-01-10 13:12:00 +01:00
Jim Ferenczi 433c822d4f Promote longs to doubles when a terms agg mixes decimal and non-decimal numbers (#22449)
* Promote longs to doubles when a terms agg mixes decimal and non-decimal number

This change makes the terms aggregation work when the buckets coming from different indices are a mix of decimal numbers and non-decimal numbers. In this case non-decimal number (longs) are promoted to decimal (double) which can result in a loss of precision for big numbers.

Fixes #22232
2017-01-10 11:50:56 +01:00
henakamaMSFT 72ec3d2661 Fixing the error message to report the number of docs correctly for each node (#22515)
There is a bug in the error message that is thrown if the number of docs differs between the source and target shards when recovering a shard with a syncId. The source and target doc counts are swapped around.

Closes #21893
2017-01-10 09:57:57 +01:00
Nik Everett 3fb9254b95 Replace Suggesters with namedObject (#22491)
Removes another parser registery type thing in favor of
`XContentParser#namedObject`.
2017-01-09 16:51:08 -05:00
Nik Everett d623df9372 Remove AggregatorParsers
Meant to remove it with e3f77b4795.
It is no longer used.
2017-01-09 15:13:49 -05:00
Nik Everett e3f77b4795 Replace AggregatorParsers with namedObject (#22397)
Removes `AggregatorParsers`, replacing all of its functionality with
`XContentParser#namedObject`.

This is the third bit of payoff from #22003, one less thing to pass
around the entire application.
2017-01-09 13:59:38 -05:00
Nik Everett f75ef7adfd Use namedObject to parse AllocationCommands (#22489)
This removes `AllocationCommandRegistry` entirely and replaces
it with `XContentParser#namedObject`, removing another class from
guice.
2017-01-09 12:26:57 -05:00
Boaz Leskes be0c461b50 UnicastZenPingTests didn't properly wait for pinging rounds to be closed
The test ping and waited for the ping results to be returned but since we first return the result and then close temporary connections, assertions are tripped that expects all connections to close by end of test .

Closes #22497
2017-01-09 17:42:28 +01:00
Martijn van Groningen cb8f8fc9ad Don't ignore `ignore_unmapped` options on nested, has_child and has_parent queries if the wrapped query gets rewritten. 2017-01-09 17:17:34 +01:00
Jay Modi b04f8fe159 prevent NPE when calling GetResponse#getSourceAsBytesRef
This commit checks for a null BytesReference as the value for `source`
in GetResult#sourceRef and simply returns null. Previously this would
have resulted in a NPE. While this does seem internal at first glance, it can affect
user code as a GetResponse could trigger this when the document is missing.

Additionally, the CompressorFactory#uncompressIfNeeded now requires a
non-null argument.
2017-01-09 09:19:05 -05:00
Nik Everett f4884e0726 Replace SearchExtRegistry with namedObject (#22492)
This is one of the last things in `SearchRequestParsers`.
2017-01-09 08:35:54 -05:00
Yannick Welsch 8741691511 Fix primary relocation for shadow replicas (#22474)
The recovery process started during primary relocation of shadow replicas accesses the engine on the source shard after it's been closed, which results in the source shard failing itself.
2017-01-08 12:18:52 +01:00
Nik Everett 12923ef896 Close and flush refresh listeners on shard close
Right now closing a shard looks like it strands refresh listeners,
causing tests like
`delete/50_refresh/refresh=wait_for waits until changes are visible in search`
to fail. Here is a build that fails:
https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+multi_cluster_search+multijob-darwin-compatibility/4/console

This attempts to fix the problem by implements `Closeable` on
`RefreshListeners` and rejecting listeners when closed. More importantly
the act of closing the instance flushes all pending listeners
so we shouldn't have any stranded listeners on close.

Because it was needed for testing, this also adds the number of
pending listeners to the `CommonStats` object and all API to which
that flows: `_cat/nodes`, `_cat/indices`, `_cat/shards`, and
`_nodes/stats`.
2017-01-06 20:03:32 -05:00
Ali Beyad b0c009ae76 Gracefully handles pre 2.x compressed snapshots
In pre 2.x versions, if the repository was set to compress snapshots,
then snapshots would be compressed with the LZF algorithm.  In 5.x,
Elasticsearch no longer supports the LZF compression algorithm.  This
presents an issue when retrieving snapshots in a repository or upgrading
repository data to the 5.x version, because Elasticsearch throws an
exception when it tries to read the snapshot metadata because it was
compressed using LZF.

This commit gracefully handles the situation by introducing a new
incompatible-snapshots blob to the repository.  For any pre-2.x snapshot
that cannot be read, that snapshot is removed from the list of active
snapshots, because the snapshot could not be restored anyway.  Instead,
the snapshot is recorded in the incompatible-snapshots blob.  When
listing snapshots, both active snapshots and incompatible snapshots will
be listed, with incompatible snapshots showing a `INCOMPATIBLE` state.
Any attempt to restore an incompatible snapshot will result in an
exception.
2017-01-06 17:52:10 -05:00
javanna ded694fc83 Make StatusToXContent extend ToXContentObject and rename it to StatusToXContentObject
This also allows to make RestToXContentListener require ToXContentObject rather than ToXContent
2017-01-06 23:31:48 +01:00
javanna 8edf59c9e7 Make DocWriteResponse a ToXContentObject
This involved changing also index, delete, update so that bulk can print them out in its own format.
2017-01-06 23:31:48 +01:00
javanna d5510701a0 Make SearchResponse a ToXContentObject 2017-01-06 23:31:48 +01:00
javanna 3393d1b409 Make TermVectorsResponse a ToXContentObject 2017-01-06 23:31:48 +01:00
javanna 45d4938fcc Migrate some more responses to ToXContentObject 2017-01-06 23:31:48 +01:00
javanna f4aab0138d introduce ToXContentObject interface
`ToXContentObject` extends `ToXContent` without adding new methods to it, while allowing to mark classes that output complete xcontent objects to distinguish them from classes that require starting and ending an anonymous object externally.

Ideally ToXContent would be renamed to ToXContentFragment, but that would be a huge change in our codebase, hence we simply document the fact that toXContent outputs fragments with no guarantees that the output is valid per se without an external ancestor.

Relates to #16347
2017-01-06 23:31:48 +01:00
Ryan Ernst cd6e3f4cea Merge branch 'master' into keystore 2017-01-06 09:32:08 -08:00
Ryan Ernst 42ebfe7bdb fix NPE 2017-01-06 09:11:07 -08:00
Tim B b9c2c2f6f0 Move IfConfig.logIfNecessary call into bootstrap (#22455)
This is related to #22116. A logIfNecessary() call makes a call to
NetworkInterface.getInterfaceAddresses() requiring SocketPermission
connect privileges. By moving this to bootstrap the logging call can be
made before installing the SecurityManager.
2017-01-06 11:10:53 -06:00
Simon Willnauer 79093e1663 Ensure shrunk indices carry over version information from its source (#22469)
Today when an index is shrunk the version information is not carried over
from the source to the target index. This can cause major issues like mapping
incompatibilities for instance if an index from a previous major version is shrunk.

This commit ensures that all version information from the soruce index is preserved
when a shrunk index is created.

Closes #22373
2017-01-06 16:36:43 +01:00
Ryan Ernst eb596d7270 more renames 2017-01-06 01:03:45 -08:00
Ryan Ernst 6e406aed2d addressing more PR comments 2017-01-06 00:49:18 -08:00
javanna 5daf46286e remove ParseFieldMatcher usages from InternalSearchHit 2017-01-05 19:33:04 +01:00
javanna 975fee402a remove ParseFieldMatcher usages from suggesters 2017-01-05 19:33:04 +01:00
javanna 13dcb8ccbe remove ParseFieldMatcher usages from IngestMetadata 2017-01-05 19:33:04 +01:00
javanna d60e9bddd0 remove ParseFieldMatcher usages from IndexGraveyard 2017-01-05 19:33:04 +01:00