andrey filatov activity https://gitlab.com/FIL0003 2026-03-13T10:24:46Z tag:gitlab.com,2026-03-13:5200658824 andrey filatov commented on issue #592642 at GitLab.org / GitLab 2026-03-13T10:24:46Z FIL0003 andrey filatov

@emmaspark I'm not 100% sure this is correct, but based on the PostgreSQL logs I captured, here's what I observed:

The trigger fires on the first INSERT of the day, not on duplicates.

Here's the flow in find_or_create_project_daily_statistic:

  1. find_by(project_id, date) — SELECT, if row exists → return it, no INSERT, trigger never fires
  2. If no row → upsert with ON CONFLICT (project_id, date) DO NOTHING → actual INSERT → trigger fires

So on_duplicate: :skip only protects against a race condition where two concurrent requests try to insert the same row simultaneously. The trigger always fires on the first daily INSERT, where there's no conflict in project_daily_statistics.

The bug: after the table swap in !211916 (merged), project_daily_statistics_archived already contains the row for (project_id, date) (it's the original pre-swap table with all historical data). So the trigger's plain INSERT into _archived hits a UniqueViolation.

TL;DR: a conflict between the swap (!211916 (merged)) which already populated _archived with the row, and the trigger which tries to insert the same row again on the first git fetch of the day.

tag:gitlab.com,2026-03-07:5177265684 andrey filatov commented on issue #592642 at GitLab.org / GitLab 2026-03-07T00:20:35Z FIL0003 andrey filatov

@gitlab-bot label typebug

tag:gitlab.com,2026-03-07:5177237705 andrey filatov opened issue #592642: 18.8: table_sync_function causes PG::UniqueViolation on git-upload-pack, breaking all CI pipelines after first run per d... 2026-03-07T00:04:25Z FIL0003 andrey filatov