-
Notifications
You must be signed in to change notification settings - Fork 9
Fix acquire timeout release lock #108
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,7 @@ func (s *Server) Acquire(ctx context.Context, req *pb.AcquireRequest) (*pb.Acqui | |
| select { | ||
| case <-ctx.Done(): | ||
| slog.InfoContext(ctx, "Acquire context cancelled", "error", ctx.Err()) | ||
| s.cancelLockRequest(ctx, groupID, jobID) | ||
| return nil, status.FromContextError(ctx.Err()).Err() | ||
| case <-ticker.C: | ||
| resp, err, done := s.checkAcquire(ctx, groupID, jobID, startTime) | ||
|
|
@@ -99,6 +100,33 @@ func (s *Server) Acquire(ctx context.Context, req *pb.AcquireRequest) (*pb.Acqui | |
| } | ||
| } | ||
|
|
||
| // cancelLockRequest undoes the lock request made by Acquire when the caller | ||
| // stops waiting, so the group is not left locked (or the job queued) for a | ||
| // caller that believes the acquire failed. | ||
| func (s *Server) cancelLockRequest(ctx context.Context, groupID, jobID string) { | ||
| // The request context is already cancelled; detach so the store updates can proceed. | ||
| ctx = context.WithoutCancel(ctx) | ||
|
|
||
| // Re-read group to get the latest status and spec from the store | ||
| group, err := s.groupStore.Get(ctx, groupID) | ||
| if err != nil { | ||
| slog.ErrorContext(ctx, "Failed to get group to cancel lock request", "error", err) | ||
| return | ||
| } | ||
|
|
||
| released, err := group.Spec().CancelLockRequest(ctx, jobID) | ||
| if err != nil { | ||
| slog.ErrorContext(ctx, "Failed to cancel lock request", "error", err) | ||
| return | ||
| } | ||
| if released { | ||
| slog.InfoContext(ctx, "Released lock held by cancelled acquire") | ||
| if s.ctrl != nil { | ||
| s.ctrl.EnqueueWork(groupID) | ||
| } | ||
| } | ||
|
Comment on lines
+117
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== Files mentioning CancelLockRequest / lockingJob / fault ==\n'
rg -n --hidden --glob '!**/.git/**' 'CancelLockRequest|lockingJob|isGroupFaulted|faulted|lease|heartbeat|reconcile|reconciler' pkg
printf '\n== Candidate files ==\n'
git ls-files 'pkg/**' | rg 'accelerator-orchestrator|group\.go|server\.go|recon|fault|lease|heartbeat'
printf '\n== Outline of server.go and likely group file(s) ==\n'
ast-grep outline pkg/accelerator-orchestrator/server/server.go --view expanded || true
fd -a 'group.go' pkg || trueRepository: llm-d-incubation/llm-d-rl-time-slicing Length of output: 20710 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== store/group.go relevant slice ==\n'
sed -n '150,320p' pkg/accelerator-orchestrator/store/group.go | cat -n
printf '\n== controller/controller.go relevant slice around reconcile and group state ==\n'
sed -n '200,520p' pkg/accelerator-orchestrator/controller/controller.go | cat -n
printf '\n== server/server.go fault handling slice ==\n'
sed -n '130,190p' pkg/accelerator-orchestrator/server/server.go | cat -nRepository: llm-d-incubation/llm-d-rl-time-slicing Length of output: 21953 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== all unlock / CancelLockRequest call sites ==\n'
rg -n --hidden --glob '!**/.git/**' 'CancelLockRequest\(|\.unlock\(|Yield\(' pkg/accelerator-orchestrator
printf '\n== lock store implementations ==\n'
sed -n '1,220p' pkg/accelerator-orchestrator/store/configmap_lockstore.go | cat -n
printf '\n---\n'
sed -n '1,140p' pkg/accelerator-orchestrator/store/lock_memstore.go | cat -n
printf '\n== server Acquire/cancel path ==\n'
sed -n '59,130p' pkg/accelerator-orchestrator/server/server.go | cat -nRepository: llm-d-incubation/llm-d-rl-time-slicing Length of output: 12468 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== controller queue / enqueue sources ==\n'
rg -n --hidden --glob '!**/.git/**' 'EnqueueWork|Run\(|NewController|workqueue|ticker|resync|periodic|reconcileAll|List\(\)' pkg/accelerator-orchestrator/controller
printf '\n== controller top-level structure ==\n'
sed -n '1,220p' pkg/accelerator-orchestrator/controller/controller.go | cat -nRepository: llm-d-incubation/llm-d-rl-time-slicing Length of output: 24740 Retry 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| func (s *Server) defaultCheckAcquire( | ||
| ctx context.Context, | ||
| groupID, jobID string, | ||
|
|
||
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.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Detached work needs a timeout
context.WithoutCancelremoves both cancellation and deadline, sogroupStore.GetandCancelLockRequestcan block indefinitely on a slow backing store while holding the group mutex. Wrap the detached context inWithTimeoutbefore calling into the store.🤖 Prompt for AI Agents