mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 18:31:54 +00:00
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> |
||
|---|---|---|
| .. | ||
| 1000000033_squashed_migrations_privileged | ||
| 1000000034_squashed_migrations_unprivileged | ||
| 1665531314_remove_api_docs_tables | ||
| 1666727108_add_codeintel_last_reconcile_table | ||
| 1669075922_add_scip_tables | ||
| 1669842405_add_additional_metadata_fields | ||
| 1669934289_add_scip_document_schema_versions_table | ||
| 1670001463_add_missing_index_for_cascading_deletes | ||
| 1670363942_fix_scip_schema_version_triggers | ||
| 1670365552_fix_scip_document_schema_counting | ||
| 1670370058_process_unreferenced_documents | ||
| 1670881409_fix_scip_document_schema_counting_again | ||
| 1670940342_add_codeintel_scip_symbol_names_table | ||
| 1670967960_add_codeintel_scip_symbol_names_indexes | ||
| 1671059396_remove_duplicate_trigger | ||
| 1676423214_remove_lsif_data | ||
| 1678041507_cleanup_unused_functions | ||
| 1678898749_make_unreferenced_documents_index_usable | ||
| 1678899132_remove_unused_unreferenced_documents_index | ||
| 1679010276_add_missing_index | ||
| 1686315964_clean_out_schema_versions_tables | ||
| 1723117227_add_tenants_table | ||
| 1723127341_add_tenant_id_to_most_tables | ||
| BUILD.bazel | ||
| squashed.sql | ||