Skip to content

Commit

Permalink
Fix: increase heartbeat frequency (#806)
Browse files Browse the repository at this point in the history
There may be a possible race condition here since the timing of the
expiry and the interval are so close together.
  • Loading branch information
luke-lombardi authored Dec 20, 2024
1 parent 3fcfeca commit b6a885a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/abstractions/endpoint/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,15 @@ func (rb *RequestBuffer) heartBeat(req *request, containerId string) {
ticker := time.NewTicker(endpointRequestHeartbeatInterval)
defer ticker.Stop()

rb.rdb.Set(rb.ctx, Keys.endpointRequestHeartbeat(rb.workspace.Name, rb.stubId, req.task.msg.TaskId, containerId), 1, endpointRequestHeartbeatInterval)
rb.rdb.Set(rb.ctx, Keys.endpointRequestHeartbeat(rb.workspace.Name, rb.stubId, req.task.msg.TaskId, containerId), 1, endpointRequestHeartbeatKeepAlive)
for {
select {
case <-ctx.Done():
return
case <-rb.ctx.Done():
return
case <-ticker.C:
rb.rdb.Set(rb.ctx, Keys.endpointRequestHeartbeat(rb.workspace.Name, rb.stubId, req.task.msg.TaskId, containerId), 1, endpointRequestHeartbeatInterval)
rb.rdb.Set(rb.ctx, Keys.endpointRequestHeartbeat(rb.workspace.Name, rb.stubId, req.task.msg.TaskId, containerId), 1, endpointRequestHeartbeatKeepAlive)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/abstractions/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ var (
endpointRoutePrefix string = "/endpoint"
endpointServeContainerTimeout time.Duration = 10 * time.Minute
endpointServeContainerKeepaliveInterval time.Duration = 30 * time.Second
endpointRequestHeartbeatInterval time.Duration = 30 * time.Second
endpointRequestHeartbeatInterval time.Duration = 5 * time.Second
endpointRequestHeartbeatKeepAlive time.Duration = 30 * time.Second
endpointMinRequestBufferSize int = 10
)

Expand Down

0 comments on commit b6a885a

Please sign in to comment.