-
Notifications
You must be signed in to change notification settings - Fork 117
Fix the StateFailed issue when calling /unload and resulting SIGTERM #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix issues with failed processes after /unload and processes that need to be removed with SIGKILL. When a Process is SIGKILL'd it will wind up in a StateFailed state due to complex interactions between various contexts and channels for managing state. The StopAndReset strategy will call Process.StopImmediately() to terminate the process and then replace it with NewProcess().
WalkthroughA new stop strategy, Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ProxyManager
participant ProcessGroup
participant Process
Client->>ProxyManager: HTTP request to unload all models
ProxyManager->>ProcessGroup: StopProcesses(StopAndReset)
loop For each process
ProcessGroup->>Process: Stop immediately
ProcessGroup->>ProcessGroup: Replace with new Process (thread-safe)
end
ProxyManager-->>Client: HTTP 200 OK ("OK")
Suggested labels
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
proxy/processgroup.go (1)
81-112: 🛠️ Refactor suggestionHolding pg.Lock while goroutines run risks blocking in-flight requests
StopProcesseskeepspg.Lock()held while the spawned goroutines execute.
If an in-flight request reachesProxyRequest(which grabspg.Lock()whenpg.swapis true) it will block, while the goroutine runningprocess.StopImmediately()proceeds.
AlthoughStopImmediatelyno longer waits for requests, the blocked request could still delay its own completion and prolong the lock.Consider:
- Copying the
pg.processesslice under the lock.- Releasing
pg.Lock()before spawning goroutines.- Using the new
processMutexonly for the actual map write.That reduces the critical-section window and avoids lock contention with live traffic.
🧹 Nitpick comments (2)
proxy/process.go (1)
33-41: Spelling / comment polishNit: “pristine” is miss-spelled as “prestine” in several added comments (
StopStrategydoc string here and inprocessgroup.go).- // stop the process and reset its state to pristine + // stop the process and reset its state to pristineproxy/processgroup.go (1)
98-99: Typo in comment- // stop all processes and replace with a new prestine Process + // stop all processes and replace with a new pristine Process
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
proxy/process.go(3 hunks)proxy/processgroup.go(2 hunks)proxy/proxymanager.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
proxy/proxymanager.go (1)
proxy/process.go (1)
StopAndReset(41-41)
proxy/processgroup.go (1)
proxy/process.go (4)
Process(44-77)StopImmediately(37-37)StopAndReset(41-41)NewProcess(80-107)
🔇 Additional comments (2)
proxy/proxymanager.go (1)
507-508: Change aligns handler with new stop strategy – looks goodSwitching to
StopAndResetensures the “/unload” endpoint both stops and refreshes all processes, matching the new behaviour added inProcessGroup.StopProcesses. No further concerns here.proxy/process.go (1)
205-217: Good addition of explicit start-error loggingThe extra
proxyLogger.Errorfgives immediate visibility whencmd.Start()fails – nice catch.
|
going to abandon this after a bit more thought. Better to clean up start/stop in Process as that should work as expected with SIGKILL, not worked around like this. |
Ref:
Summary by CodeRabbit