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

Set locale to en_US prior to server startup #21294

Merged
merged 3 commits into from
Mar 27, 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
4 changes: 0 additions & 4 deletions core/docker/default/etc/jvm.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@
-XX:GCLockerRetryAllocationCount=32
# Allow loading dynamic agent used by JOL
-XX:+EnableDynamicAgentLoading
# Trino server behavior does generally not depend on locale settings.
# Use en_US as this is what Trino is tested with.
-Duser.language=en
-Duser.region=US
5 changes: 5 additions & 0 deletions core/trino-main/src/main/java/io/trino/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import java.nio.file.Paths;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.Set;

Expand All @@ -95,6 +96,10 @@ public final void start(String trinoVersion)

private void doStart(String trinoVersion)
{
// Trino server behavior does not depend on locale settings.
// Use en_US as this is what Trino is tested with.
Locale.setDefault(Locale.US);

long startTime = System.nanoTime();
verifyJvmRequirements();
verifySystemTimeIsReasonable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ final class TrinoSystemRequirements
{
private static final int MIN_FILE_DESCRIPTORS = 4096;
private static final int RECOMMENDED_FILE_DESCRIPTORS = 8192;
private static final Locale EN_US = Locale.of("en", "US");

private TrinoSystemRequirements() {}

Expand All @@ -53,7 +52,6 @@ public static void verifyJvmRequirements()
verifyFileDescriptor();
verifySlice();
verifyUtf8();
verifyLocale();
}

private static void verify64BitJvm()
Expand Down Expand Up @@ -164,14 +162,6 @@ private static void verifyUtf8()
}
}

private static void verifyLocale()
{
Locale defaultLocale = Locale.getDefault();
if (!defaultLocale.equals(EN_US)) {
failRequirement("Trino requires that the default locale is ENGLISH (found %s). This can be set with the JVM command line option -Duser.language=en -Duser.region=US", defaultLocale);
}
}

/**
* Perform a sanity check to make sure that the year is reasonably current, to guard against
* issues in third party libraries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
import java.time.Instant;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
Expand All @@ -152,6 +153,10 @@ public class TestingTrinoServer
Logging logging = Logging.initialize();
logging.setLevel("io.trino.event.QueryMonitor", Level.ERROR);
logging.setLevel("org.eclipse.jetty", Level.ERROR);

// Trino server behavior does not depend on locale settings.
// Use en_US as this is what Trino is tested with.
Locale.setDefault(Locale.US);
}

public static final String SESSION_START_TIME_PROPERTY = "session_start_time";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@
-XX:GCLockerRetryAllocationCount=32
# Allow loading dynamic agent used by JOL
-XX:+EnableDynamicAgentLoading
# Trino server behavior does generally not depend on locale settings.
# Use en_US as this is what Trino is tested with.
-Duser.language=en
-Duser.region=US
4 changes: 0 additions & 4 deletions docs/src/main/sphinx/installation/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ The following provides a good starting point for creating `etc/jvm.config`:
-XX:GCLockerRetryAllocationCount=32
# Allow loading dynamic agent used by JOL
-XX:+EnableDynamicAgentLoading
# Trino server behavior does generally not depend on locale settings.
# Use en_US as this is what Trino is tested with.
-Duser.language=en
-Duser.region=US
```

You must adjust the value for the memory used by Trino, specified with `-Xmx`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@
-XX:ErrorFile=/docker/logs/product-tests-presto-jvm-error-file.log
# Allow loading dynamic agent used by JOL
-XX:+EnableDynamicAgentLoading
# Trino server behavior does generally not depend on locale settings.
# Use en_US as this is what Trino is tested with.
-Duser.language=en
-Duser.region=US
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@
-XX:ErrorFile=/docker/logs/product-tests-presto-jvm-error-file.log
# Allow loading dynamic agent used by JOL
-XX:+EnableDynamicAgentLoading
# Trino server behavior does generally not depend on locale settings.
# Use en_US as this is what Trino is tested with.
-Duser.language=en
-Duser.region=US
Loading