yujun777 opened a new issue, #67133:
URL: https://github.com/apache/doris/issues/67133
### Background
PR #66739 (`[refactor](stream) Localize Cloud Table Stream rewrite state
handling`) tightened `StreamConsumptionInfoExtractor` so that, in cloud mode,
every non-snapshot `LogicalOlapTableStreamScan` in the final plan must already
have cloud read states installed:
```java
Preconditions.checkState(Config.isNotCloudMode() ||
wrapper.hasCloudReadStates(),
"Cloud Table Stream read state must be installed during relation
analysis");
```
Before this change, scans without installed states were silently skipped.
The new invariant is correct for statements whose stream scans are created
during relation binding, but it breaks any flow that **synthesizes stream scans
after binding**.
### Problem
Read-state installation is only wired to one place:
- `BindRelation.makeTableStreamScan()` registers
`CloudTableStreamReadStateHook` when the statement *binds* an `OlapTableStream`
during analysis.
- The hook's `afterAnalyze()` installs read states for all stream scans via
`resolve(plan)` — which is package-private and lives inside the hook.
However, other components generate `LogicalOlapTableStreamScan` **after**
binding, so the hook is never registered for their statements and the
precondition always fails. Concretely, IVM refresh synthesizes stream scans
outside of bind:
- COMPLETE refresh: `IvmFullRefreshMTMV` rewrites plain base-table scans
into stream scans during late analysis.
- INCREMENTAL refresh: `IvmDeltaRewriteState.createDeltaScan(...)` creates
delta stream scans during the rewrite phase.
Because the MV defining SQL of an IVM MV is a plain query over base tables,
at bind time there is no stream object at all — hook registration can never
happen on this path.
Since stream scans are allowed to be generated in multiple places,
read-state installation should NOT be hardwired to `BindRelation`. A public
installation API should be provided so any generator can install states before
extraction.
### Reproduction (cloud mode)
Deployment: 1 FE + 1 BE + 1 Meta Service + 1 Recycler + FDB, master branch.
```sql
CREATE TABLE t (
k1 INT,
v1 INT,
v2 INT
) DUPLICATE KEY(k1)
DISTRIBUTED BY HASH(k1) BUCKETS 1
PROPERTIES (
'replication_num' = '1',
'binlog.enable' = 'true',
'binlog.format' = 'ROW'
);
CREATE MATERIALIZED VIEW mv
REFRESH INCREMENTAL
AS SELECT k1, v1, v2 FROM t;
INSERT INTO t VALUES (1, 10, 100);
REFRESH MATERIALIZED VIEW mv COMPLETE;
-- refresh task FAILED
```
Task error:
```
Cloud Table Stream read state must be installed during relation analysis
```
Works as expected on shared-nothing mode (`Config.isNotCloudMode()`
short-circuits the check).
### Expected
Either:
1. Provide a public installation entry point (e.g., abstract the collect →
single `get_table_stream_offset/read_states` RPC → distribute/install
orchestration currently locked inside
`CloudTableStreamReadStateHook.resolve()`) so components that synthesize stream
scans (IVM full/incremental refresh) can install read states before extraction;
or
2. Relax the precondition accordingly.
The fix should land on master.
### Related issues
- #65265
- #65418
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]