[
https://issues.apache.org/jira/browse/FLINK-41802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
YifanWu updated FLINK-41802:
----------------------------
Description:
PyFlink DataStream's CsvReaderFormat.for_schema() fails during reader
construction when PythonCsvUtils and CsvReaderFormat are defined by different
class loaders. The former calls the latter's package-private constructor, so
the JVM raises IllegalAccessError before any CSV file is read.
Reproduction
Run PyFlink with flink-csv on the application classpath and flink-python loaded
separately by Flink's child-first class loader. The community report below
shows this layout with Flink 1.18.1 and the Kubernetes Operator. A minimal call
is:
from pyflink.datastream import StreamExecutionEnvironment
from pyflink.datastream.formats.csv import CsvReaderFormat, CsvSchema
from pyflink.table import DataTypes
StreamExecutionEnvironment.get_execution_environment()
schema = CsvSchema.builder().add_number_column('id',
number_type=DataTypes.INT()).build()
CsvReaderFormat.for_schema(schema)
Actual result: java.lang.IllegalAccessError in
PythonCsvUtils.createCsvReaderFormat when it calls CsvReaderFormat.<init>.
Expected result: the reader is created and reads records with the configured
schema. Verified on released Apache Flink 2.3.0 (latest stable) and 2.2.1 with
the matching JARs from Maven Central and JDK 21.0.10. In both versions, Flink’s
ChildFirstClassLoader defined PythonCsvUtils, the application class loader
defined CsvReaderFormat, and reader creation failed at PythonCsvUtils.java:48
with IllegalAccessError. The same failure also reproduces on Apache Flink
master ea273d29db9.
Proposed approach
Route construction through the internal CsvFileFormatFactory in flink-csv. Keep
the constructor package-private, preserve row conversion and the existing
serialization entry points, and verify reader creation, serialization, ordinary
and NULL fields, and EOF with the two distinct class loaders.
Prior report: https://lists.apache.org/thread/xmrfywn2jq2ordwdm4ko5x9jyn6vxjxm
Call site:
https://github.com/apache/flink/blob/ea273d29db96262cea0955dce7fcb83d7faac046/flink-python/src/main/java/org/apache/flink/formats/csv/PythonCsvUtils.java#L37-L49
was:
PyFlink DataStream's CsvReaderFormat.for_schema() fails during reader
construction when PythonCsvUtils and CsvReaderFormat are defined by different
class loaders. The former calls the latter's package-private constructor, so
the JVM raises IllegalAccessError before any CSV file is read.
Reproduction
Run PyFlink with flink-csv on the application classpath and flink-python loaded
separately by Flink's child-first class loader. The community report below
shows this layout with Flink 1.18.1 and the Kubernetes Operator. A minimal call
is:
from pyflink.datastream import StreamExecutionEnvironment
from pyflink.datastream.formats.csv import CsvReaderFormat, CsvSchema
from pyflink.table import DataTypes
StreamExecutionEnvironment.get_execution_environment()
schema = CsvSchema.builder().add_number_column('id',
number_type=DataTypes.INT()).build()
CsvReaderFormat.for_schema(schema)
Actual result: java.lang.IllegalAccessError in
PythonCsvUtils.createCsvReaderFormat when it calls CsvReaderFormat.<init>.
Expected result: the reader is created and reads records with the configured
schema. The same failure was reproduced by a split-class-loader regression test
against Apache Flink master ea273d29db9.
Proposed approach
Route construction through the internal CsvFileFormatFactory in flink-csv. Keep
the constructor package-private, preserve row conversion and the existing
serialization entry points, and verify reader creation, serialization, ordinary
and NULL fields, and EOF with the two distinct class loaders.
Prior report: https://lists.apache.org/thread/xmrfywn2jq2ordwdm4ko5x9jyn6vxjxm
Call site:
https://github.com/apache/flink/blob/ea273d29db96262cea0955dce7fcb83d7faac046/flink-python/src/main/java/org/apache/flink/formats/csv/PythonCsvUtils.java#L37-L49
> PyFlink CsvReaderFormat.for_schema fails with IllegalAccessError across class
> loaders
> -------------------------------------------------------------------------------------
>
> Key: FLINK-41802
> URL: https://issues.apache.org/jira/browse/FLINK-41802
> Project: Flink
> Issue Type: Bug
> Components: API / Python
> Affects Versions: 1.18.1, 2.3.0, 2.2.1
> Reporter: YifanWu
> Priority: Major
>
> PyFlink DataStream's CsvReaderFormat.for_schema() fails during reader
> construction when PythonCsvUtils and CsvReaderFormat are defined by different
> class loaders. The former calls the latter's package-private constructor, so
> the JVM raises IllegalAccessError before any CSV file is read.
> Reproduction
> Run PyFlink with flink-csv on the application classpath and flink-python
> loaded separately by Flink's child-first class loader. The community report
> below shows this layout with Flink 1.18.1 and the Kubernetes Operator. A
> minimal call is:
> from pyflink.datastream import StreamExecutionEnvironment
> from pyflink.datastream.formats.csv import CsvReaderFormat, CsvSchema
> from pyflink.table import DataTypes
> StreamExecutionEnvironment.get_execution_environment()
> schema = CsvSchema.builder().add_number_column('id',
> number_type=DataTypes.INT()).build()
> CsvReaderFormat.for_schema(schema)
> Actual result: java.lang.IllegalAccessError in
> PythonCsvUtils.createCsvReaderFormat when it calls CsvReaderFormat.<init>.
> Expected result: the reader is created and reads records with the configured
> schema. Verified on released Apache Flink 2.3.0 (latest stable) and 2.2.1
> with the matching JARs from Maven Central and JDK 21.0.10. In both versions,
> Flink’s ChildFirstClassLoader defined PythonCsvUtils, the application class
> loader defined CsvReaderFormat, and reader creation failed at
> PythonCsvUtils.java:48 with IllegalAccessError. The same failure also
> reproduces on Apache Flink master ea273d29db9.
> Proposed approach
> Route construction through the internal CsvFileFormatFactory in flink-csv.
> Keep the constructor package-private, preserve row conversion and the
> existing serialization entry points, and verify reader creation,
> serialization, ordinary and NULL fields, and EOF with the two distinct class
> loaders.
> Prior report: https://lists.apache.org/thread/xmrfywn2jq2ordwdm4ko5x9jyn6vxjxm
> Call site:
> https://github.com/apache/flink/blob/ea273d29db96262cea0955dce7fcb83d7faac046/flink-python/src/main/java/org/apache/flink/formats/csv/PythonCsvUtils.java#L37-L49
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)