Skip to content
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

Check stv_inflight for query PID for redshift cancel #375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/blazer/adapters/sql_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def cancel(run_id)
if postgresql?
select_all("SELECT pg_cancel_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND query LIKE ?", ["%,run_id:#{run_id}%"])
elsif redshift?
first_row = select_all("SELECT pid FROM stv_recents WHERE status = 'Running' AND query LIKE ?", ["%,run_id:#{run_id}%"]).first
run_text = "%,run_id:#{run_id}%"
first_row = select_all("SELECT pid FROM stv_recents WHERE status = 'Running' AND query LIKE ? UNION SELECT pid FROM stv_inflight WHERE text LIKE ?", [run_text, run_text]).first
if first_row
select_all("CANCEL #{first_row["pid"].to_i}")
end
Expand Down