[PR #3046] [CLOSED] ngram: avoid draining nonexistent reads after initialization failures #4420

Closed
opened 2026-11-07 15:35:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3046
Author: @j-luwierski
Created: 10/18/2026
Status: ❌ Closed

Base: main ← Head: codex/ple-reader-init-cleanup


📝 Commits (1)

  • ad5a36b ngram: avoid draining nonexistent reads after initialization failures

📊 Changes

3 files changed (+136 additions, -1 deletions)

View changed files

📝 CMakeLists.txt (+19 -0)
📝 src/ngram/ple_reader.cpp (+3 -1)
➕ tests/platform/ple_reader_lifecycle.cpp (+114 -0)

📄 Description

Title

Resolves #3045

Summary

PleReader::open() can block forever during cleanup before submitting any reads: slab allocation failure publishes a nonzero slot count with no free slots, and failed reopen inherits the previous slot count after close cleared the free slots. Both paths wait for completions that cannot exist. Failed initialization now returns the existing error, closes the file and permits a later valid open.

What changed

  • Publish max_inflight only after the slab and free-slot list are initialized.
  • Reset max_inflight when closing the reader.
  • Add a Linux CPU-only lifecycle test with caller-thread and I/O-worker cases. Link-time posix_memalign wrapping injects a one-shot ENOMEM without adding production fault-injection settings. CTest timeouts turn the former hangs into bounded failures.

Successful row reads, page-straddling rows, close with outstanding reads, repeated close and read-after-recovery are covered. The I/O scheduling, cache, kernels, row bytes, defaults and public API remain unchanged.

Validation

Linux x86_64, GCC 14.2.0; isolated branch from directly fetched upstream main 477ac13cbe8e582c20484871ce459d20d82df09d.

  • CMake CPU build with STRATA_BUILD_TESTS=ON and STRATA_WERROR=ON: built ple_reader_lifecycle_test and direct_file_async_test.
  • CTest: all 7 selected tests passed (6 lifecycle cases and existing DirectFile async test). Successful reads are compared byte-for-byte against an independent fixture pattern.
  • Compiled the same lifecycle test against unchanged upstream: both normal-read controls passed; allocation and reopen cases timed out after 2 seconds in both caller and threaded modes (4 timeouts).
  • git diff --check passed.

Extra Notes

Draft; no review requested. AGENTS.md requires builds of every affected backend before review. Full CUDA/HIP/SYCL engine builds have not been run; HIP and SYCL compilers are unavailable here. Windows runtime behavior and real model inference were not tested. These are injected/API error-path tests, not a measured production memory-pressure incident.

Searched open issues and PRs. #2991 concerns temporary-file collisions in another selftest; #2623 concerns prefetch matching. This change addresses initialization bookkeeping only.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3046 **Author:** [@j-luwierski](https://github.com/j-luwierski) **Created:** 10/18/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/ple-reader-init-cleanup` --- ### 📝 Commits (1) - [`ad5a36b`](https://github.com/Niko1221/Strata/commit/ad5a36be86c2110ada902fb9d22fb4c65af4a372) ngram: avoid draining nonexistent reads after initialization failures ### 📊 Changes **3 files changed** (+136 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+19 -0) 📝 `src/ngram/ple_reader.cpp` (+3 -1) ➕ `tests/platform/ple_reader_lifecycle.cpp` (+114 -0) </details> ### 📄 Description ## Title Resolves #3045 ## Summary `PleReader::open()` can block forever during cleanup before submitting any reads: slab allocation failure publishes a nonzero slot count with no free slots, and failed reopen inherits the previous slot count after close cleared the free slots. Both paths wait for completions that cannot exist. Failed initialization now returns the existing error, closes the file and permits a later valid open. ## What changed - Publish `max_inflight` only after the slab and free-slot list are initialized. - Reset `max_inflight` when closing the reader. - Add a Linux CPU-only lifecycle test with caller-thread and I/O-worker cases. Link-time `posix_memalign` wrapping injects a one-shot ENOMEM without adding production fault-injection settings. CTest timeouts turn the former hangs into bounded failures. Successful row reads, page-straddling rows, close with outstanding reads, repeated close and read-after-recovery are covered. The I/O scheduling, cache, kernels, row bytes, defaults and public API remain unchanged. ## Validation Linux x86_64, GCC 14.2.0; isolated branch from directly fetched upstream main `477ac13cbe8e582c20484871ce459d20d82df09d`. - CMake CPU build with `STRATA_BUILD_TESTS=ON` and `STRATA_WERROR=ON`: built `ple_reader_lifecycle_test` and `direct_file_async_test`. - CTest: all 7 selected tests passed (6 lifecycle cases and existing DirectFile async test). Successful reads are compared byte-for-byte against an independent fixture pattern. - Compiled the same lifecycle test against unchanged upstream: both normal-read controls passed; allocation and reopen cases timed out after 2 seconds in both caller and threaded modes (4 timeouts). - `git diff --check` passed. ## Extra Notes Draft; no review requested. AGENTS.md requires builds of every affected backend before review. Full CUDA/HIP/SYCL engine builds have not been run; HIP and SYCL compilers are unavailable here. Windows runtime behavior and real model inference were not tested. These are injected/API error-path tests, not a measured production memory-pressure incident. Searched open issues and PRs. #2991 concerns temporary-file collisions in another selftest; #2623 concerns prefetch matching. This change addresses initialization bookkeeping only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:35:36 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4420
No description provided.