Summary:
When an inbound call is created, we create the wait state in it's constructor,
but the wait state code was previously initialized to `kUnused`, which had the
value 0xFFFFFFFFU.
The stack trace suggests that the wait event component is being passed as NULL
```
frame #1: 0x0000aaaab2ffd680 postgres`yb_active_session_history [inlined] cstring_to_text(s=0x0000000000000000) at varlena.c:190:37
frame #2: 0x0000aaaab2ffd67c postgres`yb_active_session_history(fcinfo=<unavailable>) at yb_ash.c:1055:4
...
```
The component should be one of the following, otherwise it is returned as NULL
```
YB_DEFINE_TYPED_ENUM(Component, uint8_t,
(kYSQL)
(kYCQL)
(kTServer)
(kMaster));
template <class Enum>
const char* NoPrefixName(Enum value) {
const char* name = ToCString(value);
if (!name) {
DCHECK(false);
return nullptr;
}
return name + 1;
}
const char* YBCGetWaitEventComponent(uint32_t wait_event_info) {
// The highest 4 bits are needed to get the wait event component
uint8_t comp_id = narrow_cast<uint8_t>(wait_event_info >> YB_ASH_COMPONENT_POSITION);
return NoPrefixName(static_cast<ash::Component>(comp_id));
}
```
The component in kUnused is 0xFF which is not one in the above list. So this is returned as NULL
which results in segmentation fault.
The likely cause is that the RPC is sampled between creating and intiializing the wait state, so the
code is returned as kUnused.
This diff removes the kUnused state and instead initializes the wait state to kIdle, which is
ignored when sampling wait events.
Also, don't return NULL when the wait event, component, class, type cannot be found, and enhance
the DCHECK with a log line.
Jira: DB-17982
Test Plan: Jenkins
Reviewers: amitanand, ishan.chhangani, cagrawal
Reviewed By: amitanand
Subscribers: yql
Differential Revision: https://phorge.dev.yugabyte.com/D46146