Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.15] Fix windows memory locking (#111866) #111935

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/111866.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 111866
summary: Fix windows memory locking
area: Infra/Core
type: bug
issues:
- 111847
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class JdkKernel32Library implements Kernel32Library {
);
private static final MethodHandle SetProcessWorkingSetSize$mh = downcallHandleWithError(
"SetProcessWorkingSetSize",
FunctionDescriptor.of(ADDRESS, JAVA_LONG, JAVA_LONG)
FunctionDescriptor.of(JAVA_BOOLEAN, ADDRESS, JAVA_LONG, JAVA_LONG)
);
private static final MethodHandle GetShortPathNameW$mh = downcallHandleWithError(
"GetShortPathNameW",
Expand Down Expand Up @@ -94,7 +94,7 @@ static class JdkAddress implements Address {

@Override
public Address add(long offset) {
return new JdkAddress(MemorySegment.ofAddress(address.address()));
return new JdkAddress(MemorySegment.ofAddress(address.address() + offset));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.packaging.test;

import org.elasticsearch.packaging.util.ServerUtils;
import org.elasticsearch.packaging.util.docker.DockerRun;

import java.util.Map;

import static org.elasticsearch.packaging.util.docker.Docker.runContainer;
import static org.elasticsearch.packaging.util.docker.DockerRun.builder;

public class MemoryLockingTests extends PackagingTestCase {

public void test10Install() throws Exception {
install();
}

public void test20MemoryLockingEnabled() throws Exception {
configureAndRun(
Map.of(
"bootstrap.memory_lock",
"true",
"xpack.security.enabled",
"false",
"xpack.security.http.ssl.enabled",
"false",
"xpack.security.enrollment.enabled",
"false",
"discovery.type",
"single-node"
)
);
// TODO: very locking worked. logs? check memory of process? at least we know the process started successfully
stopElasticsearch();
}

public void configureAndRun(Map<String, String> settings) throws Exception {
if (distribution().isDocker()) {
DockerRun builder = builder();
settings.forEach(builder::envVar);
runContainer(distribution(), builder);
} else {

for (var setting : settings.entrySet()) {
ServerUtils.addSettingToExistingConfiguration(installation.config, setting.getKey(), setting.getValue());
}
ServerUtils.removeSettingFromExistingConfiguration(installation.config, "cluster.initial_master_nodes");
}

startElasticsearch();
}
}