Skip to content

Fail in-progress jobs when the worker running them exits abnormally #277

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

Merged
merged 5 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove process's name from metadata and add it to instrumentation events
  • Loading branch information
rosa committed Aug 21, 2024
commit cb5669ff43f99d8412c7b8af99b4eeb00378cfdb
11 changes: 7 additions & 4 deletions lib/solid_queue/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def start_process(event)
attributes = {
pid: process.pid,
hostname: process.hostname,
process_id: process.process_id
process_id: process.process_id,
name: process.name
}.merge(process.metadata)

info formatted_event(event, action: "Started #{process.kind}", **attributes)
Expand All @@ -75,15 +76,16 @@ def shutdown_process(event)
attributes = {
pid: process.pid,
hostname: process.hostname,
process_id: process.process_id
process_id: process.process_id,
name: process.name
}.merge(process.metadata)

info formatted_event(event, action: "Shutdown #{process.kind}", **attributes)
end

def register_process(event)
process_kind = event.payload[:kind]
attributes = event.payload.slice(:pid, :hostname, :process_id)
attributes = event.payload.slice(:pid, :hostname, :process_id, :name)

if error = event.payload[:error]
warn formatted_event(event, action: "Error registering #{process_kind}", **attributes.merge(error: formatted_error(error)))
Expand All @@ -99,6 +101,7 @@ def deregister_process(event)
process_id: process.id,
pid: process.pid,
hostname: process.hostname,
name: process.name,
last_heartbeat_at: process.last_heartbeat_at.iso8601,
claimed_size: event.payload[:claimed_size],
pruned: event.payload[:pruned]
Expand Down Expand Up @@ -147,7 +150,7 @@ def replace_fork(event)
termsig: status.termsig

if replaced_fork = event.payload[:fork]
info formatted_event(event, action: "Replaced terminated #{replaced_fork.kind}", **attributes.merge(hostname: replaced_fork.hostname))
info formatted_event(event, action: "Replaced terminated #{replaced_fork.kind}", **attributes.merge(hostname: replaced_fork.hostname, name: replaced_fork.name))
else
warn formatted_event(event, action: "Tried to replace forked process but it had already died", **attributes)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/solid_queue/processes/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def pid
end

def metadata
{ name: name }
{}
end

private
Expand Down
2 changes: 1 addition & 1 deletion test/unit/log_subscriber_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def set_logger(logger)
attach_log_subscriber
instrument "deregister_process.solid_queue", process: process, pruned: false, claimed_size: 0

assert_match_logged :info, "Deregister Worker", "process_id: #{process.id}, pid: 42, hostname: \"localhost\", last_heartbeat_at: \"#{last_heartbeat_at}\", claimed_size: 0, pruned: false"
assert_match_logged :info, "Deregister Worker", "process_id: #{process.id}, pid: 42, hostname: \"localhost\", name: \"worker-123\", last_heartbeat_at: \"#{last_heartbeat_at}\", claimed_size: 0, pruned: false"
end

private
Expand Down