sourcegraph/migrations/codeintel
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
..
1000000033_squashed_migrations_privileged chore: Squash migrations (#38563) 2022-07-11 16:26:57 -05:00
1000000034_squashed_migrations_unprivileged migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1665531314_remove_api_docs_tables migrations: Add CI check detecting drift on downgrade (#52098) 2023-05-17 15:44:19 -05:00
1666727108_add_codeintel_last_reconcile_table codeintel: Create background job to reconcile abandoned uploads (#43443) 2022-10-31 13:21:28 -05:00
1669075922_add_scip_tables codeintel: Fix asymmetric down migration (#45025) 2022-12-01 17:48:04 -06:00
1669842405_add_additional_metadata_fields codeintel: Add additional metadata fields to SCIP tables (#44971) 2022-11-30 23:42:42 +00:00
1669934289_add_scip_document_schema_versions_table codeintel: Fix migration comment and add missing function (#45031) 2022-12-01 17:25:13 -06:00
1670001463_add_missing_index_for_cascading_deletes codeintel: Add index on SCIP table to speed up cascading deletes (#45092) 2022-12-02 19:13:48 +00:00
1670363942_fix_scip_schema_version_triggers codeintel: Fix bad SCIP schema version triggers (#45300) 2022-12-06 22:47:40 +00:00
1670365552_fix_scip_document_schema_counting migrations: Add CI check detecting drift on downgrade (#52098) 2023-05-17 15:44:19 -05:00
1670370058_process_unreferenced_documents codeintel: Tombstone SCIP documents after last use (#45308) 2022-12-09 12:22:32 -06:00
1670881409_fix_scip_document_schema_counting_again codeintel: Improve document schema version tracking (#45587) 2022-12-13 16:46:43 +00:00
1670940342_add_codeintel_scip_symbol_names_table codeintel: Trie-encode SCIP symbol names (#45592) 2022-12-14 09:24:32 -06:00
1670967960_add_codeintel_scip_symbol_names_indexes codeintel: Trie-encode SCIP symbol names (#45592) 2022-12-14 09:24:32 -06:00
1671059396_remove_duplicate_trigger codeintel: Clean up triggers (#45681) 2022-12-15 08:58:38 -06:00
1676423214_remove_lsif_data LSIF: Remove tables from schema (#46127) 2023-03-02 01:25:42 +00:00
1678041507_cleanup_unused_functions chore: Remove unreferenced LSIF trigger functions (#48690) 2023-03-06 07:37:47 -06:00
1678898749_make_unreferenced_documents_index_usable Codeintel: Make index usable (#49440) 2023-03-15 14:03:57 -06:00
1678899132_remove_unused_unreferenced_documents_index Codeintel: Make index usable (#49440) 2023-03-15 14:03:57 -06:00
1679010276_add_missing_index codeintel: Fix missing index (#49565) 2023-03-16 19:10:45 -05:00
1686315964_clean_out_schema_versions_tables codeintel: Fix cleaning up metadata tables in codeintel-db (#53232) 2023-06-16 17:46:07 +00:00
1723117227_add_tenants_table tenant: Ensure tenant table also exists in codeintel and codeinsights DBs (#64359) 2024-08-08 15:33:49 +02:00
1723127341_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