Commit graph

183 commits

Author SHA1 Message Date
Arpad Kiraly
30dd38bc97
Remove @UpdateForV9 annotation (#125024)
* Delete libs/core/src/main/java/org/elasticsearch/core/UpdateForV9.java

* Remove UpdateForV9 annotation in ConsumeProcessor.java
2025-03-18 12:52:18 +01:00
Matt Culbreth
b9ec8fd35e
Remove @UpdateForV9 annotations from Security code (#123176) 2025-03-12 18:32:37 -04:00
David Turner
4e00998cf2
Add @UpdateForV9 for ReferenceDocs (#123928)
The docs system is very different in v9 so we must update
`ReferenceDocs` to generate links that are not broken.
2025-03-04 07:38:20 +00:00
Arpad Kiraly
196e083502
Remove @UpdateForV9 usages that are related to security manager removal (#123690)
* Remove @UpdateForV9 annotation in RuntimeVersionFeature

Re ES-10338 the Core/Infra team agreed that this is not blocked on security manager removal. We should go ahead and remove these 2 instances of the @UpdateForV9 annotation, the code will be cleaned up soon with the removal of Security Manager.

* Remove @UpdateForV9 annotation from SystemJvmOptions

re ES-10338 the Core/Infra team agreed this is not blocked on security manager removal. We should go ahead and remove this instance of the @UpdateForV9 annotation.
2025-03-03 11:34:46 +01:00
Armin Braun
43f3032db8
Inline some methods into Releasables (#123273)
Bit of a random find. Looks like we're effectively spending something
like ~0.5% of the total CPU time on resolving virtual calls for these
methods. Inlining `IOUtils` reduces their size quite a bit, removes
dead-code for rethrowing `IOException` that is never actually thrown
and hopefully as a result improve compilation a little here.
2025-02-27 12:09:36 +01:00
Tim Vernum
de93304b95 Merge main into multi-project 2025-02-19 21:37:13 +11:00
David Turner
997233fd4e
Remove unused @UpdateForV9 owners (#122748)
Several teams have completed all outstanding `@UpdateForV9` tasks, so
this commit removes the corresponding `Owner` symbols.
2025-02-19 21:06:13 +11:00
Tim Vernum
680e7a6979 Merge revision 5c00341c2b into multi-project 2025-02-14 17:17:41 +11:00
Sam Xiao
5d48ded537
Improve SLM Health Indicator to cover missing snapshot (#121370)
Currently the SLM health indicator in health report turns YELLOW when snapshots fail for a number of times. However, the SLM health indicator stays GREEN if snapshot is not completed (no success or failure) for a long time. This change adds a new optional setting unhealthy_if_no_snapshot_within to SLM policy, that sets a time threshold. If the SLM policy has not had a successful snapshot for longer than the threshold, the SLM health indicator will turn YELLOW.
2025-02-14 09:54:26 +08:00
Niels Bauman
1b342b26ef Merge main into multi-project 2025-02-03 21:03:58 +10:00
Patrick Doyle
38a3844441
Entitlement tests using reflection (#121436)
* Entitlement IT cases for reflection

* EntitlementBootstrap selfTest using reflection

* Remove errant logging setting

* Lambdas instead of booleans

* [CI] Auto commit changes from spotless

* Refactor: Extract lambdas to method refs

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2025-01-31 19:18:17 +01:00
Tim Vernum
e5a0739005 Merge main into multi-project 2024-12-12 17:23:24 +11:00
John Verwolf
a560782995
Remove any references to V_7 (#118103)
This PR removes any references to org.elasticsearch.core.RestApiVersion#V_7.
2024-12-11 17:43:17 -08:00
Tim Vernum
64d5baf753 Merge main into multi-project 2024-12-11 16:40:08 +11:00
Lorenzo Dematté
ba9e0cef4d
Do not try to enable SecurityManager on JDK 24 (#117999) 2024-12-10 18:00:58 +01:00
Yang Wang
b8f8656fda Merge main into multi-project 2024-11-23 16:55:53 +11:00
Ryan Ernst
129e174551
Fix entitlement tools to build (#117351)
This commit adjusts the common lib of entitlement tools to use
elasticsearch.build so that it gets java version configuration
automatically. Additionally the mrjar plugin is removed from the core
lib since it is not used there.
2024-11-22 21:24:50 +00:00
Yang Wang
8d376c89ce ProjectResolver.getProjectId now takes no argument (MP-1749)
A ProjectResolver should be able to fetch the ProjectId without the need
of a cluster state. This PR changes the method to take no argument and
fixes cascading changes. It also adds a separate ProjectIdResolver
interface to host the new no-arg getProjectId method. The existing
ProjectResolver interface extends the new interface.

The major impact of the change is for tests and test helpers. It has
been made more obvious that most tests rely on the default project ID.
Previously this was hidden by the no arg `singleProjectOnly()` that just
pops the only project from cluster state. This only project is the
default project anyway in the current tests. The change just made this
fact explicit which I think is not a bad thing. We can definitely tidy
up the tests and test helpers once more pieces fall into places. Happy
to take suggestions.
2024-11-07 11:21:38 +11:00
Tim Vernum
da5da54f3f Merge main into multi-project 2024-11-06 16:05:33 +11:00
Patrick Doyle
338c0538b7
Dynamic entitlement agent (#116125)
* Refactor: treat "maybe" JVM options uniformly

* WIP

* Get entitlement running with bridge all the way through, with qualified
exports

* Cosmetic changes to SystemJvmOptions

* Disable entitlements by default

* Bridge module comments

* Fixup forbidden APIs

* spotless

* Rename EntitlementChecker

* Fixup InstrumenterTests

* exclude recursive dep

* Fix some compliance stuff

* Rename asm-provider

* Stop using bridge in InstrumenterTests

* Generalize readme for asm-provider

* InstrumenterTests doesn't need EntitlementCheckerHandle

* Better javadoc

* Call parseBoolean

* Add entitlement to internal module list

* Docs as requested by Lorenzo

* Changes from Jack

* Rename ElasticsearchEntitlementChecker

* Remove logging javadoc

* exportInitializationToAgent should reference EntitlementInitialization, not EntitlementBootstrap.

They're currently in the same module, but if that ever changes, this code would have become wrong.

* Some suggestions from Mark

---------

Co-authored-by: Ryan Ernst <ryan@iernst.net>
2024-11-06 00:07:52 +01:00
Tim Vernum
2ba2d2a995 Merge main into multi-project 2024-10-31 11:55:04 +11:00
Ryan Ernst
e5d5c17c99
Use directory name as project name for libs (#115720)
The libs projects are configured to all begin with `elasticsearch-`.
While this is desireable for the artifacts to contain this consistent
prefix, it means the project names don't match up with their
directories. Additionally, it creates complexities for subproject naming
that must be manually adjusted.

This commit adjusts the project names for those under libs to be their
directory names. The resulting artifacts for these libs are kept the
same, all beginning with `elasticsearch-`.
2024-10-29 13:02:28 -07:00
Tim Vernum
5933b041ef Add @FixForMultiProject annotation (MP-1691)
This annotation (which will be removed in the future) marks places in
the source code that we need to revisit as part of the multi-project
initiative.

It can be used to mark
 * code that should be removed,
 * code where we have made decisions that we'd like to revisit
 * places that are known to break when operating on multiple projects
* anything else that needs to be looked at before the code can be
considered production-ready
2024-10-15 19:02:21 +11:00
Patrick Doyle
3953331ac5
Entitlements for System.exit (#114015)
* Entitlements for System.exit

* Respond to Simon's comments

* Rename trampoline -> bridge

* Require exactly one bridge jar

* Use Type helpers to generate descriptor strings

* Various cleanup from PR comments

* Remove null "receiver" for static methods

* Use List<Type> instead of voidDescriptor

* Clarifying comment

* Whoops, getMethod

* SuppressForbidden System.exit

* Spotless

* Use embedded provider plugin to keep ASM off classpath

* Oops... forgot the punchline

* Move ASM license to impl

* Use ProviderLocator and simplify bridgeJar logic

* Avoid eager resolution of configurations during task configuration

* Remove compile-time dependency agent->bridge

---------

Co-authored-by: Mark Vieira <portugee@gmail.com>
2024-10-09 09:01:27 -04:00
David Turner
81bd8667cb
Define owners for UpdateForV9 annotations (#113926)
In order to better track the work needed to prepare this branch for the
major version upgrade, this commit adds a mandatory `owner` field to all
`UpdateForV9` (and `UpdateForV10`) annotations.
2024-10-02 11:37:14 +01:00
David Turner
f9921168f5
Mark AbstractRefCounted#mustIncRef as final (#113761)
The overridden `RefCounted` methods on `AbstractRefCounted` are all
`final`, but `mustIncRef` uses the default implementation and can still
be overridden. For the avoidance of doubt, this commit marks
`mustIncRef` as `final`.
2024-10-02 20:16:42 +10:00
Jake Landis
888188695a
Bump compatible rest api version to 9/8 (#113151)
This commit bumps the REST API version from 8 to 9. This effectively removes all support for REST API 
compatibility with version 7 (though earlier commits already chipped away at some v7 support).

This also enables REST API compatibility support for version 8, providing support for v8 compatibility headers, 
i.e. "application/vnd.elasticsearch+json;compatible-with=8" and no-op support (no errors) to accept v9 
compatibility headers i.e. "application/vnd.elasticsearch+json;compatible-with=9".

see additional context in the GH PR #113151
2024-09-26 14:52:05 -05:00
Mark Vieira
a59c182f9f
Add AGPLv3 as a supported license 2024-09-13 15:29:46 -07:00
Mark Vieira
4ce661cc48
Bump Elasticsearch version to 9.0.0 (#112570) 2024-09-11 09:40:11 -07:00
Armin Braun
306491aa9d
Fix a few toString implementations+usages that affect test performance (#112380)
No need to precompute the toString for `ActionListener` and
`Releasable`, that's quite expensive at times. Also string concat is way
faster than formating these days, so use that in the transport channels.
Lastly, short-circuit some obvious spots in network address
serialization and remove code that duplicates the JDK (remove the IPV4
specific forbidden API because it makes no sense, but still needed to
disable the check to make the build green because of the exclude on the
parent class).
2024-08-30 15:17:18 +02:00
Chris Hegarty
569184871b
Add UpdateForV10 annotation (#112281)
In preparation for the next major release of Elasticsearch, this commit adds the UpdateForV10 annotation.
2024-08-29 08:23:34 +01:00
Armin Braun
822ab72867
Enhance test utility for running tasks in parallel (#110610)
Follow up to #110552, add utility for starting tasks at the same time
via a barrier as discussed there. Also, make use of the new tooling in a
couple more spots to save LoC and thread creation.
2024-07-09 09:42:38 +10:00
Jonathan Buttner
fdb5058b13
[ML] Inference API rate limit queuing logic refactor (#107706)
* Adding new executor

* Adding in queuing logic

* working tests

* Added cleanup task

* Update docs/changelog/107706.yaml

* Updating yml

* deregistering callbacks for settings changes

* Cleaning up code

* Update docs/changelog/107706.yaml

* Fixing rate limit settings bug and only sleeping least amount

* Removing debug logging

* Removing commented code

* Renaming feedback

* fixing tests

* Updating docs and validation

* Fixing source blocks

* Adjusting cancel logic

* Reformatting ascii

* Addressing feedback

* adding rate limiting for google embeddings and mistral

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-06-05 08:25:25 -04:00
Nik Everett
04d3b9989f
ESQL: Begin optimizing Block#lookup (#108482)
This creates the infrastructure to allow optimizing the `lookup` method
when applied to `Vector`s and then implements that optimization for
constant vectors. Constant vectors now take one of six paths:
1. An empty positions `Block` yields an empty result set.
2. If `positions` is a `Block`, perform the un-optimized lookup.
3. If the `min` of the `positions` *Vector* is less that 0 then throw an
   exception.
4. If the `min` of the positions Vector is greater than the number of
   positions in the lookup block then return a single
   `ConstantNullBlock` because you are looking up outside the range.
5. If the `max` of the positions Vector is less than the number of
   positions in the lookup block then return a `Constant$Type$Block`
   with the same value as the lookup block. This is a lookup that's
   entirely within range.
6. Otherwise return the unoptimized lookup.

This is *fairly* simple but demonstrates how we can plug in more complex
optimizations later.
2024-05-10 13:45:42 -04:00
Simon Cooper
e7350dce29
Add a capabilities API to check node and cluster capabilities (#106820)
This adds a /_capabilities rest endpoint for checking the capabilities of a cluster - what endpoints, parameters, and endpoint capabilities the cluster supports
2024-05-08 14:44:26 +01:00
David Turner
9242e012c1
Intern common TimeValue constants (#107985)
The values `30s` and `1m` are used as defaults in various places in ES,
there's no need to create a new `TimeValue` instance each time they
appear. Moreover we already have constants for `0` and `-1`, but we
don't use these constants when reading the values off the wire.

This commit adds constants for `30s` and `1m` and adjusts the
deserialization code to avoid unnecessary allocation for common
`TimeValue` instances.

Relates #107984
2024-04-29 05:41:01 -04:00
Nik Everett
0f68c673f7
ESQL: Add BlockHash#lookup (#107762)
Adds a `lookup` method to `BlockHash` which finds keys that were already
in the hash without modifying it and returns the "ordinal" that the
`BlockHash` produced when that key had been called with `add`.

For multi-column keys this can change the number of values pretty
drastically. You get a combinatorial explosion of values. So if you have
three columns with 2 values each the most values you can get is 2*2*2=8.
If you have five columns with ten values each you can have 100,000
values in a single position! That's too many.

Let's do an example! This one has a two row block containing three
colunms. One row has two values in each column so it could produce at
most 8 values. In this case one of the values is missing from the hash,
so it only produces 7.

Block:
|   a  |   b  |   c  |
| ----:| ----:| ----:|
|    1 |    4 |    6 |
| 1, 2 | 3, 4 | 5, 6 |

BlockHash contents:
| a | b | c |
| -:| -:| -:|
| 1 | 3 | 5 |
| 1 | 3 | 6 |
| 1 | 4 | 5 |
| 1 | 4 | 6 |
| 2 | 3 | 5 |
| 2 | 3 | 6 |
| 2 | 4 | 6 |

Results:

|          ord        |
| -------------------:|
|                   3 |
| 0, 1, 2, 3, 4, 5, 6 |

The `add` method has a fairly fool-proof mechanism to work around this,
it calls it's consumers with a callback that can split positions into
multiple calls. It calls the callback in batches of like 16,000
positions at a time. And aggs uses the callback. So you can aggregate
over five colunms with ten values each. It's slow, but the callbacks
let us get through it.

Unlike `add`, `lookup` can't use a callback. We're going to need it to
return `Iterator` of `IntBlock`s containing ordinals. That's just how
we're going to use it. That'd be ok, but we can't split a single
position across multiple `Block`s. That's just not how `Block` works.

So, instead, we fail the query if we produce more than 100,000 entries
in a single position. We'd like to stop collecting and emit a warning,
but that's a problem for another change. That's a single 400kb array
which is quite big.

Anyway! If we're not bumping into massive rows we emit `IntBlocks`
targeting a particular size in memory. Likely we'll also want to plug in
a target number of rows as well, but for now this'll do.
2024-04-24 08:30:36 -04:00
David Turner
d7733c06e0
Make randomTimeValue() return a TimeValue (#107689)
Today various test utility methods construct a random string that can be
parsed as a `TimeValue`, but in practice almost everywhere we just parse
it straight away. With this change we have the utility methods return a
`TimeValue` directly.
2024-04-23 07:21:53 +01:00
Armin Braun
fc8e2b7897
Introduce Predicate Utilities for always true/false use-cases (#105881)
Just a suggetion. I think this would save us a bit of memory here and
there. We have loads of places where the always true lambdas are used
with `Predicate.or/and`. Found this initially when looking into field
caps performance where we used to heavily compose these but many spots
in security and index name resolution gain from these predicates.
The better toString also helps in some cases at least when debugging.
2024-03-04 14:01:21 +01:00
Armin Braun
842915701d
Faster ref-count logic for when ref-counted object does not escape (#105338)
Introducing a plain version of `AbstractRefCounted` as a compromise.
This saves a bunch of allocations and a circular reference to the object
holding the ref counted instance, making smaller SearchHit instances
etc. cheaper. We could get an even more direct solution here by making
these extend `AbstractRefCounted` but that would lose us the ability to
leak-track in tests, so doing it this way (same way Netty does it on
their end) as a compromise.
2024-02-10 14:50:12 +01:00
Armin Braun
cf27a501aa
Introduce StreamInput.readSlicedBytesReference (#105262)
This is mainly added as a prerequisite to slicing doc sources out of
bulk index requests. The few usages for it added in this PR have limited
performance impact but demonstrate correct functioning of the
implementations.

Co-authored-by: David Turner <david.turner@elastic.co>
2024-02-09 02:30:30 +01:00
Ryan Ernst
6375e9f443
Add native access library (#105100)
Elasticsearch requires access to some native functions. Historically
this has been achieved with the JNA library. However, JNA is a
complicated, magical library, and has caused various problems booting
Elasticsearch over the years. The new Java Foreign Function and Memory
API allows access to call native functions directly from Java. It also
has the advantage of tight integration with hotspot which can improve
performance of these functions (though performance of Elasticsearch's
native calls has never been much of an issue since they are mostly at
boot time).

This commit adds a new native lib that is internal to Elasticsearch. It
is built to use the foreign function api starting with Java 21, and
continue using JNA with Java versions below that.

Only one function, checking whether Elasticsearch is running as root, is
migrated. Future changes will migrate other native functions.
2024-02-07 18:27:09 -05:00
Ryan Ernst
2ca6df71d6
Make ProviderLocator aware of boot qualified exports (#105250)
Qualfied exports in the boot layer only work when they are to other boot
modules. Yet Elasticsearch has dynamically loaded modules as in plugins.
For this purpose we have ModuleQualifiedExportsService. This commit
moves loading of ModuleQualfiedExportService instances in the boot layer
into core so that it can be reused by ProviderLocator when a qualified
export applies to an embedded module.
2024-02-07 09:43:22 -08:00
Armin Braun
18bd6c4238
Fix Releasables.close performance issues (#104970)
It's less code and it actually inlines (avoiding virtual calls in most
cases) to just do the null check here instead of delegating to IOUtils
and then catching the impossible IOException. Also, no need to use
`Releaseables` in 2 spots where try-with-resources works as well and
needs less code.

Noticed this when I saw that we had a lot of strange CPU overhead in
this call in some hot loops like translog writes.
2024-01-31 08:21:59 -05:00
Ryan Ernst
d5e727e362
Add plugin for creating MRJARs (#104883)
This commit adds an elasticsearch gradle plugin which sets up a project
to build an MRJAR. By applying the plugin, the src dir is checked for
any directories matching mainXX where XX is the java version number.
A source set is automatically setup, an appropriate compiler tied to
that source set, and it's output placed in the correct part of the final
jar. Additionally, the sourceset allows use of preview features in that
verison of Java, and the preview bits are stripped from the resulting
class files.
2024-01-29 21:06:19 -08:00
Simon Cooper
0d53be3bed
Expand uses of matchers for Optionals (#104123)
Also add variants to assert for specific values
2024-01-09 12:55:29 +00:00
Armin Braun
78c365fc96
Introduce a noop, never-released ref counted constant (#103931)
This is needed for the search response pooling work. Also, the one usage
in `ReleasableBytesReference` actually makes outright sense. We
shouldn't be ref-counting on a global constant, that just needlessly
introduces contention that isn't entirely obvious. This change required
a couple tests to be adjusted where we were checking release mechanics
on noop instances.
2024-01-04 13:33:07 -05:00
David Turner
6c13a815bd
Refcount responses in TransportNodesAction (#103254)
Today we `decRef()` the per-node responses just after adding them to the
`responses` collection, but in fact we should keep them alive until
we've constructed the final response. This commit does that.
2024-01-02 13:38:02 +00:00
David Turner
b2127ec2f9
Introduce RefCounted#mustIncRef (#102515)
In several places we acquire a ref to a resource that we are certain is
not closed, so this commit adds a utility for asserting this to be the
case. This also helps a little with mocks since boolean methods like
`tryIncRef()` return `false` on mock objects by default, but void
methods like `mustIncRef()` default to being a no-op.
2023-11-23 16:40:43 -05:00
David Turner
5e20253fe8
Add @UpdateForV9 markers on versions (#102441)
We probably wouldn't forget these, but for the sake of completeness this
commit marks several lists of versions with the `@UpdateForV9`
annotation.
2023-11-22 08:09:34 +00:00