Skip to content

Manifests reader queue in ParallelIterable is unlimited caused OOM #7843

Closed

Description

@Heltman

Feature Request / Improvement

ParallelIterable use ConcurrentLinkedQueue to read manifests file. If we have too many files in our iceberg table, this queue will take up too much memory. I recommend using LinkedBlockingQueue to limit to avoid driver/coordinator OOM.

We have an iceberg table with millions of files and a few hundred columns. A FileScanTask will use 50KB memory because the complex schema, millions will totally use almost 50GB memory in this queue.

This problem happened in spark and trino.

Query engine

Trino

Activity

  1. nastra commented on Jun 15, 2023

    @nastra
    Contributor

    @Heltman thanks for reporting this. Would you be interested in providing a PR to fix this?

  2. Heltman commented on Jun 15, 2023

    @Heltman
    ContributorAuthor

    @nastra I give a PR. I wonder if we need to add performance related tests.

  3. rdblue commented on Jun 19, 2023

    @rdblue
    Contributor

    This has come up before and the issue is actually that the table has too many files, not that we need to change the design of the queue within ParallelIterable. The queue filling up is usually a symptom of needing to compact data in the table. @Heltman can you run a query to summarize the files in your table? How many are there and what is the average size? How many partitions and what's the distribution of file sizes within those partitions?

  4. Heltman commented on Jun 20, 2023

    @Heltman
    ContributorAuthor

    @rdblue We have table with 400 partitions, every partition with 10k files, every files with 64~256MB. Total size ~500TB. Table has ~100 columns with complex types. As I see, one FileScanTask use 20KB memory, our trino coordinator have 40cores, default use 80 threads load to this queue. Which means at least we used 15GB (80 x 10k x 20KB) memory in this queue. When we has 4 queries, coordinator will oom.

  5. zinking commented on Jun 21, 2023

    @zinking
    Contributor

    can you explain a bit more why a linkedq makes difference ?

    in your calculation you are assuming the whole partition is loaded, is this the common case ?

  6. Heltman commented on Jun 21, 2023

    @Heltman
    ContributorAuthor

    @zinking LinkedBlockingQueue can limit the queue size, and block read manifests thread. In fact, the user just query similar to select * limit, but needs to read all metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions