sourcegraph/migrations/codeinsights
Keegan Carruthers-Smith e93b69bef2
migrations: use COMMIT AND CHAIN for tenant_id (#64431)
We dived into our go postgres driver and when executing a migration it
is executed as a "simple query". Postgres in this case automatically
wraps the collection of statements in a transaction, unless it contains
transaction statements. So our last attempt at removing the transaction
failed.

In this attempt we use COMMIT AND CHAIN after each table alter. What
this does is commit the current transaction and then starts it up again.
From the perspective of the go driver, it is as if there was only one
transaction. We then switch the migration to using a transaction to
ensure the go drivers clean up the postgres connection in case of
failure.

IE if a query manually starts a transaction and does not clean up, the
connection will be marked as broken for the next person who gets the
connection from the pool. By wrapping in go's transaction code the
connection will be properly cleaned up.

Test Plan: All continuous environments have already succeeded or failed
on this migration number. So we will manually run this again against
them with the migrator code to ensure the same code paths. If they
succeed we will keep code as is, otherwise we will rollback.

Additionally we did lots of adhoc testing to understand the
characteristics of go and transaction handling.

Co-authored-by: Erik Seliger <erikseliger@me.com>
2024-08-13 11:59:59 +00:00
..
1000000027_squashed_migrations_privileged chore: Squash migrations (#38563) 2022-07-11 16:26:57 -05:00
1646761143_squashed_migrations_unprivileged migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1647894746_dashboard_type migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1649801281_context_filters migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1651021000_sort_series migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1652289966_deprecate-search-stream-generation-method migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1656517037_group_by migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1656608833_track_backfill_attempts migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1659572248_refresh_scoped_insights migrations: Add CI check detecting drift on downgrade (#52098) 2023-05-17 15:44:19 -05:00
1663626068_backfill_completed_at insights: Background process to stamp backfill_completed_at (#41832) 2022-09-23 18:48:36 -04:00
1664984848_insights_scheduler_table insights: skeleton queue for new scheduler (#42581) 2022-10-05 13:41:31 -07:00
1665003565_insights_backfill_scheduler_state insights: add durable repo iterator (#42676) 2022-10-10 14:13:04 -07:00
1665053848_add_insight_series_recording_times insights: save insight series recording times on creation and job runs (#42801) 2022-10-24 08:44:23 -04:00
1665616961_backfill_table insights: maintain state about backfills throughout the entire series lifecycle (#42912) 2022-10-14 12:39:38 -04:00
1666632478_add_supports_augmentation_column insights: augment series points with zero values (#43166) 2022-10-25 07:46:04 -04:00
1666729025_incomplete_points insights: extend insight series API for timeout alerts (#43452) 2022-11-09 10:56:02 -07:00
1667309737_backfill_priority_groups insights: bin backfill costs and use to prioritize backfill runs #43757 (#43758) 2022-11-01 14:20:17 -04:00
1670253074_insight_series_repo_criteria insights: db and store changes for strat scoped insights (#45624) 2022-12-13 12:45:27 -05:00
1672740238_add_insights_data_retention_jobs insights: add base for data retention worker (#46082) 2023-01-04 14:07:25 +00:00
1672917501_add_retention_tables insights: archive points for a series beyond a set sample size (#46164) 2023-01-12 10:29:40 +00:00
1672921606_data_retention_jobs_series_metadata migrations: Add CI check detecting drift on downgrade (#52098) 2023-05-17 15:44:19 -05:00
1674474174_remove_dirty_queries_table insights: remove deprecated dirty_queries table (#45714) 2023-01-23 15:58:08 +00:00
1675113463_backfill_repo_query_selector insights: add migration for code insights repo criteria query (#47133) 2023-01-30 23:11:02 +00:00
1675347548_add_insight_view_series_num_samples insights: allow to save the default number of series samples (#47329) 2023-02-08 12:24:08 +00:00
1679051112_remove_commit_index_tables insights: remove deprecated commit_index tables (#49578) 2023-03-28 09:48:45 +01:00
1719914228_insight_series_modify_query insights: persist patternType in db (#63579) 2024-07-03 09:51:48 +02:00
1723117231_add_tenants_table tenant: Ensure tenant table also exists in codeintel and codeinsights DBs (#64359) 2024-08-08 15:33:49 +02:00
1723127349_add_tenant_id_to_most_tables migrations: use COMMIT AND CHAIN for tenant_id (#64431) 2024-08-13 11:59:59 +00:00
BUILD.bazel bzl: rework migration schemas generation (#57511) 2023-10-10 17:19:47 +02:00
squashed.sql database: run tenant_id migration outside of a transaction (#64410) 2024-08-13 07:08:19 +02:00