发布

  • [OPIK-6482] [BE] fix: fetch dashboards page in two steps to avoid filesort OOM on JSON config (#7015)

    frostbyte_neo 发布于 2026-06-10 13:51:45 +00:00

    • [OPIK-6482] [BE] fix: fetch dashboards page in two steps to avoid filesort OOM on JSON config

    The dashboards list query did SELECT * ... ORDER BY id and, when the optimizer could
    not satisfy the ordering from an index, fell back to a filesort. On MySQL 8.0.20+ the
    filesort packs the selected columns (the addon-fields algorithm) — including the large
    JSON config column — into the sort buffer. Once a single row's config exceeds
    sort_buffer_size, MySQL raises ER_OUT_OF_SORTMEMORY and the list endpoint returns 500.
    max_length_for_sort_data no longer forces the rowid algorithm in 8.0.20+, so the only
    reliable control is to keep config out of the sorted projection.

    Fetch the page in two steps: findPageIdsSorted orders and paginates selecting only id
    (a narrow sort that cannot exceed sort_buffer_size), then findByIds loads the row bodies
    with no ORDER BY and the service restores ordering in memory. This removes config from
    every sort buffer regardless of config size or sort field, and works for any sort column.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • [OPIK-6482] [BE] test: cover two-step reorder under custom sort + pagination

    Adds a DashboardsResourceTest case that creates dashboards with random names
    (name order != id order), then sorts by name and traverses every page, asserting
    each page's full content (recursive comparison, not just ids) matches the expected
    sorted slice. This verifies the two-step fetch's in-memory reorder under a custom
    sorting_field across all pages, which the prior sort tests (single page, id-only
    assertions) did not cover. Dashboards are created in parallel to speed up the run.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • [OPIK-6482] [BE] refactor: drop redundant null filter in two-step dashboards fetch

    Both findPageIdsSorted and findByIds run in the same READ_ONLY transaction
    (consistent snapshot), so every pageId resolves in findByIds and the
    filter(Objects::nonNull) can never drop an element. Trust findByIds' results
    per review feedback.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com

    下载附件