Commit graph

146 commits

Author SHA1 Message Date
Andrei Dan
2375e89a5f
Make writerWithOffset fully delegate to the writer it wraps (#126937)
writerWithOffset uses a lambda to create a RangeMissingHandler however,
the RangeMissingHandler interface has a default implementation for `sharedInputStreamFactory`.

This makes `writerWithOffset` delegate to the received writer only for the `fillCacheRange`
method where the writer itself perhaps didn't have the `sharedInputStream` method invoked
(always invoking `sharedInputStream` before `fillCacheRange` is part of the contract of the
RangeMissingHandler interface)

This PR makes `writerWithOffset` delegate the `sharedInputStream` to the underlying writer.
2025-05-29 15:58:16 +01:00
Nick Tindall
83fe2eda5c
Optimise shared-blob-cache evictions (#126581)
Closes: ES-10744

Co-authored-by: Tanguy Leroux <tlrx.dev@gmail.com>
2025-05-27 10:01:27 +10:00
Christoph Büscher
4c0c9b65b6
Avoid some uses of ConcurrentLinkedQueue.size() in SharedBlobCacheService (#128119)
SharedBlobCacheService keeps track of the free regions in a
ConcurrentLinkedQueue. We use its "size()" method in three places
outside of tests but unfortunately this is not a constant time operation
because of the asynchronous nature of this queue. This change removes
two of the uses where we only check if the queue is empty by calling the
"isEmpty()" method instead.
2025-05-20 11:35:06 +02:00
Andrei Dan
2f2b9099d8
Add OnlinePrewarming option for cache population reason (#126716) 2025-04-15 02:52:08 +10:00
Andrei Dan
d553455092
Add metrics around the file extensions we request when populating the cache (#123134)
This adds the file extentions for the blobs we request when populating the
cache.
The possible values for lucene extensions are around 50 and we use a special
"other" category for everything else, as a fallback.
2025-03-12 14:12:56 +00:00
Lorenzo Dematté
20b829fc14
[Entitlements] Add check functions for NIO Files (#122591) 2025-02-19 21:55:06 +01:00
Moritz Mack
8eb89cf7c1
Add entitlement checks for java.io stream classes (#122406) 2025-02-18 14:12:01 +01:00
Patrick Doyle
34059c9dbd
Limit ByteSizeUnit to 2 decimals (#120142)
* Exhaustive testParseFractionalNumber

* Refactor: encapsulate ByteSizeUnit constructor

* Refactor: store size in bytes

* Support up to 2 decimals in parsed ByteSizeValue

* Fix test for rounding up with no warnings

* ByteSizeUnit transport changes

* Update docs/changelog/120142.yaml

* Changelog details and impact

* Fix change log breaking.area

* Address PR comments
2025-01-16 19:30:23 +00:00
Rene Groeschke
ba61f8c7f7
Update Gradle wrapper to 8.12 (#118683)
This updates the gradle wrapper to 8.12

We addressed deprecation warnings due to the update that includes:

- Fix change in TestOutputEvent api
- Fix deprecation in groovy syntax
- Use latest ospackage plugin containing our fix
- Remove project usages at execution time
- Fix deprecated project references in repository-old-versions
2024-12-30 15:34:24 +01:00
Armin Braun
e94f145350
Fix a bunch of non-final static fields (#119185)
Fixing almost all missing `final` spots, who knows maybe we get a small speedup from
some constant folding here and there.
2024-12-26 19:14:36 +01:00
Nick Tindall
43d36edbd9
Remove high-cardinality metric attributes (#116700)
Relates: ES-10027
2024-11-14 14:00:20 +11:00
Craig Taverner
c9c1765986
Remove duplicate 'the the' (#116023)
There were many places where `the the` was typed, in comments, docs and messages. All were incorrect and replaces with a single `the`
2024-10-31 19:14:58 +01: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
Chris Hegarty
d1c7e9886f
Update BlobCacheBufferedIndexInput::readVLong to correctly handle negative long values (#115594) 2024-10-24 21:43:22 +01:00
Luca Cavanna
8efd08b019
Upgrade to Lucene 10 (#114741)
The most relevant ES changes that upgrading to Lucene 10 requires are:

- use the appropriate IOContext
- Scorer / ScorerSupplier breaking changes
- Regex automaton are no longer determinized by default
- minimize moved to test classes
- introduce Elasticsearch900Codec
- adjust slicing code according to the added support for intra-segment concurrency
- disable intra-segment concurrency in tests
- adjust accessor methods for many Lucene classes that became a record
- adapt to breaking changes in the analysis area

Co-authored-by: Christoph Büscher <christophbuescher@posteo.de>
Co-authored-by: Mayya Sharipova <mayya.sharipova@elastic.co>
Co-authored-by: ChrisHegarty <chegar999@gmail.com>
Co-authored-by: Brian Seeders <brian.seeders@elastic.co>
Co-authored-by: Armin Braun <me@obrown.io>
Co-authored-by: Panagiotis Bailis <pmpailis@gmail.com>
Co-authored-by: Benjamin Trent <4357155+benwtrent@users.noreply.github.com>
2024-10-21 13:38:23 +02:00
Armin Braun
e5bcb0c5b3
Remove duplication in settings code and some minor setting speedups (#112897)
Some small speedups in here from pre-evaluating `isFiltered(properties)`
in lots of spots and not creating an unused `SimpleKey` in `toConcreteKey`
which runs a costly string interning at some rate.
Other than that, obvious deduplication using existing utilities or
adding obvious missing overloads for them.
2024-09-18 15:01:49 +02:00
Mark Vieira
a59c182f9f
Add AGPLv3 as a supported license 2024-09-13 15:29:46 -07:00
Yang Wang
212fe035ea
[Test] Fix SharedBlobCacheServiceTests.testGetMultiThreaded (#112322)
A cacheFileRegion can be concurrently evicted while its being incref'd.

See this comment
98fe686da4/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java (L1812-L1813)

The tryRead method also performs null and eviction check for io before
returing true.
98fe686da4/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java (L926-L931)

Resolves: #112314
2024-08-30 16:01:21 +02:00
Volodymyr Krasnikov
5fb3c1dfbe
Write multiple cache gaps for warming service in one go (#112071)
* Write multiple cache gaps for warming service in one go
2024-08-29 14:20:34 -07:00
Lee Hinman
9bf5f61fbb
Mute SharedBlobCacheServiceTests.testGetMultiThreaded (#112315)
Relates to https://github.com/elastic/elasticsearch/issues/112305
2024-08-29 06:48:25 +10:00
Henning Andersen
3dc21f99b6
Avoid cache io field volatile accesses (#112184)
The blob cache has an io field per region that is declared volatile, since it is originally null
and then later initialized. However, during "tryRead" we do not need the volatile access.
This commit changes the field to be non-volatile and use proper volatile accesses only
when needed.
2024-08-28 17:20:54 +02:00
Chris Hegarty
00f2b9a779
Fix JDK 21 lint warnings (#112249)
This commit fixes lint warnings that arise when compiling with javac from JDK 21.

This change is in preparation for an eventual bump of Elasticsearch to a minimum of JDK 21, in ES 9.0.
2024-08-28 08:00:42 +01:00
Artem Prigoda
f318f22346
Give executor to cache instead of string (#111711) (#112091)
Relates ES-8155

Co-authored-by: Iraklis Psaroudakis <kingherc@gmail.com>
2024-08-26 08:39:22 +02:00
Volodymyr Krasnikov
a9fa443402
Avoid unsafe futures in SharedBlobCacheService (#111526) 2024-08-20 10:59:35 -07:00
Artem Prigoda
8b0a1aa7eb
[cache] Support async RangeMissingHandler callbacks (#111340) (#111896)
Change `fillCacheRange` method to accept a completion listener that must be called by `RangeMissingHandler` implementations when they finish fetching data. By doing so, we support asynchronously fetching the data from a third party storage. We also support asynchronous `SourceInputStreamFactory` for reading gaps from the storage.
2024-08-19 16:14:09 +02:00
Nick Tindall
5934190539
Add additional BlobCacheMetrics, expose BlobCacheMetrics via SharedBlobCacheService (#111730)
Relates: ES-9067
2024-08-15 17:02:43 +10:00
Artem Prigoda
82520a166b
Revert "[cache] Support async RangeMissingHandler callbacks (#111340)" (#111839)
* Revert "[cache] Support async RangeMissingHandler callbacks (#111340)"

This reverts commit 364bba2e6b.

* Revert "Give executor to cache instead of string (#111711)"

This reverts commit 4f70047ee4.
2024-08-13 17:53:30 +02:00
Iraklis Psaroudakis
4f70047ee4
Give executor to cache instead of string (#111711)
Relates ES-8155
2024-08-13 09:06:48 +03:00
Artem Prigoda
364bba2e6b
[cache] Support async RangeMissingHandler callbacks (#111340)
Change `fillCacheRange` method to accept a completion listener that must be called by `RangeMissingHandler` implementations when they finish fetching data. By doing so, we support asynchronously fetching the data from a third party storage. We also support asynchronous `SourceInputStreamFactory` for reading gaps from the storage.
2024-08-12 10:09:14 +02:00
Yang Wang
d4f330fd10
Use milliseconds for time histogram metrics (#111502)
LongHistogram's default base2 exponentional aggregagtion is optimized
for latency range of 1ms to 100s. Hence we should record time metrics in
milliseconds instead of micros.

Relates: ES-9065
2024-08-02 18:56:15 +10:00
Artem Prigoda
8886c5c8d7
Revert "[cache] Support async RangeMissingHandler callbacks (#110587)" (#111327)
Reverts elastic/elasticsearch#110587
2024-07-26 19:54:59 +10:00
Artem Prigoda
cb7a21e8ff
[cache] Support async RangeMissingHandler callbacks (#110587)
Change `fillCacheRange` method to accept a completion listener that must be called by `RangeMissingHandler` implementations when they finish fetching data. By doing so, we support asynchronously fetching the data from a third party storage. We also support asynchronous `SourceInputStreamFactory` for reading gaps from the storage.

Depends on #111177
2024-07-25 20:26:57 +02:00
Yang Wang
ff2c4dea63
Add support for shared input stream to RangeMissingHandler (#110855)
This PR augments the RangeMissingHandler interface to support shared
input stream which is reused when filling mulitple gaps. The shared
input stream is meant to be consumed sequentially to fill the list of
gaps in sequential order. The existing behaviour is preserved when
shared input stream is not used, i.e. when it is `null`.
2024-07-18 15:21:16 +10:00
David Turner
5766491ad4
Remove PlainActionFuture#get utility (#110955)
This utility is almost entirely used in tests where an infinite wait is
inappropriate, and the exception-mangling behaviour is unhelpful, so
this commit replaces it with safer alternatives. There should be no need
for an easy way to block production threads forever.
2024-07-17 16:38:54 +10: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
Artem Prigoda
8d0a1ac71d Revert "Trying to make SharedBlobCacheService async?"
This reverts commit 1c859c9f7a.
2024-07-08 10:04:31 +02:00
Artem Prigoda
1c859c9f7a Trying to make SharedBlobCacheService async? 2024-07-08 09:55:34 +02:00
Nick Tindall
7a8a7c0628
Improve mechanism for extracting the result of a PlainActionFuture (#110019)
Closes #108125
2024-07-04 12:26:56 +10:00
Tanguy Leroux
a7cd581201
Update sparse file tracker complete pointer on progress (#109247)
This change updates the complete pointer when a Gap makes progress.
2024-06-12 08:58:37 +02:00
Armin Braun
25b77ea366
Use System::nanoTime as default time source in SharedBlobCacheService (#109420)
We need to use `System#nanoTime` here. We use this time source for
measuring the timing of blob IO. The 200ms default accuracy isn't enough
here, we need accurate timing.
2024-06-06 18:33:45 +02:00
Tanguy Leroux
42f1e1d4d3
[Test] Fix SparseFileTrackerTests.testCallsListenerWhenRangeIsAvailable failing (#109239)
Test required some adjustments now listeners are
not completed on progress update if they are waiting
up to the end of the gap.

Relates #108095
Closes #109237
2024-05-31 13:06:53 +02:00
Tanguy Leroux
3a5e94011e
Do not request gaps to fill when the sub range is already completed (#109212)
When the range to read (subRange) is already completed, we can 
optimize by returning early without asking for the range to write 
(range) to be fully filled and save one or more fetch requests.
2024-05-31 10:44:43 +02:00
Tanguy Leroux
d367c11793
Do not execute listeners when progress is updated to the end of the range (#108095)
ProgressListenableActionFuture executes listeners once the 
progress is updated to a value the listener is waiting for.

But when a listener waits for the exact end of a range/gap, 
there is no need to execute it at the time the progress is 
updated to the end of the range. Instead we can leave the 
listener and it will be executed when the range/gap is 
completed (which should happen just after).

I'd like to propose this change because we can have read 
listeners that use CacheFile#tryRead which relies on 
SparseFileTracker#checkAvailable and the volatile 
SparseFileTracker#complete field, which is only updated 
when the range is completed, just before executing listeners.

If listeners are executed when the progress is updated to 
the end of the range, they may call tryRead before the 
SparseFileTracker#complete field is updated, making the 
fast read path fails.
2024-05-30 17:00:15 +02:00
Tanguy Leroux
0ae817e5b6
Complete sparse file tracker gaps before releasing refs on CacheFileRegion (#107359)
This change ensure that CacheFileRegion has references at the time 
the Gap is completed. It also ensure that a reference on CacheFileRegion 
is held until all writes/gaps are completed (ie not acquiring a ref before 
writing each gap anymore).

Finally, it ensure that the Gap is correctly failed if the write task is rejected.
2024-05-30 10:49:26 +02:00
Tim Brooks
b84ad26c9b
Use the unsafe future for read single region (#109139)
We need to use the unsafe future to block on the same thread pool
similar to read multi regions.
2024-05-29 10:56:43 +02:00
Henning Andersen
a4bd25687c
Assert not same executor when completing future (#108934)
A common deadlock pattern is waiting and completing a future on the same executor.
This only works until the executor is fully depleted of threads. Now assert that
waiting for a future to be completed and the completion happens on different
executors.

Introduced UnsafePlainActionFuture, used in all offending places, allowing those
to be tackled independently.
2024-05-28 10:12:51 +02:00
Volodymyr Krasnikov
54090f88b8
Add nano time supplier to SharedBlobCacheService (#108592) 2024-05-14 09:27:18 -07:00
Tim Brooks
fd3aa536a4
Add method to copy to file channel from buffer (#108228)
Currently in ShardBytes we only support copying from an inputstream
using an intermediate buffer. This commit adds a method to copy from the
buffer directly without reading from the input stream.
2024-05-03 11:28:16 -06:00
Armin Braun
c5834dee20
Add fastpath for cloning fully-buffered BlobCacheBufferedIndexInput (#107844)
Like with slicing we can optimize cloning the same way. This has lots of potential for saving memory
when dealing with offheap fst stores and the like where there's a bunch of small slices getting cloned.
2024-05-01 09:16:50 +02:00
Tanguy Leroux
5d474e183d
Add SharedBlobCacheService.maybeFetchRange method (#108032)
This commit adds a maybeFetchRange() method that can be used 
to fetch a given range in a specific blob region if at least a free 
page is available. The range can be larger than the blob region 
and is remapped (mapSubRangeToRegion();) before hitting the 
cache. It is basically a variant of maybeFetchRegion that allow 
passing a range instead of the whole region.
2024-04-30 17:19:38 +02:00