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

Prompt is not shown for a long time when I use "eclipse-temurin:8-jdk-noble" container #491

Open
kota2and3kan opened this issue Nov 16, 2024 · 0 comments · May be fixed by #492
Open

Prompt is not shown for a long time when I use "eclipse-temurin:8-jdk-noble" container #491

kota2and3kan opened this issue Nov 16, 2024 · 0 comments · May be fixed by #492

Comments

@kota2and3kan
Copy link

Hello Team,

I faced a performance issue that the prompt was not shown for a long time when I ran SQLLine in eclipse-temurin:8-jdk-noble container.

It seems that the root cause of this issue exists on the JLine side. So, I want to update the version of JLine that SQLLine uses.

I will submit a new PR. However, I'm not familiar with the rules of this repository. So, could you please correct me if I wrong something?

The issue details are the following:

Overview

When I run SQLLine in the eclipse-temurin:8-jdk-noble container, the prompt does not appear for a long time.

# java -jar ./target/sqlline-1.13.0-SNAPSHOT-jar-with-dependencies.jar

(The prompt "sqlline>" does not appear for a long time...)

How to reproduce the issue

Note

To avoid the same issue in the build process, you must set LS_COLORS="" when you run the ./mvnw package command.

  1. Start eclipse-temurin:8-jdk-noble container.

    docker run -d --name sqlline-test --entrypoint sleep eclipse-temurin:8-jdk-noble inf
  2. Run bash in the container.

    docker exec -it sqlline-test bash
  3. Install the git command.

    apt update && apt install -y git
  4. Build SQLLine based on the current main branch.

    git clone https://github.com/julianhyde/sqlline.git
    cd sqlline
    LS_COLORS="" ./mvnw package
  5. Run SQLLine in the container.

    java -jar ./target/sqlline-1.13.0-SNAPSHOT-jar-with-dependencies.jar

    The prompt does not appear for a long time...

Issue details

I checked what is happening in the internal of SQLLine by using the jdb command when the issue occurs. As a result, it seems that java.util.regex.Pattern runs many times and it takes a long time.

  • Stack of SQLLine when the issue occurs.

    main[1] where
      [1] java.util.regex.Pattern$Curly.match (Pattern.java:4,241)
      [2] java.util.regex.Pattern$Branch.match (Pattern.java:4,618)
      [3] java.util.regex.Pattern$GroupHead.match (Pattern.java:4,672)
      [4] java.util.regex.Pattern$BmpCharProperty.match (Pattern.java:3,812)
      [5] java.util.regex.Pattern$GroupHead.match (Pattern.java:4,672)
    
      (omit)
    
      [2,995] java.util.regex.Pattern$Curly.match0 (Pattern.java:4,261)
      [2,996] java.util.regex.Pattern$Curly.match (Pattern.java:4,248)
      [2,997] java.util.regex.Pattern$Branch.match (Pattern.java:4,618)
      [2,998] java.util.regex.Pattern$GroupHead.match (Pattern.java:4,672)
      [2,999] java.util.regex.Matcher.match (Matcher.java:1,270)
      [3,000] java.util.regex.Matcher.matches (Matcher.java:604)
      [3,001] java.util.regex.Pattern.matches (Pattern.java:1,135)
      [3,002] java.lang.String.matches (String.java:2,121)
      [3,003] org.jline.builtins.Styles.consoleOption (Styles.java:74)
      [3,004] org.jline.builtins.Styles.style (Styles.java:51)
      [3,005] org.jline.builtins.Styles.lsStyle (Styles.java:35)
      [3,006] org.jline.builtins.Completers$FileNameCompleter.<clinit> (Completers.java:333)
      [3,007] sqlline.Application.getCommandHandlers (Application.java:254)
      [3,008] sqlline.SqlLine$Config.<init> (SqlLine.java:2,044)
      [3,009] sqlline.SqlLine.setAppConfig (SqlLine.java:1,973)
      [3,010] sqlline.SqlLine.<init> (SqlLine.java:231)
      [3,011] sqlline.SqlLine.start (SqlLine.java:268)
      [3,012] sqlline.SqlLine.main (SqlLine.java:208)

