[PR #3335] [Other] Serialize conversation-cache log polling #4574

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

📋 Pull Request Information

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

Base: main ← Head: fix/conversation-cache-poll-lock-20261018


📝 Commits (1)

  • 2a5d7a3 fix(serve): serialize conversation-cache log polling

📊 Changes

2 files changed (+95 additions, -0 deletions)

View changed files

📝 serve/server.py (+6 -0)
📝 serve/test_monitor.py (+89 -0)

📄 Description

Problem and result

Concurrent /metrics readers could read the same conversation-cache log range and replay an event. This change serializes access to the shared log cursor, so direct and HTTP metrics readers count each event once.

Continues #3041 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.

Closes #3039.

Approach

Guard the existing log-poll operation with the cache object's lock and add direct-reader and local loopback /metrics concurrency regressions. Cache parsing and native inference behavior are unchanged.

Validation

Rebased on upstream main 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4 (v0.2.1.4); tested candidate 2a5d7a369e8ec1deab6d0f463798bb7fe3c7e592 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_monitor.py (Ruff 0.2.1): 10 existing diagnostics, same as unmodified main; zero new diagnostics.

  • python -m unittest -v serve.test_monitor serve.test_prometheus — 18 tests passed.

  • python -m py_compile serve/server.py serve/test_monitor.py.

  • git diff --check 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4..HEAD.

Failed:

  • With the exact base production file restored, the direct concurrency test replayed the park event twice. The initial two-test run also had one environment error before the local regex dependency was installed. The subsequent fresh loopback HTTP /metrics red test failed as expected with (parks, restores) = (2, 0) instead of (1, 0).

Not run:

  • No GPU, native backend, model download, or hardware inference test.

Limits

The proof covers concurrent Python readers, the repository mock engine, and a local loopback HTTP server. It does not exercise a real model process or hardware runtime.


🔄 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/3335 **Author:** [@oscarlius](https://github.com/oscarlius) **Created:** 10/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/conversation-cache-poll-lock-20261018` --- ### 📝 Commits (1) - [`2a5d7a3`](https://github.com/Niko1221/Strata/commit/2a5d7a369e8ec1deab6d0f463798bb7fe3c7e592) fix(serve): serialize conversation-cache log polling ### 📊 Changes **2 files changed** (+95 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+6 -0) 📝 `serve/test_monitor.py` (+89 -0) </details> ### 📄 Description ## Problem and result Concurrent `/metrics` readers could read the same conversation-cache log range and replay an event. This change serializes access to the shared log cursor, so direct and HTTP metrics readers count each event once. ## Related discussion Continues #3041 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/3041#issuecomment-6282591930) explicitly suggested a new linked pull request. Closes #3039. ## Approach Guard the existing log-poll operation with the cache object's lock and add direct-reader and local loopback `/metrics` concurrency regressions. Cache parsing and native inference behavior are unchanged. ## Validation Rebased on upstream main `9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4` (v0.2.1.4); tested candidate `2a5d7a369e8ec1deab6d0f463798bb7fe3c7e592` 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_monitor.py` (Ruff 0.2.1): 10 existing diagnostics, same as unmodified main; zero new diagnostics. - `python -m unittest -v serve.test_monitor serve.test_prometheus` — 18 tests passed. - `python -m py_compile serve/server.py serve/test_monitor.py`. - `git diff --check 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4..HEAD`. **Failed:** - With the exact base production file restored, the direct concurrency test replayed the park event twice. The initial two-test run also had one environment error before the local `regex` dependency was installed. The subsequent fresh loopback HTTP `/metrics` red test failed as expected with `(parks, restores) = (2, 0)` instead of `(1, 0)`. **Not run:** - No GPU, native backend, model download, or hardware inference test. ## Limits The proof covers concurrent Python readers, the repository mock engine, and a local loopback HTTP server. It does not exercise a real model process or hardware runtime. --- <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#4574
No description provided.