Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-14220 Build and test Spark against Scala 2.12
  3. SPARK-25047

Can't assign SerializedLambda to scala.Function1 in deserialization of BucketedRandomProjectionLSHModel

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.4.0
    • 2.4.0
    • ML
    • None
    • Hide
      Release Notes text:

      In Scala 2.12, in some rare cases, Spark jobs will fail with an error like "java.lang.ClassCastException: cannot assign instance of java.lang.invoke.SerializedLambda ... of type scala.Function1". This typically occurs when a closure or function definition is assigned to a class member. It can typically be avoided by changing this to a simple function definition -- from a "val" to a "def".
      Show
      Release Notes text: In Scala 2.12, in some rare cases, Spark jobs will fail with an error like "java.lang.ClassCastException: cannot assign instance of java.lang.invoke.SerializedLambda ... of type scala.Function1". This typically occurs when a closure or function definition is assigned to a class member. It can typically be avoided by changing this to a simple function definition -- from a "val" to a "def".

    Description

      Another distinct test failure:

      - BucketedRandomProjectionLSH: streaming transform *** FAILED ***
      
        org.apache.spark.sql.streaming.StreamingQueryException: Query [id = 7f34fb07-a718-4488-b644-d27cfd29ff6c, runId = 0bbc0ba2-2952-4504-85d6-8aba877ba01b] terminated with exception: Job aborted due to stage failure: Task 0 in stage 16.0 failed 1 times, most recent failure: Lost task 0.0 in stage 16.0 (TID 16, localhost, executor driver): java.lang.ClassCastException: cannot assign instance of java.lang.invoke.SerializedLambda to field org.apache.spark.ml.feature.BucketedRandomProjectionLSHModel.hashFunction of type scala.Function1 in instance of org.apache.spark.ml.feature.BucketedRandomProjectionLSHModel
      
      ...
      
        Cause: java.lang.ClassCastException: cannot assign instance of java.lang.invoke.SerializedLambda to field org.apache.spark.ml.feature.BucketedRandomProjectionLSHModel.hashFunction of type scala.Function1 in instance of org.apache.spark.ml.feature.BucketedRandomProjectionLSHModel
      
        at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2233)
      
        at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1405)
      
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2284)
      ...

      Here the different nature of a Java 8 LMF closure trips of Java serialization/deserialization. I think this can be patched by manually implementing the Java serialization here, and don't see other instances (yet).

      Also wondering if this "val" can be a "def".

      Attachments

        Activity

          People

            srowen Sean R. Owen
            srowen Sean R. Owen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: