apache / apache/doris

[Bug] TopN Lazy Materialization hangs when ORDER BY + LIMIT queries require RowId materialization (4.1.2-rc01)

Open
#66,365 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
15.9k
Forks
3.9k
Avg merge
2d 23h
Merged PRs (30d)
520

Description

### Search before asking

- [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.

### Version

Apache Doris
doris-4.1.2-rc01-aec169d2025

### What's Wrong?

After upgrading to Apache Doris 4.1.2-rc01, we found that queries using ORDER BY ... LIMIT may hang indefinitely when the query needs to materialize non-key columns.
The problem disappears after disabling TopN Lazy Materialization by setting:
SET GLOBAL experimental_topn_lazy_materialization_threshold = 0;
This suggests the issue is related to the TopN Lazy Materialization / RowId Lookup execution path.

### What You Expected?

The query should finish normally.
TopN Lazy Materialization should not hang.

### How to Reproduce?

[Doris缺陷.docx](https://github.com/user-attachments/files/30640960/Doris.docx)

### Anything Else?

_No response_

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

Contributor guide

Open the contributing guide

Research direction

Begin with the attached Doris reproduction and inspect the TopN Lazy Materialization/RowId Lookup execution path. Verify the ORDER BY ... LIMIT query with the threshold enabled, then confirm it completes without the workaround. The payload names no source file or regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.