Skip to content

fix: honor explicit IPC names#379

Open
shipiyouniao wants to merge 1 commit into
ovg-project:mainfrom
shipiyouniao:fix/explicit-ipc-name
Open

fix: honor explicit IPC names#379
shipiyouniao wants to merge 1 commit into
ovg-project:mainfrom
shipiyouniao:fix/explicit-ipc-name

Conversation

@shipiyouniao

Copy link
Copy Markdown

Summary

Fixes #378.

Treat KVCACHED_IPC_NAME as an exact IPC namespace when it is explicitly set. The generated-name path still keeps the existing uniqueness probing.

Why

The explicit env var is used as a process coordination contract. If kvcached auto-suffixes it after the segment already exists, later workers can join a different namespace than the process that created the segment.

Tests

python -m pytest tests/test_ipc_name.py -q
python -m py_compile kvcached/utils.py tests/test_ipc_name.py

Copilot AI review requested due to automatic review settings July 2, 2026 06:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Issue #378 by making KVCACHED_IPC_NAME an exact (sanitized) IPC namespace when explicitly set, avoiding any auto-suffixing/uniqueness probing that could cause later workers to join a different shared-memory namespace.

Changes:

  • Update _obtain_default_ipc_name() to immediately return the sanitized explicit KVCACHED_IPC_NAME without probing/suffixing.
  • Add a unit test covering the explicit-name path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/test_ipc_name.py Adds a regression test for treating an explicit IPC name as exact.
kvcached/utils.py Removes uniqueness probing/suffixing when KVCACHED_IPC_NAME is explicitly set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kvcached/utils.py Outdated
Comment on lines +65 to +69
explicit = os.getenv("KVCACHED_IPC_NAME")
if explicit:
preferred = _sanitize_segment(explicit)

if not _ipc_segment_exists(preferred):
return preferred

base_candidate = f"{preferred}_{engine_tag}_{group_id}"
if not _ipc_segment_exists(base_candidate):
return base_candidate
# As a last resort, append a small numeric suffix until unique
for i in range(1, 100):
candidate = f"{base_candidate}_{i}"
if not _ipc_segment_exists(candidate):
return candidate
# If everything somehow exists, fall back to PID-specific name
return f"{base_candidate}_{os.getpid()}"
# An explicit IPC name is a contract between all processes in one
# serving instance. Do not auto-suffix it when the segment already
# exists: late-importing TP workers must still join the same namespace,
Comment thread tests/test_ipc_name.py
Comment on lines +14 to +16
monkeypatch.setenv("KVCACHED_IPC_NAME", "shared-instance-ipc")
monkeypatch.setattr(utils, "_ipc_segment_exists", lambda name: True)

@shipiyouniao shipiyouniao force-pushed the fix/explicit-ipc-name branch from 785b5c8 to 27f7aa9 Compare July 2, 2026 08:19
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.

Explicit KVCACHED_IPC_NAME should not be auto-suffixed

2 participants