You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ambari.apache.org by "Jonathan Hurley (JIRA)" <ji...@apache.org> on 2016/09/15 16:08:20 UTC
[jira] [Created] (AMBARI-18404) Upgrade Summary Endpoint Throws
NPEs Due To JPA Cached Entities With Missing IDs
Jonathan Hurley created AMBARI-18404:
----------------------------------------
Summary: Upgrade Summary Endpoint Throws NPEs Due To JPA Cached Entities With Missing IDs
Key: AMBARI-18404
URL: https://issues.apache.org/jira/browse/AMBARI-18404
Project: Ambari
Issue Type: Bug
Components: ambari-server
Affects Versions: 2.4.0
Reporter: Jonathan Hurley
Assignee: Jonathan Hurley
Priority: Critical
Fix For: 2.5.0
When creating an upgrade, the {{upgrades_summary}} endpoint sometimes returns a NPE.
STR:
- Start an upgrade
- Force an error (remove {{hdp-select}})
- Wait for error in upgrade, and then make a request to {{upgrades_summary}}
{code}
HostRoleCommandEntity mostRecentFailure = s_hostRoleCommandDAO.findMostRecentFailure(upgradeRequestId);
{code}
And its requestId is null
DB is fine
{code}
ambari=> select request_id, task_id, status, role, role_command, custom_command_name from host_role_command where task_id = 504;
request_id | task_id | status | role | role_command | custom_command_name
------------+---------+------------------+-------------+----------------+---------------------
45 | 504 | HOLDING_TIMEDOUT | NODEMANAGER | CUSTOM_COMMAND | STOP
(1 row)
{code}
Problem is with query,
{code}
TypedQuery<HostRoleCommandEntity> query = entityManagerProvider.get().createNamedQuery(
"HostRoleCommandEntity.findTasksByStatusesOrderByIdDesc", HostRoleCommandEntity.class);
query.setParameter("requestId", requestId);
query.setParameter("statuses", HostRoleStatus.STACK_UPGRADE_FAILED_STATUSES);
List<HostRoleCommandEntity> results = query.getResultList();
...
HostRoleCommandEntity candidate = results.get(0);
{code}
since "candidate" has no requestId.
However, HostRoleCommandEntity.java defines the query like so,
{code}
@NamedQuery(name = "HostRoleCommandEntity.findTasksByStatusesOrderByIdDesc", query = "SELECT task FROM HostRoleCommandEntity task WHERE task.requestId = :requestId AND task.status IN :statuses ORDER BY task.taskId DESC"),
{code}
so the "task" object should have a request_id, especially since it's defined to be non-nullable,
{code}
@Column(name = "request_id", insertable = false, updatable = false, nullable = false)
@Basic
private Long requestId;
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)