Create pipeline sync events for ClickHouse
What does this MR do and why?
This MR builds on Create p_ci_finished_pipeline_ch_sync_events table (!158060) to start creating pipeline sync events as pipelines enter an unlockable state, at which point we want to start syncing them to ClickHouse from the Ci::FinishedPipelineChSyncEvent
queue. It is important to only do this when we don't expect more significant changes to a pipeline, since we treat ClickHouse as a (mostly) immutable database.
Part of #470078
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Run any pipeline in a GDK project. Once it completes, a new Ci::FinishedPipelineChSyncEvent
record should be present in the database:
> Ci::FinishedPipelineChSyncEvent.pending.count
=> 1
Database query plan
Upsert
https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/29664/commands/92096
INSERT INTO "p_ci_finished_pipeline_ch_sync_events" ("pipeline_id", "pipeline_finished_at", "project_namespace_id")
VALUES (1805209, '2024-05-25 06:28:42.584935', 80)
ON CONFLICT ("pipeline_id", "partition")
DO UPDATE SET
"pipeline_finished_at" = excluded."pipeline_finished_at", "project_namespace_id" = excluded."project_namespace_id"
RETURNING "pipeline_id", "partition"
ModifyTable on public.p_ci_finished_pipeline_ch_sync_events (cost=0.00..0.01 rows=1 width=33) (actual time=0.501..0.502 rows=1 loops=1)
Buffers: shared hit=107 dirtied=5
I/O Timings: read=0.000 write=0.000
-> Result (cost=0.00..0.01 rows=1 width=33) (actual time=0.001..0.001 rows=1 loops=1)
I/O Timings: read=0.000 write=0.000