Skip to content

Commit 4ab4d7f

Browse files
author
Peter Alfonsi
committed
Merge remote-tracking branch 'upstream/main' into tiramisu-stats-api-final
Signed-off-by: Peter Alfonsi <[email protected]>
2 parents 40796c5 + f84d28d commit 4ab4d7f

File tree

71 files changed

+4072
-689
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4072
-689
lines changed

.github/workflows/assemble.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
java: [ 11, 17, 21 ]
11-
os: [ubuntu-latest, windows-latest, macos-latest]
11+
os: [ubuntu-latest, windows-latest, macos-13]
1212
steps:
1313
- uses: actions/checkout@v4
1414
- name: Set up JDK ${{ matrix.java }}
@@ -18,10 +18,7 @@ jobs:
1818
distribution: temurin
1919
- name: Setup docker (missing on MacOS)
2020
if: runner.os == 'macos'
21-
run: |
22-
brew install docker
23-
colima start
24-
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
21+
uses: douglascamata/setup-docker-macos-action@main
2522
- name: Run Gradle (assemble)
2623
run: |
2724
./gradlew assemble --parallel --no-build-cache -PDISABLE_BUILD_CACHE

.github/workflows/precommit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
java: [ 11, 17, 21 ]
11-
os: [ubuntu-latest, windows-latest, macos-latest]
11+
os: [ubuntu-latest, windows-latest, macos-13]
1212
steps:
1313
- uses: actions/checkout@v4
1414
- name: Set up JDK ${{ matrix.java }}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2525
- [Tiered Caching] Expose new cache stats API ([#13237](https://github.com/opensearch-project/OpenSearch/pull/13237))
2626
- [Streaming Indexing] Ensure support of the new transport by security plugin ([#13174](https://github.com/opensearch-project/OpenSearch/pull/13174))
2727
- Add cluster setting to dynamically configure the buckets for filter rewrite optimization. ([#13179](https://github.com/opensearch-project/OpenSearch/pull/13179))
28+
- [Tiered Caching] Gate new stats logic behind FeatureFlags.PLUGGABLE_CACHE ([#13238](https://github.com/opensearch-project/OpenSearch/pull/13238))
29+
- [Tiered Caching] Add a dynamic setting to disable/enable disk cache. ([#13373](https://github.com/opensearch-project/OpenSearch/pull/13373))
30+
- [Remote Store] Add capability of doing refresh as determined by the translog ([#12992](https://github.com/opensearch-project/OpenSearch/pull/12992))
31+
- [Tiered caching] Make Indices Request Cache Stale Key Mgmt Threshold setting dynamic ([#12941](https://github.com/opensearch-project/OpenSearch/pull/12941))
32+
- Batch mode for async fetching shard information in GatewayAllocator for unassigned shards ([#8746](https://github.com/opensearch-project/OpenSearch/pull/8746))
2833

2934
### Dependencies
3035
- Bump `org.apache.commons:commons-configuration2` from 2.10.0 to 2.10.1 ([#12896](https://github.com/opensearch-project/OpenSearch/pull/12896))
@@ -46,6 +51,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4651
- Bump `com.github.spullara.mustache.java:compiler` from 0.9.10 to 0.9.11 ([#13329](https://github.com/opensearch-project/OpenSearch/pull/13329))
4752
- Bump `jakarta.enterprise:jakarta.enterprise.cdi-api` from 4.0.1 to 4.1.0 ([#13328](https://github.com/opensearch-project/OpenSearch/pull/13328))
4853
- Bump `com.google.api.grpc:proto-google-iam-v1` from 0.12.0 to 1.33.0 ([#13332](https://github.com/opensearch-project/OpenSearch/pull/13332))
54+
- OpenJDK Update (April 2024 Patch releases), update to Eclipse Temurin 21.0.3+9 ([#13389](https://github.com/opensearch-project/OpenSearch/pull/13389))
55+
- Bump `com.squareup.okio:okio` from 3.8.0 to 3.9.0 ([#12997](https://github.com/opensearch-project/OpenSearch/pull/12997))
4956

5057
### Changed
5158
- [BWC and API enforcement] Enforcing the presence of API annotations at build time ([#12872](https://github.com/opensearch-project/OpenSearch/pull/12872))
@@ -54,6 +61,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5461
- Ignoring unavailable shards during search request execution with ignore_available parameter ([#13298](https://github.com/opensearch-project/OpenSearch/pull/13298))
5562
- Refactoring globMatch using simpleMatchWithNormalizedStrings from Regex ([#13104](https://github.com/opensearch-project/OpenSearch/pull/13104))
5663
- [BWC and API enforcement] Reconsider the breaking changes check policy to detect breaking changes against released versions ([#13292](https://github.com/opensearch-project/OpenSearch/pull/13292))
64+
- Switch to macos-13 runner for precommit and assemble github actions due to macos-latest is now arm64 ([#13412](https://github.com/opensearch-project/OpenSearch/pull/13412))
5765

5866
### Deprecated
5967

buildSrc/src/main/java/org/opensearch/gradle/test/DistroTestPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@
7777
import java.util.stream.Stream;
7878

7979
public class DistroTestPlugin implements Plugin<Project> {
80-
private static final String SYSTEM_JDK_VERSION = "21.0.2+13";
80+
private static final String SYSTEM_JDK_VERSION = "21.0.3+9";
8181
private static final String SYSTEM_JDK_VENDOR = "adoptium";
82-
private static final String GRADLE_JDK_VERSION = "21.0.2+13";
82+
private static final String GRADLE_JDK_VERSION = "21.0.3+9";
8383
private static final String GRADLE_JDK_VENDOR = "adoptium";
8484

8585
// all distributions used by distro tests. this is temporary until tests are per distribution

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ opensearch = 3.0.0
22
lucene = 9.11.0-snapshot-fb97840
33

44
bundled_jdk_vendor = adoptium
5-
bundled_jdk = 21.0.2+13
5+
bundled_jdk = 21.0.3+9
66

77
# optional dependencies
88
spatial4j = 0.7

modules/cache-common/src/internalClusterTest/java/org.opensearch.cache.common.tier/TieredSpilloverCacheIT.java

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,121 @@ public void testWithExplicitCacheClear() throws Exception {
425425
}, 1, TimeUnit.SECONDS);
426426
}
427427

428+
public void testWithDynamicDiskCacheSetting() throws Exception {
429+
int onHeapCacheSizeInBytes = 10; // Keep it low so that all items are cached onto disk.
430+
internalCluster().startNode(
431+
Settings.builder()
432+
.put(defaultSettings(onHeapCacheSizeInBytes + "b"))
433+
.put(INDICES_CACHE_CLEAN_INTERVAL_SETTING.getKey(), new TimeValue(1))
434+
.build()
435+
);
436+
Client client = client();
437+
assertAcked(
438+
client.admin()
439+
.indices()
440+
.prepareCreate("index")
441+
.setMapping("k", "type=keyword")
442+
.setSettings(
443+
Settings.builder()
444+
.put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
445+
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
446+
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
447+
.put("index.refresh_interval", -1)
448+
)
449+
.get()
450+
);
451+
// Update took time policy to zero so that all entries are eligible to be cached on disk.
452+
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest().transientSettings(
453+
Settings.builder()
454+
.put(
455+
TieredSpilloverCacheSettings.TOOK_TIME_POLICY_CONCRETE_SETTINGS_MAP.get(CacheType.INDICES_REQUEST_CACHE).getKey(),
456+
new TimeValue(0, TimeUnit.MILLISECONDS)
457+
)
458+
.build()
459+
);
460+
assertAcked(internalCluster().client().admin().cluster().updateSettings(updateSettingsRequest).get());
461+
int numberOfIndexedItems = randomIntBetween(5, 10);
462+
for (int iterator = 0; iterator < numberOfIndexedItems; iterator++) {
463+
indexRandom(true, client.prepareIndex("index").setSource("k" + iterator, "hello" + iterator));
464+
}
465+
ensureSearchable("index");
466+
refreshAndWaitForReplication();
467+
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
468+
ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get();
469+
OpenSearchAssertions.assertAllSuccessful(forceMergeResponse);
470+
long perQuerySizeInCacheInBytes = -1;
471+
// Step 1: Hit some queries. We will see misses and queries will be cached(onto disk cache) for subsequent
472+
// requests.
473+
for (int iterator = 0; iterator < numberOfIndexedItems; iterator++) {
474+
SearchResponse resp = client.prepareSearch("index")
475+
.setRequestCache(true)
476+
.setQuery(QueryBuilders.termQuery("k" + iterator, "hello" + iterator))
477+
.get();
478+
if (perQuerySizeInCacheInBytes == -1) {
479+
RequestCacheStats requestCacheStats = getRequestCacheStats(client, "index");
480+
perQuerySizeInCacheInBytes = requestCacheStats.getMemorySizeInBytes();
481+
}
482+
assertSearchResponse(resp);
483+
}
484+
485+
RequestCacheStats requestCacheStats = getRequestCacheStats(client, "index");
486+
assertEquals(numberOfIndexedItems * perQuerySizeInCacheInBytes, requestCacheStats.getMemorySizeInBytes());
487+
assertEquals(numberOfIndexedItems, requestCacheStats.getMissCount());
488+
assertEquals(0, requestCacheStats.getHitCount());
489+
assertEquals(0, requestCacheStats.getEvictions());
490+
491+
// Step 2: Hit same queries again. We will see hits now.
492+
for (int iterator = 0; iterator < numberOfIndexedItems; iterator++) {
493+
SearchResponse resp = client.prepareSearch("index")
494+
.setRequestCache(true)
495+
.setQuery(QueryBuilders.termQuery("k" + iterator, "hello" + iterator))
496+
.get();
497+
assertSearchResponse(resp);
498+
}
499+
requestCacheStats = getRequestCacheStats(client, "index");
500+
assertEquals(numberOfIndexedItems * perQuerySizeInCacheInBytes, requestCacheStats.getMemorySizeInBytes());
501+
assertEquals(numberOfIndexedItems, requestCacheStats.getMissCount());
502+
assertEquals(numberOfIndexedItems, requestCacheStats.getHitCount());
503+
assertEquals(0, requestCacheStats.getEvictions());
504+
long lastKnownHitCount = requestCacheStats.getHitCount();
505+
long lastKnownMissCount = requestCacheStats.getMissCount();
506+
507+
// Step 3: Turn off disk cache now. And hit same queries again. We should not see hits now as all queries
508+
// were cached onto disk cache.
509+
updateSettingsRequest = new ClusterUpdateSettingsRequest().transientSettings(
510+
Settings.builder()
511+
.put(TieredSpilloverCacheSettings.DISK_CACHE_ENABLED_SETTING_MAP.get(CacheType.INDICES_REQUEST_CACHE).getKey(), false)
512+
.build()
513+
);
514+
assertAcked(internalCluster().client().admin().cluster().updateSettings(updateSettingsRequest).get());
515+
516+
for (int iterator = 0; iterator < numberOfIndexedItems; iterator++) {
517+
SearchResponse resp = client.prepareSearch("index")
518+
.setRequestCache(true)
519+
.setQuery(QueryBuilders.termQuery("k" + iterator, "hello" + iterator))
520+
.get();
521+
assertSearchResponse(resp);
522+
}
523+
requestCacheStats = getRequestCacheStats(client, "index");
524+
assertEquals(numberOfIndexedItems * perQuerySizeInCacheInBytes, requestCacheStats.getMemorySizeInBytes()); //
525+
// Still shows disk cache entries as explicit clear or invalidation is required to clean up disk cache.
526+
assertEquals(lastKnownMissCount + numberOfIndexedItems, requestCacheStats.getMissCount());
527+
assertEquals(0, lastKnownHitCount - requestCacheStats.getHitCount()); // No new hits being seen.
528+
lastKnownMissCount = requestCacheStats.getMissCount();
529+
lastKnownHitCount = requestCacheStats.getHitCount();
530+
531+
// Step 4: Invalidate entries via refresh.
532+
// Explicit refresh would invalidate cache entries.
533+
refreshAndWaitForReplication();
534+
assertBusy(() -> {
535+
// Explicit refresh should clear up cache entries
536+
assertTrue(getRequestCacheStats(client, "index").getMemorySizeInBytes() == 0);
537+
}, 1, TimeUnit.SECONDS);
538+
requestCacheStats = getRequestCacheStats(client, "index");
539+
assertEquals(0, lastKnownMissCount - requestCacheStats.getMissCount());
540+
assertEquals(0, lastKnownHitCount - requestCacheStats.getHitCount());
541+
}
542+
428543
private RequestCacheStats getRequestCacheStats(Client client, String indexName) {
429544
return client.admin().indices().prepareStats(indexName).setRequestCache(true).get().getTotal().getRequestCache();
430545
}

0 commit comments

Comments
 (0)