Commit graph

351 commits

Author SHA1 Message Date
Mark Vieira
0009de3575
Upgrade Bouncy Castle FIPS dependencies (#112989) (#119614)
This PR updates `bc-fips` and `bctls-fips` dependencies to the latest
minor versions.

(cherry picked from commit 6ea3e01958)

Co-authored-by: Slobodan Adamović <slobodanadamovic@users.noreply.github.com>
2025-01-07 08:03:17 +11:00
Simon Cooper
31d5967d35
Remove use of SPI locale for JDK 23+ (#113182)
On JDK 23 we're just going with what CLDR specifies for week-date calculations - the built-in locales are available for ISO weekdate uses.
2024-09-20 16:48:17 +01:00
Ryan Ernst
ec1785b3f7
Simplify java version checker (#112955) (#112960)
* Simplify java version checker (#112955)

The version checker ensures custom JDKs used to run Elasticsearch meet
the minimum Java version. It uses a multi-release jar to pass through
the "ok" versions, falling back to a java 8 version to print an error.
However, a multi-release jar is not necessary, we can instead do simple
string version parsing for the check, special casing Java 1.8.

* adjust for java 17
2024-09-19 06:29:43 +10:00
Joe Gallo
2cf435ac34
There's no need to BufferedInputStream within a GZIPInputStream (#113052) (#113068) 2024-09-19 01:00:42 +10:00
Mark Vieira
0279c0a909
Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00
Simon Cooper
a36d90cf34
Use CLDR locale provider on JDK 23+ (#110222)
JDK 23 removes the COMPAT locale provider, leaving CLDR as the only option. This commit configures Elasticsearch
to use the CLDR provider when on JDK 23, but still use the existing COMPAT provider when on JDK 22 and below.

This causes some differences in locale behaviour; this also adapts various tests to still work whether run on COMPAT or CLDR.
2024-09-04 13:42:40 +01:00
Ryan Ernst
84bd31eb8e
Fix shutdown race condition in server start (#112300)
When the server CLI is preparing to start Elasticsearch, it may receive
a SIGTERM. That signal causes the close method of the CLI to be invoked,
which checks for a non-null server process, and stops it if it exists.
Since shutdown occurs in a different thread, it is possible close is
invoked, sees the server process is null, so skips calling close, but
then before close finishes the server process is started.

Normally the above case is ok; the close method will cause Java to exit,
and the child process will be sent a SIGTERM. However, in the case of
serverless, close is wrapped so that the CLI can wait on uploading
possible heapdumps. This presents the possibility that close thinks the
child process has been stopped, but it hasn't, so the wrapped close
waits indefinitely on the child process that was started up during the
race.

This commit guards against the startup race by locking the critical
sections that create the child process and stop it. Either the child
process is created first, and will then be stopped immediately, or close
is invoked first, marking that the CLI is shutting down, and creating
the child process will be skipped.
2024-08-29 10:20:43 -07:00
Ryan Ernst
0aa4758f02
Stop setting java.library.path (#112119)
Native libraries in Java are loaded by calling System.loadLibrary. This
method inspects paths in the java.library.path to find the requested
library. Elasticsearch previously used this to find libsystemd, but now
the only remaining use is to set the additional platform directory in
which Elasticsearch keeps its own native libraries.

One issue with setting java.library.path is that its not set for the cli
process, which makes loading the native library infrastructure from clis
difficult. This commit reworks how Elasticsearch native libraries are
found in order to avoid needing to set java.library.path. There are two
cases. The simplest is production, where the working directory is the
Elasticsearch installation directory, so the platform specific directory
can be constructed. The second case is for tests where we don't have an
installtion. We already pass in java.library.path there, so this change
renames the system property to be a test specific property that the new
loading infrastructure looks for.
2024-08-23 11:16:18 -07:00
Ryan Ernst
8417d3f141
Move preallocate functionality to native access (#110678)
This commit moves the file preallocation functionality into
NativeAccess. The code is basically the same. One small tweak is that
instead of breaking Java access boundaries in order to get an open file
handle, the new code uses posix open directly.

relates #104876
2024-07-11 09:42:44 -07:00
Patrick Doyle
43b2e877e0
Revert "Move PluginsService to its own internal package (#109872)" (#109946)
This reverts commit b9e7965184.
2024-06-19 18:10:50 -04:00
Patrick Doyle
b9e7965184
Move PluginsService to its own internal package (#109872)
* Mechanical package change in IntelliJ
* A couple of manual fixups
* Export plugins.loading to deprecation
* Put plugin-cli in a module so can export PluginsUtils to it.
2024-06-19 15:23:47 -04:00
Chris Hegarty
6b62c5129d
Replace use of reflection with MemorySegmentAccessInput (#109061)
This commit replaces the use of reflection with the newly added MemorySegmentAccessInput.
2024-05-27 17:49:49 +01:00
elasticsearchmachine
7bd291d726 Merge remote-tracking branch 'origin/main' into lucene_snapshot 2024-05-21 10:01:52 +00:00
Ryan Ernst
9e6fe11d19
Update ASM to 9.7 for plugin scanner (#108822)
This commit updates the ASM library in order to support class files
written with Java 23.

closes #108776
2024-05-20 11:56:23 -04:00
elasticsearchmachine
0ce5dadc6b Merge remote-tracking branch 'origin/main' into lucene_snapshot 2024-05-15 10:02:23 +00:00
Ryan Ernst
db70623442
Fix G1 JDK bug workaround (#108641)
The workaround requires to JDK args, but SystemJvmOptions actually
operates on individual JDK args. This commit adjusts SystemJvmOptions to
allow adding sets of jdk args together.
2024-05-14 19:42:35 -04:00
Ryan Ernst
b2bc951ac5
Workaround G1 bug for JDK 22 and 22.0.1 (#108571)
See https://bugs.openjdk.org/browse/JDK-8329528. The applied workaround
was suggested on the linked issue, and was tested and confirmed to avoid
the G1 bug.
2024-05-14 06:17:14 -07:00
elasticsearchmachine
1d9cbbcded Merge remote-tracking branch 'origin/main' into lucene_snapshot 2024-05-08 10:01:34 +00:00
Moritz Mack
4c263e2ab4
CLI launcher / terminal improvements (#106470)
This removes getWriter() and getErrorWriter() from Terminal in order to prepare for using log4j in server-cli.
Additionally, ensure IO failures on the pump thread are handled once completed (closed) and
catch throwables in Command#main to print them (formatted) via Terminal.
2024-05-07 16:09:52 +02:00
elasticsearchmachine
6f46ee51c8 Merge remote-tracking branch 'origin/main' into lucene_snapshot 2024-05-03 10:01:31 +00:00
Jake Landis
6d20cef931
Bump Tika dependencies to 2.9.2 (#108144)
This commit bumps Tika to 2.9.2 and manually bumps the transitive versions 
to match 2.9.2's parent POM. This commit also centralizes the dependency 
versions so that you only need to look at 1 list to see the full set of dependencies 
to manually check.
2024-05-02 10:19:31 -05:00
elasticsearchmachine
e42f38c5c7 Merge remote-tracking branch 'origin/main' into lucene_snapshot 2024-05-02 10:01:20 +00:00
Ryan Ernst
a6e93c8fc6
Minor cleanups to auto heap (#107961)
Just a couple minor things: expose constants to subclass of auto heap
and removed unused test method
2024-05-01 18:54:52 -07:00
Chris Hegarty
1e233a993c
Enable native access for Lucene madvise 2024-04-29 11:35:32 +01:00
Ryan Ernst
d7e524fcf9
Make auto heap configuration configurable in server cli subclasses (#107919)
This commit makes auto heap configuration extendible so that serverless
can tweak the configuration based on project settings.
2024-04-26 08:08:24 -07:00
Ryan Ernst
7402f93839
Expose server process to server cli subclasses (#107729)
This commit gives protected access to subclasses of ServerCli (ie for
tests or serverless).
2024-04-23 17:17:34 -07:00
Chris Hegarty
6b52d7837b
Add an optimised int8 vector distance function for aarch64. (#106133)
This commit adds an optimised int8 vector distance implementation for aarch64. Additional platforms like, say, x64, will be added as a follow-up.

The vector distance implementation outperforms Lucene's Pamana Vector implementation for binary comparisons by approx 5x (depending on the number of dimensions). It does so by means of compiler intrinsics built into a separate native library and link by Panama's FFI. Comparisons are performed on off-heap mmap'ed vector data.

The implementation is currently only used during merging of scalar quantized segments, through a custom format ES814HnswScalarQuantizedVectorsFormat, but its usage will likely be expanded over time.

Co-authored-by: Benjamin Trent <ben.w.trent@gmail.com>
Co-authored-by: Lorenzo Dematté <lorenzo.dematte@elastic.co>
Co-authored-by: Mark Vieira <portugee@gmail.com>
Co-authored-by: Ryan Ernst <ryan@iernst.net>
2024-04-12 08:44:21 +01:00
Ryan Ernst
4114eea1a2
Allow force stopping server process (#107170)
This commit allows the cli access to sending SIGKILL to the underlying
jvm process.
2024-04-10 20:38:22 -04:00
Ryan Ernst
f5a7d25f06
Handle x86_64 os.arch for native libraries (#107289)
On some systems Java appears to return amd64 (even if not an amd
processor), but on others it returns x86_64. This commit handles the
latter case to correctly associate the arch with the appropriate
platform dir.
2024-04-10 14:51:52 -07:00
Nikolaj Volgushev
88306379ba
Increase KDF iteration count in KeyStoreWrapper (#107107)
This PR increases the KDF iteration count for the keystore password.

Additional context in ES-8063.
2024-04-08 05:28:12 -04:00
Ryan Ernst
e39fd58c5d
Fix jvm ergonomics tests (#106969)
closes #106554
2024-04-02 13:40:33 -07:00
David Turner
751742422a AwaitsFix for #106554 2024-03-20 14:22:38 +00:00
Henning Andersen
9315f8022d
Enhance search tier GC options (#106526)
For small nodes, we need a bit more wiggle room for new size
and concurrent GC threads in order to stay below real memory
circuit breaker limits on dedicated search nodes.

ES-8087
2024-03-20 13:20:54 +01:00
Ryan Ernst
405b88b882
Add zstd to native access (#105715)
This commit makes zstd compression available to Elasticsearch. The
library is pulled in through maven in jar files for each platform, then
bundled in a new platform directory under lib. Access to the zstd
compression/decompression is through NativeAccess.
2024-03-13 09:45:12 -07:00
Simon Cooper
b752169ee9
Use hamcrest regex matcher rather than our own (#104457)
The difference is that our matcher uses .find() to search for a regex match anywhere in the string, whereas the hamcrest one uses .matches() to check the whole string against the regex. This leads to more specific regex checks.

I've left our own one for YAML tests, as that way we don't need to mangle the regex to add .* either side, which might be confusing in test failures.
2024-02-22 16:15:36 +00: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
2a298a7acc
Add replay diagnostic dir to system jvm options (#103535)
When hotspot encounters an error, it will emite a log file which can be
used for reproducing the error. This file is dumped to /tmp by default.
This commit configures the replay file to be alongside the hs_err file.
2024-02-05 20:58:53 -08:00
Ryan Ernst
125c1c86af
Fix server cli to always pass through exit code (#104943)
In certain circumstances if Elasticsearch encounters an error while
starting up, the server cli may exit with no error. This commit fixes
the cli to always check and wait on the Elasticsearch process and exit
with the same exit code.

relates #104055
2024-01-31 12:28:09 -05:00
Moritz Mack
dbf59c5414
Update/Cleanup references to old tracing.apm.* legacy settings in favor of the telemetry.* settings (#104917) 2024-01-31 09:20:05 +01:00
Moritz Mack
35cc9e1159
New APM settings using telemetry. prefix deprecate ambiguous tracing.apm. settings. (#104376)
Telemetry / APM settings are renamed from "tracing.apm.{name}" to "telemetry.tracing.{name}" for tracing related settings. General APM settings are renamed to "telemetry.{name}". The old legacy settings are kept for now and applied as fallback.
2024-01-30 09:34:03 +01:00
Stuart Tettemer
3493e425ac
Metrics: Agent settings prefix telemetry.agent preferred over tracing.apm.agent (#104345)
Prefer the telemetry.agent prefix for APM agent settings.

Add a fallback prefix to Affix settings to migrating between an old prefix
and a new prefix.
2024-01-22 12:53:36 -06:00
Moritz Mack
00ca64bcf2
Use allow-list for APM agent settings and consolidate defaults in APMJvmOptions (#104141)
Prevent invalid and miss-configuration of APM agent using an explicit allow-list of setting keys.
Additionally, configuration defaults of APMAgentSettings are consolidated in APMJvmOptions to keep defaults in a single location.
(ES-6916)
2024-01-12 10:30:04 +01:00
Ryan Ernst
2f5247117e
Upgrade ASM to 9.6 for Java 22 support (#104085)
This commit upgrades the version of asm used by the build and plugins in
order to support Java 22 version format.

closes #104065 relates #103963
2024-01-08 15:03:40 -05:00
Armin Braun
49f1b5b787
Make sure to close XContentParser in more spots (#103504)
We're leaking quite a few of these parsers. That doesn't seem to be much
of a problem but results in some memory inefficiencies in Jackson here
and there. This PR bulk fixes a bunch of instances that I could easily
automatically fix. I'll open a follow-up for closing the parser on the
document parsing context which also suffers from this but is non-trivial
to fix.
2023-12-19 10:26:06 +01:00
Lorenzo Dematté
0e5f485058
ServerProcess refactoring (separate options construction from ServerProcess start) (#102973)
* Refactoring: move command line and environment build to a separate class
* Refactoring: adding a builder
* Moving tmp dir setup and JVM option parsing outside of builder
2023-12-14 07:37:50 +01:00
Lorenzo Dematté
c54ce68723
Switch InstallPluginActionTests to non-blocking SecureRandom seed generator (#102893)
* Force urandom on Linux
* Unmute test
2023-12-04 18:54:38 +01:00
Rene Groeschke
98b9bd547a
Mute tests (#102785) 2023-11-30 13:16:35 +01:00
Lorenzo Dematté
e86f0f78ab
Adding extension point in ServerCli to add processing after server process exited (#102475) 2023-11-28 09:47:05 +01:00
Armin Braun
1b84ea7421
Delete all unused private methods (#98111)
Pretty straight forward dead-code cleanup I think. Just delete all
private methods or methods in private classes that aren't used.
2023-11-25 22:21:59 +01:00
Jake Landis
17a46a6e9f
upgrade bouncy castle jars (#100923)
This commit upgrades the Bouncy Castle jars. Bouncy Castle is used for 
some internal build concners as well as a comnand line application. 
Most notably Bouncy Castle is also used as the FIPs certified JCE/JSEE provider 
we use to test our ability to use a FIPs compliant crypto provider. 

The following changes here are a result of the upgraded Bouncy Castle jars:
* TLSv1.3 is now supported when running in FIPs mode 
* RSA PKCS#1 v1.5 is no longer allowed in FIPS mode
* Triple DES (3DES) is no longer allowed in FIPS mode
* Minor updates the security manager configuration used to test FIPs (to read permissions from the security provider)
* Minor adjustments to tests to accommodate the above changes. 
* Minor adjustments to the gradle build to accommodate new dependencies 

Note - update to the documentation will come in a later commit.
2023-11-21 11:14:41 -06:00