Database saved audit events must stream with primary key id
What does this MR do and why?
Currently we are streaming database saved audit events containing id as created_at.to_i
this is happening because
audit events are saved using bulk_insert and events present in memory doesn't reload and does not contain primary key id as they are not ActiveRecord
.
This MR fixes this by using bulk_insert
to return ids of saved objects and reload these events using these ids.
How to set up and validate locally
- Setup streaming audit event destination https://docs.gitlab.com/ee/administration/audit_event_streaming.html#use-the-gitlab-ui
- Create audit event example project download using zip download button from project page.
On master
branch:
- Check audit_json.log, it will contain log which will have id: null
- Check streamed audit event it will contain id not matching database saved id as this is timestamp of audit event created_at.
On this branch:
- Check audit_json.log, it will contain log which will have id of audit event created.
- Check streamed audit event it will contain id of audit event created.
on both the branches stream only audit events will contain id as created_at.to_i
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #381533 (closed)
Edited by Harsimar Sandhu