Skip to content

fix: improve async safety in routers and Redis KV reads - #5800

Merged
franciscojavierarceo merged 8 commits into
ogx-ai:mainfrom
leseb:Looking-at-the-attached-text-to-determine-the-task
May 12, 2026
Merged

fix: improve async safety in routers and Redis KV reads#5800
franciscojavierarceo merged 8 commits into
ogx-ai:mainfrom
leseb:Looking-at-the-attached-text-to-determine-the-task

Conversation

@leseb

@leseb leseb commented May 12, 2026

Copy link
Copy Markdown
Member

What does this PR do?

This PR hardens async behavior in router/storage paths and removes an unnecessary Redis read round-trip. It adds done-callback error logging for fire-and-forget chat completion persistence tasks in the inference router. It snapshots provider implementation maps before health-check iteration to avoid RuntimeError from concurrent dict mutation. It also removes an unused ttl call from Redis KV get().

Test Plan

uv run pytest tests/unit/core/routers/test_inference_router.py tests/unit/core/routers/test_vector_io.py -q
Result: 12 passed in 0.47s.

uv run pytest tests/unit/utils/kvstore -q
Result: 60 passed, 3 xfailed in 0.44s.

leseb added 4 commits May 12, 2026 12:53
The get() method called await client.ttl(key) but discarded the result,
adding an unnecessary round-trip to Redis on every read operation.

Signed-off-by: Sébastien Han <seb@redhat.com>
…orage

Replace bare asyncio.create_task() calls with the existing
create_detached_background_task() utility which properly detaches
request-scoped context (OTel traces, auth identity) and adds error
logging via done callbacks.

Signed-off-by: Sébastien Han <seb@redhat.com>
… checks

Create a shallow copy of impls_by_provider_id before iterating to
prevent RuntimeError if the routing table refreshes concurrently.

Signed-off-by: Sébastien Han <seb@redhat.com>
Replace bare asyncio.create_task() calls with task + done callback
so that errors in background store_chat_completion() are logged
instead of silently swallowed. Keeps request context (OTel trace,
auth identity) intact for observability.

Signed-off-by: Sébastien Han <seb@redhat.com>
@mergify

mergify Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be merged. @leseb please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label May 12, 2026
leseb added 2 commits May 12, 2026 17:53
…ed-text-to-determine-the-task

Signed-off-by: Sébastien Han <seb@redhat.com>
@mergify mergify Bot removed the needs-rebase label May 12, 2026
@franciscojavierarceo
franciscojavierarceo added this pull request to the merge queue May 12, 2026
Merged via the queue into ogx-ai:main with commit 028c2f2 May 12, 2026
39 checks passed
@leseb
leseb deleted the Looking-at-the-attached-text-to-determine-the-task branch May 13, 2026 07:32
@leseb

leseb commented May 13, 2026

Copy link
Copy Markdown
Member Author

@Mergifyio backport release-1.0.x

@mergify

mergify Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

backport release-1.0.x

✅ Backports have been created

Details

eoinfennessy pushed a commit to opendatahub-io/ogx that referenced this pull request May 14, 2026
…-ai#5800) (ogx-ai#5823)

# What does this PR do?
This PR hardens async behavior in router/storage paths and removes an
unnecessary Redis read round-trip. It adds done-callback error logging
for fire-and-forget chat completion persistence tasks in the inference
router. It snapshots provider implementation maps before health-check
iteration to avoid `RuntimeError` from concurrent dict mutation. It also
removes an unused `ttl` call from Redis KV `get()`.

## Test Plan
`uv run pytest tests/unit/core/routers/test_inference_router.py
tests/unit/core/routers/test_vector_io.py -q`
Result: `12 passed in 0.47s`.

`uv run pytest tests/unit/utils/kvstore -q`
Result: `60 passed, 3 xfailed in 0.44s`.
<hr>This is an automatic backport of pull request ogx-ai#5800 done by
[Mergify](https://mergify.com).

Signed-off-by: Sébastien Han <seb@redhat.com>
Co-authored-by: Sébastien Han <seb@redhat.com>
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.

3 participants