apache / linkis

Apache Linkis builds a computation middleware layer to facilitate connection, governance and orchestration between the upper applications and the underlying data engines.
https://linkis.apache.org/
Apache License 2.0
3.32k stars 1.17k forks source link

[Bug] [Spark]The execution of SecureRandomStringUtils.random may get stuck. #5196

Closed peacewong closed 1 week ago

peacewong commented 2 weeks ago

Search before asking

Linkis Component

linkis-engineconnn-plugin

Steps to reproduce

  1. execute pyspark task
  2. java thread hang
    "TaskExecution-Thread-1" #144 daemon prio=5 os_prio=0 tid=0x00007f154800f000 nid=0x6fd8 runnable [0x00007f14efd6e000]
    java.lang.Thread.State: RUNNABLE
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:255)
        at sun.security.provider.NativePRNG$RandomIO.readFully(NativePRNG.java:424)
        at sun.security.provider.NativePRNG$RandomIO.ensureBufferValid(NativePRNG.java:525)
        at sun.security.provider.NativePRNG$RandomIO.implNextBytes(NativePRNG.java:544)
        - locked <0x00000000c074f570> (a java.lang.Object)
        at sun.security.provider.NativePRNG$RandomIO.access$400(NativePRNG.java:331)
        at sun.security.provider.NativePRNG$Blocking.engineNextBytes(NativePRNG.java:268)
        at java.security.SecureRandom.nextBytes(SecureRandom.java:468)
        at java.security.SecureRandom.next(SecureRandom.java:491)
        at java.util.Random.nextInt(Random.java:390)
        at org.apache.linkis.engineplugin.spark.executor.SecureRandomStringUtils.random(SecureRandomStringUtils.java:182)
        at org.apache.linkis.engineplugin.spark.executor.SecureRandomStringUtils.random(SecureRandomStringUtils.java:99)
        at org.apache.linkis.engineplugin.spark.executor.SecureRandomStringUtils.random(SecureRandomStringUtils.java:76)
        at org.apache.linkis.engineplugin.spark.executor.SecureRandomStringUtils.randomAlphanumeric(SecureRandomStringUtils.java:60)
        at org.apache.linkis.engineplugin.spark.executor.SparkPythonExecutor.py4jToken$lzycompute(SparkPythonExecutor.scala:79)

Expected behavior

do not stuck.

Your environment

Anything else

No response

Are you willing to submit a PR?

github-actions[bot] commented 2 weeks ago

:blush: Welcome to the Apache Linkis community!!

We are glad that you are contributing by opening this issue.

Please make sure to include all the relevant context. We will be here shortly.

If you are interested in contributing to our website project, please let us know! You can check out our contributing guide on :point_right: How to Participate in Project Contribution.

Community

WeChat Assistant WeChat Public Account

Mailing Lists

Name Description Subscribe Unsubscribe Archive
dev@linkis.apache.org community activity information subscribe unsubscribe archive
peacewong commented 2 weeks ago

ping ~ @pjfanning

pjfanning commented 2 weeks ago

@peacewong secure random requires entropy and on some VMs, there is not enough entropy

Sometimes, you can work around this by adding -Djava.security.egd=file:/dev/./urandom

When I have issues like this in the past, I have installed haveged on the affected machine.

https://www.digitalocean.com/community/tutorials/how-to-setup-additional-entropy-for-cloud-servers-using-haveged

pjfanning commented 2 weeks ago

One potential change is allow users to opt out of the change in https://github.com/apache/linkis/pull/5143. I would prefer, if we use secure random strings by default but we could allow customers to choose to opt out.

peacewong commented 2 weeks ago

Yes, I think we should have the option to turn off use secure random by default, which is the mode that uses random numbers.