Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
2.4.0
-
None
Description
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
HostRoleCommandEntity mostRecentFailure = s_hostRoleCommandDAO.findMostRecentFailure(upgradeRequestId);
And its requestId is null
DB is fine
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)
Problem is with query,
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);
since "candidate" has no requestId.
However, HostRoleCommandEntity.java defines the query like so,
@NamedQuery(name = "HostRoleCommandEntity.findTasksByStatusesOrderByIdDesc", query = "SELECT task FROM HostRoleCommandEntity task WHERE task.requestId = :requestId AND task.status IN :statuses ORDER BY task.taskId DESC"),
so the "task" object should have a request_id, especially since it's defined to be non-nullable,
@Column(name = "request_id", insertable = false, updatable = false, nullable = false) @Basic private Long requestId;