Bug 1779653

Summary: Searching for tasks fails with PG::AmbiguousColumn: ERROR: ORDER BY "started_at" is ambiguous
Product: Red Hat Satellite Reporter: Adam Ruzicka <aruzicka>
Component: Tasks PluginAssignee: Adam Ruzicka <aruzicka>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.4CC: aruzicka, egolov, inecas
Target Milestone: 6.7.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-foreman-tasks-0.17.4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-14 13:27:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Adam Ruzicka 2019-12-04 13:02:52 UTC
2019-12-03T10:21:14 [D|app|aec885e2] Backtrace for 'Action failed' error (ActiveRecord::StatementInvalid): PG::AmbiguousColumn: ERROR:  ORDER BY "started_at" is ambiguous                                                                  
 | LINE 1: ...,4)) WHERE (("users"."login" = 'admin')) ORDER BY started_at...                                                                                                                                                               
 |                                                              ^                                                                                                                                                                           
 | : SELECT  DISTINCT foreman_tasks_tasks.*, *, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration, "foreman_tasks_tasks"."id" AS t0_r0, "foreman_tasks_tasks"."type" AS t0_r1,
 "foreman_tasks_tasks"."label" AS t0_r2, "foreman_tasks_tasks"."started_at" AS t0_r3, "foreman_tasks_tasks"."ended_at" AS t0_r4, "foreman_tasks_tasks"."state" AS t0_r5, "foreman_tasks_tasks"."result" AS t0_r6, "foreman_tasks_tasks"."ext
ernal_id" AS t0_r7, "foreman_tasks_tasks"."parent_task_id" AS t0_r8, "foreman_tasks_tasks"."start_at" AS t0_r9, "foreman_tasks_tasks"."start_before" AS t0_r10, "foreman_tasks_tasks"."action" AS t0_r11, "foreman_tasks_tasks"."user_id" AS
 t0_r12, "foreman_tasks_tasks"."state_updated_at" AS t0_r13, "users"."id" AS t1_r0, "users"."login" AS t1_r1, "users"."firstname" AS t1_r2, "users"."lastname" AS t1_r3, "users"."mail" AS t1_r4, "users"."admin" AS t1_r5, "users"."last_l$
gin_on" AS t1_r6, "users"."auth_source_id" AS t1_r7, "users"."created_at" AS t1_r8, "users"."updated_at" AS t1_r9, "users"."password_hash" AS t1_r10, "users"."password_salt" AS t1_r11, "users"."locale" AS t1_r12, "users"."avatar_hash" $
S t1_r13, "users"."default_organization_id" AS t1_r14, "users"."default_location_id" AS t1_r15, "users"."lower_login" AS t1_r16, "users"."mail_enabled" AS t1_r17, "users"."timezone" AS t1_r18, "users"."description" AS t1_r19 FROM "fore$
an_tasks_tasks" LEFT OUTER JOIN "users" ON "users"."id" = "foreman_tasks_tasks"."user_id" AND (users.id IN (1,2,3,4,2,4,1,3,4)) WHERE (("users"."login" = 'admin')) ORDER BY started_at DESC LIMIT $1 OFFSET $2
-----B<-----SNIP-----B<-----
 | /home/aruzicka/projects/foreman/foreman-tasks/app/controllers/foreman_tasks/api/tasks_controller.rb:299:in `map'                                                                                                                         
 | /home/aruzicka/projects/foreman/foreman-tasks/app/controllers/foreman_tasks/api/tasks_controller.rb:299:in `tasks_list'
-----B<-----SNIP-----B<-----

If you sort by duration, the search for "user = admin" should work.

Comment 1 Adam Ruzicka 2019-12-04 13:02:57 UTC
Created from redmine issue https://projects.theforeman.org/issues/28415

Comment 2 Adam Ruzicka 2019-12-04 13:03:00 UTC
Upstream bug assigned to aruzicka

Comment 4 Bryan Kearney 2019-12-05 19:03:41 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/28415 has been resolved.

Comment 5 Peter Ondrejka 2020-01-03 10:36:59 UTC
Verified on Sat 6.7 snap 7

Comment 8 errata-xmlrpc 2020-04-14 13:27:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:1454