And, the java.util.regex.Pattern is called by JLine. So, I investigated this issue on the JLine side. As a result, I found the following PR. This issue has already been reported and fixed on the JLine side.

Also, the above fix is released in JLine 3.23.0. However, the latest SQLLine (1.2.0 and 1.13.0-SNAPSHOT) uses JLine 3.21.0. So, I think we can fix this issue by using the latest JLine in SQLLine.

Temporary workaround

According to the PR of JLine, the issue occurs when JLine runs java.lang.String.matches against the value of LS_COLORS.

So, I tried to set an empty string to LS_COLORS as follows:

LS_COLORS="" java -jar ./target/sqlline-1.13.0-SNAPSHOT-jar-with-dependencies.jar

As a result, I was able to see the prompt soon as follows:

LS_COLORS="" java -jar ./target/sqlline-1.13.0-SNAPSHOT-jar-with-dependencies.jar
sqlline version 1.13.0-SNAPSHOT
sqlline>

I think we can use this way as a temporary workaround.

My proposal

I updated the version of JLine to apply the fix of JLine as follows:

  • Update the version of JLine.

    diff --git a/pom.xml b/pom.xml
    index 3f09322..740fe66 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -31,7 +31,7 @@
         <h2.version>2.1.210</h2.version>
         <hamcrest.version>2.2</hamcrest.version>
         <hsqldb.version>2.5.0</hsqldb.version>
    -    <jline.version>3.21.0</jline.version>
    +    <jline.version>3.26.3</jline.version>
         <jmockit.version>1.49</jmockit.version>
         <junit.version>5.8.1</junit.version>
         <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
  • Run SQLLine with JLine 3.26.3.

    root@87bebc5e1fbe:/sqlline# java -jar ./target/sqlline-1.13.0-SNAPSHOT-jar-with-dependencies.jar
    Nov 16, 2024 6:55:03 AM org.jline.utils.Log logr
    WARNING: The terminal provider jansi has been deprecated, check your configuration. This warning can be disabled by setting the system property org.jline.terminal.disableDeprecatedProviderWarning to true.
    sqlline version 1.13.0-SNAPSHOT
    sqlline>

As shown above, I was able to run the SQLLine, and the prompt appeared soon. However, there was a WARNING message. It seems that the JANSI is now deprecated on the JLine side. So, according to the document of JLine, I added JNI as follows:

  • Update the version of JLine and add JNI in addition to JANSI.

    diff --git a/pom.xml b/pom.xml
    index 3f09322..f78bbf1 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -31,7 +31,7 @@
         <h2.version>2.1.210</h2.version>
         <hamcrest.version>2.2</hamcrest.version>
         <hsqldb.version>2.5.0</hsqldb.version>
    -    <jline.version>3.21.0</jline.version>
    +    <jline.version>3.26.3</jline.version>
         <jmockit.version>1.49</jmockit.version>
         <junit.version>5.8.1</junit.version>
         <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
    @@ -357,6 +357,11 @@
           <artifactId>jline-terminal-jansi</artifactId>
           <version>${jline.version}</version>
         </dependency>
    +    <dependency>
    +      <groupId>org.jline</groupId>
    +      <artifactId>jline-terminal-jni</artifactId>
    +      <version>${jline.version}</version>
    +    </dependency>
         <dependency>
           <groupId>org.jline</groupId>
           <artifactId>jline-terminal-jna</artifactId>
  • Run SQLLine with JLine 3.26.3 and JNI.

    root@87bebc5e1fbe:/sqlline# java -jar ./target/sqlline-1.13.0-SNAPSHOT-jar-with-dependencies.jar
    sqlline version 1.13.0-SNAPSHOT
    sqlline>

As a result, the WARNING message is not shown. So, I think it would be better to update the version of JLine to resolve the issue and add JNI to avoid the WARNING message.

That's all.
Regards,

@kota2and3kan kota2and3kan linked a pull request Nov 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant