Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch query with large filter condition, upstream MV with lots of keys fails with CN OOM #15636

Closed
kwannoel opened this issue Mar 12, 2024 · 1 comment · Fixed by #15638
Closed
Assignees
Labels
type/bug Something isn't working type/feature
Milestone

Comments

@kwannoel
Copy link
Contributor

kwannoel commented Mar 12, 2024

Repro Scripts

create.sql.log
insert.sql.log
query.sql.log

python script to generate these: https://github.com/kwannoel/risingwave-dev-scripts/blob/main/wide_table.py.

You can generate versions to stdout with less row and columns to easily see the structure of the sql.

e.g.

# view usage
./wide_table.py
./wide_table.py create 4
./wide_table.py insert 3 3

You can also use explain on the batch query (query.sql.log)

Repro steps

./risedev d full
# open localhost:3001, look at CN memory usage
psql -f create.sql.log
psql -f insert.sql.log
psql -f query.sql.log
# mem usage should spike

Observations

  1. Halving the number of filter conditions also halves the mem usage.
  2. Can try varying the PK as well.

Suggested next steps

Get a heap profile

@kwannoel kwannoel added type/bug Something isn't working type/feature labels Mar 12, 2024
@kwannoel kwannoel changed the title Batch query with large filter condition, upstream MV with lots of keys fails Batch query with large filter condition, upstream MV with lots of keys fails with CN OOM Mar 12, 2024
@github-actions github-actions bot added this to the release-1.8 milestone Mar 12, 2024
@kwannoel
Copy link
Contributor Author

I guess I have found the root cause of batch query OOM:
We have too many scan_ranges in RowSeqScan somehow (861 ranges in my reproduction). For each range, we will issue a range scan concurrently. The problem is that we don’t limit the concurrency, so there will be 861 tasks running at the same time, each has multiple array builders. They will consume a total of 861 ranges x 128 columns x 1024 rows x 4 bytes = 450MB memory. If we consider parallelism, it can easily eat up several GB.

From @wangrunji0408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working type/feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants