re20052 commented on issue #63526:
URL: https://github.com/apache/doris/issues/63526#issuecomment-4831185822

   Hit the same issue on 4.0 with a cross-Doris catalog + `ORDER BY ... LIMIT`.
   
   **Root cause:** FE has two independent lazy-materialization paths for TopN. 
Both assume the scan is a local `OlapTable` and only ship local BEs in 
`TPaloNodesInfo`. But `RemoteOlapTable extends OlapTable`, and the `row_id` it 
produces encodes the **remote** `backend_id`:
   
   - Path A (new, `MaterializationNode`) → BE crashes with 
`MaterializationSinkOperatorX failed to find rpc_struct, backend_id=XXX`.
   - Path B (old, `DeferMaterializeTopN` + `RowIDFetcher`) → BE returns `Miss 
matched return row loc count 0, expected 0, input N` from 
`be/src/exec/rowid_fetcher.cpp`.
   
   **Temporary workaround** (must set both; the two paths are independent, 
disabling only one still hits the other):
   
   ```sql
   SET enable_two_phase_read_opt = false;
   SET topn_lazy_materialization_threshold = 0;
   ```
   
   Note: these are global switches, so local-catalog TopN queries also lose the 
lazy-materialization optimization. Use only as a stopgap.


-- 
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]

Reply via email to