Skip to content

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

  1. Setup streaming audit event destination https://docs.gitlab.com/ee/administration/audit_event_streaming.html#use-the-gitlab-ui
  2. Create audit event example project download using zip download button from project page.

On master branch:

  1. Check audit_json.log, it will contain log which will have id: null
  2. 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:

  1. Check audit_json.log, it will contain log which will have id of audit event created.
  2. 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.

Related to #381533 (closed)

Edited by Harsimar Sandhu

Merge request reports

Loading