cshuo opened a new issue, #20864:
URL: https://github.com/apache/hudi/issues/20864
## Description
A Flink streaming query fails during job graph construction when
`read.source-v2.enabled=true` and the target path has no `.hoodie` directory.
The Flink DDL already declares the table schema. With
`read.source-v2.enabled=false`, the same query can build its source and wait
for the table to appear.
This prevents users from starting a Source V2 reader before the first writer.
## Steps to reproduce
1. Choose a local path that has no `.hoodie` directory. Leave the writer
stopped.
2. In a streaming Flink SQL session, declare the table and start a read.
```sql
CREATE TEMPORARY TABLE hudi_events (
uuid STRING PRIMARY KEY NOT ENFORCED,
name STRING,
ts TIMESTAMP(3)
) WITH (
'connector' = 'hudi',
'path' = 'file:///tmp/hudi-source-v2-repro',
'read.streaming.enabled' = 'true',
'read.source-v2.enabled' = 'true'
);
SELECT * FROM hudi_events;
```
3. Repeat with `read.source-v2.enabled` set to `false`, keeping the path
uninitialized.
## Expected behavior
Both source implementations should be able to build the streaming dataflow
from the declared schema before the first writer initializes the table.
## Actual behavior
A parameterized regression test on Hudi commit
`e4c229dab66ecfc7f7a51dd114482f9d0c09c674` exercised
`getScanRuntimeProvider(...).produceDataStream(...)` with Flink 2.2.1 and JDK
17. Both cases used an empty local directory and asserted that the provider
returned a data stream.
| `read.source-v2.enabled` | Observed result |
|---|---|
| `false` | Returned a data stream successfully |
| `true` | Threw `IllegalStateException` during graph construction,
including on all three Surefire retries |
```text
java.lang.IllegalStateException: MetaClient must be initialized before
creating HoodieSource
at
org.apache.hudi.common.util.ValidationUtils.checkState(ValidationUtils.java:78)
at
org.apache.hudi.table.HoodieTableSource.createHoodieSource(HoodieTableSource.java:296)
at
org.apache.hudi.table.HoodieTableSource.produceNewSourceDataStream(HoodieTableSource.java:247)
at
org.apache.hudi.table.HoodieTableSource$1.produceDataStream(HoodieTableSource.java:232)
at
org.apache.hudi.adapter.DataStreamScanProviderAdapter.produceDataStream(DataStreamScanProviderAdapter.java:32)
```
For a streaming read, `metaClientForReader` returns `null` when the table
does not yet exist. The legacy monitor checks for the table again on subsequent
polls. Source V2 requires a non-null meta client in `createHoodieSource`, so it
fails before polling can begin. [Reader
initialization](https://github.com/apache/hudi/blob/e4c229dab66ecfc7f7a51dd114482f9d0c09c674/hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/util/StreamerUtil.java#L515-L524)
· [Legacy
monitor](https://github.com/apache/hudi/blob/e4c229dab66ecfc7f7a51dd114482f9d0c09c674/hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/StreamReadMonitoringFunction.java#L230-L250)
· [Source V2
precondition](https://github.com/apache/hudi/blob/e4c229dab66ecfc7f7a51dd114482f9d0c09c674/hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/HoodieTableSource.java#L295-L296)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]