[PR #3338] [Other] Read conversation-cache log backlogs without dropping events #4576

Open
opened 2026-11-07 15:37:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3338
Author: @oscarlius
Created: 10/20/2026
Status: 🔄 Open

Base: main ← Head: fix/conversation-cache-log-backlog-20261018


📝 Commits (1)

  • b723d19 fix(serve): read cache log backlogs without dropping events

📊 Changes

2 files changed (+184 additions, -15 deletions)

View changed files

📝 serve/server.py (+29 -15)
➕ serve/test_cache_log_backlog.py (+155 -0)

📄 Description

Problem and result

Issue #3048 can drop earlier conversation-cache events when more than one MiB arrives between monitor polls. The observer now advances through a captured end of file in bounded chunks, commits only complete lines, and retains a partial line for the next poll.

Continues #3050 after the v0.2.1.4 tracker reset. The original passed the new format check, but GitHub refused to reopen the rebased branch; the reset bot explicitly suggested a new linked pull request.

Fixes #3048.

Approach

  • Replace the last-MiB seek with bounded sequential chunks in serve/server.py.
  • Commit the byte cursor only through complete lines so interrupted writes and read errors retry safely.
  • Add local backlog, chunk-boundary, interrupted-read, and local HTTP regression coverage in serve/test_cache_log_backlog.py.

Validation

Rebased on upstream main 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4 (v0.2.1.4); tested candidate b723d19bb9cd49314fdf4835be81d80d0e968e58 on Windows, Python 3.14.3. Each test command starts a fresh local process.

Passed:

  • py -3.12 -m ruff check --output-format json serve/server.py serve/test_cache_log_backlog.py (Ruff 0.2.1): 10 existing diagnostics, same as unmodified main; zero new diagnostics.
    python -m unittest serve.test_cache_log_backlog (7 tests); python -m unittest serve.test_monitor serve.test_server serve.test_prometheus (357 tests, 3 skipped); python -m py_compile serve/server.py; git diff --check 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4..HEAD.

Failed: Red reproduction used git restore --source=9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4 -- serve/server.py, then python -m unittest serve.test_cache_log_backlog, then git restore --source=HEAD -- serve/server.py. The test ran 7 tests and failed 8 assertions, covering lost early events, chunk crossings, partial-line retry, and local /metrics catch-up.

Not run: Native backend builds and real GPU/model tests. Only Python observer code changed. The Python 3.14.3 test environment had no Ruff; the separate Python 3.12.7 lint comparison above completed successfully.

Limits

One poll may process a large accumulated backlog; each underlying read remains bounded by READ_MAX. Validation used local file fixtures and a local MockEngine HTTP server; it did not use a real engine or a production service.


🔄 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/3338 **Author:** [@oscarlius](https://github.com/oscarlius) **Created:** 10/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/conversation-cache-log-backlog-20261018` --- ### 📝 Commits (1) - [`b723d19`](https://github.com/Niko1221/Strata/commit/b723d19bb9cd49314fdf4835be81d80d0e968e58) fix(serve): read cache log backlogs without dropping events ### 📊 Changes **2 files changed** (+184 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+29 -15) ➕ `serve/test_cache_log_backlog.py` (+155 -0) </details> ### 📄 Description ## Problem and result Issue #3048 can drop earlier conversation-cache events when more than one MiB arrives between monitor polls. The observer now advances through a captured end of file in bounded chunks, commits only complete lines, and retains a partial line for the next poll. ## Related discussion Continues #3050 after the v0.2.1.4 tracker reset. The original passed the new format check, but GitHub refused to reopen the rebased branch; [the reset bot](https://github.com/Niko1221/Strata/pull/3050#issuecomment-6282596517) explicitly suggested a new linked pull request. Fixes #3048. ## Approach - Replace the last-MiB seek with bounded sequential chunks in `serve/server.py`. - Commit the byte cursor only through complete lines so interrupted writes and read errors retry safely. - Add local backlog, chunk-boundary, interrupted-read, and local HTTP regression coverage in `serve/test_cache_log_backlog.py`. ## Validation Rebased on upstream main `9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4` (v0.2.1.4); tested candidate `b723d19bb9cd49314fdf4835be81d80d0e968e58` on Windows, Python 3.14.3. Each test command starts a fresh local process. **Passed:** - `py -3.12 -m ruff check --output-format json serve/server.py serve/test_cache_log_backlog.py` (Ruff 0.2.1): 10 existing diagnostics, same as unmodified main; zero new diagnostics. `python -m unittest serve.test_cache_log_backlog` (7 tests); `python -m unittest serve.test_monitor serve.test_server serve.test_prometheus` (357 tests, 3 skipped); `python -m py_compile serve/server.py`; `git diff --check 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4..HEAD`. **Failed:** Red reproduction used `git restore --source=9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4 -- serve/server.py`, then `python -m unittest serve.test_cache_log_backlog`, then `git restore --source=HEAD -- serve/server.py`. The test ran 7 tests and failed 8 assertions, covering lost early events, chunk crossings, partial-line retry, and local `/metrics` catch-up. **Not run:** Native backend builds and real GPU/model tests. Only Python observer code changed. The Python 3.14.3 test environment had no Ruff; the separate Python 3.12.7 lint comparison above completed successfully. ## Limits One poll may process a large accumulated backlog; each underlying read remains bounded by `READ_MAX`. Validation used local file fixtures and a local MockEngine HTTP server; it did not use a real engine or a production service. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4576
No description provided.