Title: MySQL migration lock is skipped by `void db reset` and by Better Auth migrations · Issue #415 · voidzero-dev/void · GitHub
Open Graph Title: MySQL migration lock is skipped by `void db reset` and by Better Auth migrations · Issue #415 · voidzero-dev/void
X Title: MySQL migration lock is skipped by `void db reset` and by Better Auth migrations · Issue #415 · voidzero-dev/void
Description: Problem PR #413 adds one lock per MySQL database for migrations. CLI runs hold GET_LOCK. Deploys to the Void platform write a lease row in _void_migration_lock. Two paths still change the database outside that lock: void db reset / void ...
Open Graph Description: Problem PR #413 adds one lock per MySQL database for migrations. CLI runs hold GET_LOCK. Deploys to the Void platform write a lease row in _void_migration_lock. Two paths still change the database ...
X Description: Problem PR #413 adds one lock per MySQL database for migrations. CLI runs hold GET_LOCK. Deploys to the Void platform write a lease row in _void_migration_lock. Two paths still change the database ...
Opengraph URL: https://github.com/voidzero-dev/void/issues/415
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MySQL migration lock is skipped by `void db reset` and by Better Auth migrations","articleBody":"## Problem\n\nPR #413 adds one lock per MySQL database for migrations. CLI runs hold `GET_LOCK`. Deploys to the Void platform write a lease row in `_void_migration_lock`. Two paths still change the database outside that lock:\n\n```\nvoid db reset / void db seed (MySQL)\n drop every base table \u003c- no lock; drops _void_migration_lock and _void_migrations too\n applyMySqlMigrations \u003c- takes the lock\n\nhosted migration handler (void deploy)\n runMySqlMigrations \u003c- lease held\n lease.release()\n runAuthMigrations \u003c- no lease\n\nvp dev (migration plugin)\n runMySqlMigrations \u003c- GET_LOCK, released when it returns\n runLocalVoidAuthMigrations \u003c- no lock\n```\n\nWhat can go wrong:\n\n- **Reset during a deploy.** `void db reset` drops the lease table while a deploy holds a lease. The deploy's next renew fails (\"expired before this run finished\"), or its next statement fails on a missing table. Reset then applies the files again under its own lock, so both runs can apply the same file.\n- **Better Auth migrations at the same time.** They read `information_schema`, then `CREATE TABLE IF NOT EXISTS` or `ALTER TABLE ... ADD COLUMN`. MySQL has no `ADD COLUMN IF NOT EXISTS`, so two runs at once can fail with \"Duplicate column name\".\n\n`void db reset` asks for confirmation on a non-local host. The risk is highest when a shared database is reset during a deploy.\n\n## Repro\n\nFrom the code (not run):\n\n1. Start a `void deploy` whose MySQL migrations take a while, so it holds the lease.\n2. Run `void db reset --yes` against the same database.\n3. Reset drops `_void_migration_lock`. The deploy loses its lease.\n\nFor Better Auth: run two deploys of different projects on one database, both with Better Auth and a new auth column.\n\n## Cause\n\n- `packages/void/src/cli/db.ts:599-611` drops every table with no lock. The lock is taken only later, in `applyMySqlMigrations` (`:616`). `void db seed` calls the same function (`:647`).\n- `packages/void/src/runtime/migration-handler-mysql.ts:25-28` runs `runAuthMigrations()` after `runMySqlMigrations` returned. That function released the lease in its `finally` (`:113`).\n- `packages/void/src/plugin-migration.ts:75` runs the SQL migrations (lock released on return), then `:108-111` runs the auth migrations.\n- `packages/void/src/runtime/auth-migrations.ts:346` onward reads the tables, then creates or alters them; `:198-199` adds no `IF NOT EXISTS` for MySQL.\n\n## Suggested fix\n\n- Reset: take the same lock (`GET_LOCK` plus the lease check) before it drops tables, and keep it until the migrations are applied.\n- Run Better Auth migrations before the lock or lease is released, in both runners.\n\n## Evidence\n\n- Code read at the head of #413. Not run.\n- The lock is new in #413 (`02d9e9b49`). On main there is no lock at all, so these are gaps in the new lock, not regressions.\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nhttps://claude.ai/code/session_0123r5HnanmW2VUrZ7VWDufH\n","author":{"url":"https://github.com/Brooooooklyn","@type":"Person","name":"Brooooooklyn"},"datePublished":"2026-10-14T04:05:25Z","url":"https://github.com/voidzero-dev/void/issues/415"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:13e1e254-4c84-5e4d-0390-c084bf854d13 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7CE:25A5E5:1BC147:257442:6AFB9BCB |
| html-safe-nonce | 15c26dc4e1e3c8d696bf3e309e4ffd3c397f7d67cce1ecd041a7c5fbec500e3b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0NFOjI1QTVFNToxQkMxNDc6MjU3NDQyOjZBRkI5QkNCIiwidmlzaXRvcl9pZCI6IjQzODMwNjUzMzE5NjI5NzcyMjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f4a0bffb96bd5192f6f1b300b206b52359e1bb5b1eb9a39077b92e66394b044b |
| hovercard-subject-tag | issue:5841737646 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/415/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db26a38068df2a27ac400c99ae195969779120f71b4f5b29b9d2a612443a599e/voidzero-dev/void/issues/415 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db26a38068df2a27ac400c99ae195969779120f71b4f5b29b9d2a612443a599e/voidzero-dev/void/issues/415 |
| og:image:alt | Problem PR #413 adds one lock per MySQL database for migrations. CLI runs hold GET_LOCK. Deploys to the Void platform write a lease row in _void_migration_lock. Two paths still change the database ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Brooooooklyn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3cefd19a936819d82cfb5279d50fb56fe79cb9ec30f0f807e04e89b0c58ffae1 |
| turbo-cache-control | no-preview |
| go-import | github.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git |
| octolytics-dimension-user_id | 149750581 |
| octolytics-dimension-user_login | voidzero-dev |
| octolytics-dimension-repository_id | 1164437080 |
| octolytics-dimension-repository_nwo | voidzero-dev/void |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1164437080 |
| octolytics-dimension-repository_network_root_nwo | voidzero-dev/void |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 606800bdb1b81d125fc845bdcc262c9fe063fc8f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width