Skip to content

[C++] Bound retained memory during hot-device metadata lookups - #1030

Open
zhangxinyao88 wants to merge 2 commits into
apache:developfrom
zhangxinyao88:codex/tsfile-1009-query-owned-index-copies
Open

zhangxinyao88 wants to merge 2 commits into
apache:developfrom
zhangxinyao88:codex/tsfile-1009-query-owned-index-copies

Conversation

@zhangxinyao88

@zhangxinyao88 zhangxinyao88 commented Oct 21, 2026 •

Copy link
Copy Markdown

Repeated lookups of a hot device clone measurement names into the cached index node's arena. Releasing each scan iterator therefore leaves retained reader memory growing even with one cached device: the regression fixture grows from 1,072 to 84,688 accounted bytes after 10,000 lookups on develop.

Give lookup-result copies an explicit destination arena and use the query/iterator arena for measurement lookup, including every level of internal-index traversal. Keep the existing lookup signature and default behavior for other callers. Temporary traversal nodes can be destroyed safely, and cache eviction cannot invalidate parsed iterator metadata. The file format and read results are unchanged.

Fixes #1009.

Validation on macOS arm64, JDK 17, clang-format 17.0.6:

  • ./mvnw -B -ntp -P with-cpp -Denable.lzma2=ON verify passes with all configured codecs, ANTLR and SIMD enabled. CTest registers 1,180 cases: 1,167 passed, 3 skipped (external cross-language fixtures not configured), 10 disabled upstream performance/large-file cases, 0 failures. Spotless, Checkstyle and RAT pass.
  • Nine focused genuinely instrumented Debug/ASan/UBSan tests pass after the 2026-10-22 test-cleanup fix. Both test and library compile flags contain -fsanitize=address,undefined; the test binary imports ASan/UBSan handlers and loads the ASan runtime. Optional codecs/ANTLR/SIMD are disabled for this separate lifetime probe. Includes both hot-device index depths, returned names surviving source arena reset and a row read after cache eviction.
  • Both new hot-device cases fail against unchanged develop production code with 84,688 retained bytes versus 1,072 at warm-up, then pass after this fix. Accounting assertions are guarded by ENABLE_MEM_STAT; functional checks still run without it.
  • git diff --check passes. No Java/Python suite, full sanitizer suite or external cross-language-fixture run is claimed.

Validation correction (2026-10-22): the earlier local build labelled ASan had lost its sanitizer compiler flags during CMake configuration, so those earlier nine passes were plain Debug results. MSVC ASan then caught a use-after-free in this PR's eviction test: column iterators were destroyed after revert_tsblock() freed their vectors. The follow-up commit scopes those iterators before block release. The full C++ Maven verification and the genuinely instrumented nine-case probe above were rerun successfully after that fix. The production metadata-ownership change is unchanged. Windows verification of the follow-up is still pending.

CI at the original head also showed Linux setup failures before compilation (clang-format-17 absent; Python 3.9 unavailable for Ubuntu 26.04). Those provisioning failures are outside this patch. No complete green-CI claim is made.

AI disclosure: OpenAI Codex generated this patch, tests, and description and performed the reported verification. No personal human review is claimed.

Copy measurement index lookup results into the iterator/query arena,
including intermediate nodes during multi-level traversal. Preserve the
existing lookup entry point and keep cached node arenas unchanged.

Cover repeated hot-device lookups, result-copy lifetime and an active
iterator surviving cache eviction.

Generated-by: OpenAI Codex
Keep column iterator destructors inside the block lifetime. MSVC ASan
caught their reset_offset writes after revert_tsblock freed the vectors.
The production metadata ownership fix remains unchanged.

Generated-by: OpenAI Codex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][C++] Repeated metadata lookups grow hot device-cache arenas

1 participant