Skip to content

Fix #65176: Auto-terminate live gateway on platform lock conflict - #65218

Closed
AllardQuek wants to merge 1 commit into
NousResearch:mainfrom
AllardQuek:fix/platform-lock-auto-terminate-65176
Closed

AllardQuek wants to merge 1 commit into
NousResearch:mainfrom
AllardQuek:fix/platform-lock-auto-terminate-65176

Conversation

@AllardQuek

Copy link
Copy Markdown
Contributor

When a new gateway detects a platform lock conflict (e.g. Telegram bot token already in use) and the holder is a live gateway process, it now terminates the holder and retries the lock acquisition instead of retrying indefinitely with a fatal error.

This mirrors the --replace behavior but applies it at platform-connect time when the scoped token lock detects a conflict, resolving the issue where the gateway would wait for manual SIGKILL of the conflicting process.

Changes:

  • gateway/platforms/base.py: Modified _acquire_platform_lock() to detect live gateway holders via _looks_like_gateway_process(), write takeover marker, force-terminate with terminate_pid(), wait 0.5s, and retry lock acquisition. Falls back to fatal error only if retry still fails.
  • tests/gateway/test_platform_lock_auto_terminate.py: New test file with three test cases covering termination of live gateway holders, non-termination of non-gateway holders, and fallback to fatal error when termination fails.

@AllardQuek
AllardQuek force-pushed the fix/platform-lock-auto-terminate-65176 branch from 96dd0bf to a1d2683 Compare July 15, 2026 21:16
…conflict

When a new gateway detects a platform lock conflict (e.g. Telegram bot token
already in use) and the holder is a live gateway process, it now terminates
the holder and retries the lock acquisition instead of retrying indefinitely
with a fatal error.

This mirrors the --replace behavior but applies it at platform-connect time
when the scoped token lock detects a conflict, resolving the issue where the
gateway would wait for manual SIGKILL of the conflicting process.

Changes:
- gateway/platforms/base.py: Modified _acquire_platform_lock() to detect
  live gateway holders via _looks_like_gateway_process(), write takeover
  marker, force-terminate with terminate_pid(), wait 0.5s, and retry lock
  acquisition. Falls back to fatal error only if retry still fails.
- tests/gateway/test_platform_lock_auto_terminate.py: New test file with
  three test cases covering termination of live gateway holders, non-termination
  of non-gateway holders, and fallback to fatal error when termination fails.
@AllardQuek
AllardQuek force-pushed the fix/platform-lock-auto-terminate-65176 branch from a1d2683 to dded554 Compare July 15, 2026 21:18
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages needs-decision Awaiting maintainer decision before any implementation duplicate This issue or pull request already exists labels Jul 15, 2026
@alt-glitch

Copy link
Copy Markdown

This was generated by AI during triage.

Duplicate of #65178: both implement adapter-level takeover of a live scoped platform-lock holder for #65176. #65178 is the earlier open implementation and includes explicit ownership/identity safeguards; this PR should be considered there instead.

@AllardQuek AllardQuek closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists needs-decision Awaiting maintainer decision before any implementation P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants