Drop updated_at column on audit_events
Problem to solve
Audit events should be append-only. The updated_at
field is redundant and can be dropped to save storage spaces and reduce query payload.
Proposal
Drop updated_at
column from audit_events
table.
This change will be more likely to be spread across multiple releases (https://docs.gitlab.com/ee/development/what_requires_downtime.html#dropping-columns)
-
13.2: Ignore
updated_at
column and stop all writes -
13.3: Remove
updated_at
column onaudit_events
-
13.4: Clean up ignore column code in
AuditEvent
model
Further details
This will shave a shy (242,000,000 mil records * 8 bytes) in Gb = 2.2352 Gb
- https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/9226#master-1022016106-18
- https://www.postgresql.org/docs/11/datatype-datetime.html
Availability & Testing
There is no known consumer of this field. Both UI and API only allow querying and presenting of created_at
field.
Require collaboration with groupdatabase to understand if there is any risk.
Designs
- Show closed items
Relates to
- gitlab-org/foundations/general-discussion #17236
- gitlab-org/foundations/general-discussion #17265
Related merge requests 5
When these merge requests are accepted, this issue will be closed automatically.
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- 🤖 GitLab Bot 🤖 added [deprecated] Accepting merge requests label
added [deprecated] Accepting merge requests label
- Tan Le changed the description
Compare with previous version changed the description
- Developer
Good call @tancnle , let's remove it!
As you pointed out already, we'll need to spread this out across releases. First step would be to ignore the column in ActiveRecord.
Thinking that in general, we might also be able to incorporate this change into a larger refactoring (if/when we end up doing that). There's no harm in starting down the standard ignore/drop/unignore route to just drop the column though.
We currently have 300M records in
audit_events
. I think this would boil down to about 2.2 GB (unless my math is broken) of savings. In any case that's worth doing!There is only exactly one record with
created_at <> updated_at
on GitLab.com. Collapse replies
- Developer
@tancnle Umh, I think that's the right approach (number of records * 8 bytes). I just end up with a different result:
300,000,000 * 8 bytes = 2400000000 bytes => about 2.2 GiB
300*10**6 * 8 / (1024.0**3) => 2.2351741790771484
I wouldn't be surprised if my basic math is flawed for some reason, so please let me know.
Collapse replies
- Tan Le changed the description
Compare with previous version changed the description
- Andreas Brandl mentioned in issue #217471 (closed)
mentioned in issue #217471 (closed)
- Dan Jensen marked this issue as related to #215717 (closed)
marked this issue as related to #215717 (closed)
- Tan Le mentioned in merge request !34156 (merged)
mentioned in merge request !34156 (merged)
- Tan Le mentioned in merge request !35690 (merged)
mentioned in merge request !35690 (merged)
- 🤖 GitLab Bot 🤖 removed [deprecated] Accepting merge requests label
removed [deprecated] Accepting merge requests label
- Tan Le mentioned in merge request !35697 (merged)
mentioned in merge request !35697 (merged)
- Matt Gonzales (ex-GitLab) mentioned in issue gitlab-org/manage/general-discussion#17236
mentioned in issue gitlab-org/manage/general-discussion#17236
- Matt Gonzales (ex-GitLab) marked this issue as related to gitlab-org/manage/general-discussion#17236
marked this issue as related to gitlab-org/manage/general-discussion#17236
- Tan Le added workflowin dev label and removed workflowsolution validation label
added workflowin dev label and removed workflowsolution validation label
- Dan Jensen set weight to 1
set weight to 1
- Tan Le changed the description
Compare with previous version changed the description
- Tan Le marked the checklist item Ignore
updated_at
column and stop all writes as completedmarked the checklist item Ignore
updated_at
column and stop all writes as completed - Tan Le marked the checklist item Remove
updated_at
column onaudit_events
as completedmarked the checklist item Remove
updated_at
column onaudit_events
as completed - Tan Le changed the description
Compare with previous version changed the description
- Tan Le set weight to 5
set weight to 5
- Tan Le set weight to 3
set weight to 3
- Matt Gonzales (ex-GitLab) mentioned in issue gitlab-org/manage/general-discussion#17265
mentioned in issue gitlab-org/manage/general-discussion#17265
- Matt Gonzales (ex-GitLab) added Deliverable label
added Deliverable label
- Matt Gonzales (ex-GitLab) marked this issue as related to gitlab-org/manage/general-discussion#17265
marked this issue as related to gitlab-org/manage/general-discussion#17265
- 🤖 GitLab Bot 🤖 added sectiondev label
added sectiondev label
- Tan Le mentioned in merge request !40249 (merged)
mentioned in merge request !40249 (merged)
- Sean McGivern closed with merge request !40249 (merged)
closed with merge request !40249 (merged)
- Sean McGivern mentioned in commit ae81cd5d
mentioned in commit ae81cd5d
- Tan Le marked the checklist item 13.4: Clean up ignore column code in
AuditEvent
model as completedmarked the checklist item 13.4: Clean up ignore column code in
AuditEvent
model as completed - 🤖 GitLab Bot 🤖 mentioned in issue gl-retrospectives/manage#51 (closed)
mentioned in issue gl-retrospectives/manage#51 (closed)
- Tan Le mentioned in merge request !43703 (merged)
mentioned in merge request !43703 (merged)