Fixes issue in retry logic for bus events when using inflightQ.

The issue was in the update of the new row (for the retry) where the id (re)inserted into the inflightQ was wrong.
Also fixed the insertion into the history tables so that they keep the same record_id (much easier for debug investigation)