The backend currently executes query event hooks during ImpalaServer::UnregisterQuery, which may actually only happen a long time after the query has actually executed. We depend on either the client closing the query/session, the client's connection dropping, or an idle session timing out.
e.g. the following sequence is possible.
- User executes query from Hue.
- User goes home for weekend, leaving Hue tab open in browser
- If we're lucky, the session timeout expires after some amount of idle time.
- The query gets unregistered, hooks get executed
It would generally be desirable to move the lineage logger earlier in the query lifecycle, so it occurs as soon as all of the required data is available.