Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions docs/changelog/111866.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 111866
summary: Fix windows memory locking
area: Infra/Core
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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 GetCompressedFileSizeW$mh = downcallHandleWithError(
"GetCompressedFileSizeW",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best (but complicated) way of doing this it to check the memory of the process, by calling VirtualQueryEx (and/or the equivalent function under linux/macos) from the test.
It does work cross process, so it should be possible to do that even in a test that spawns an external cluster. No idea how to do that with a docker test though...
Another idea: expose the information we need via an _nodes/stats (under os.mem maybe?). Could be useful regardless (e.g. for diagnostics)

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();
}
}