TABLE_BUSY
A schema change waited for a table another database session was using, past its bounds, and stopped.
Cause
A schema change waited for a table another database session was using, past its bounds, and stopped.
A change to a table needs a lock that a session in the middle of a long transaction, or a long query, can hold. Rather than wait behind it for as long as the database allows, holding up every query that queues behind the change, each try waits about 5 seconds, then the change pauses (1, 2, 4, 8, then 15 seconds) and tries again, until about 90 seconds have passed in all. Each try after the first prints one line naming the table and what holds it. The Why line names the table, the tries and how long they took, and the holder: on PostgreSQL and MySQL each holding session by its id, user, address, application and how long its transaction has been open, never its query's text; on SQLite, which names no holder, why none can be named. It also names the changes this run applied before this one.
How the change was left decides what to do:
- Nothing changed. The change was undone, or never began, and running it again is safe.
- Stopped part-way. Statements of the change had committed before the wait (a MySQL schema statement commits on its own, as does a migration run outside a transaction). The Why line names them; they stay.
- Stopped without trying again. A statement that may not be sent again ran or waited (a
setval, an index built without blocking writes, a call of a function of your own, a row change on a table with a trigger, or a statement of a kind Nextly does not recognise), so the change was not tried again. The Why line names the statement and whether the rest of the change was undone with its transaction.
On SQLite, the tries can end before their bounds: while another connection holds the whole database, the schema lock cannot be renewed, and the Why line says so.
On SQLite, a command can also stop this way before it changes anything, while it takes the schema lock: another connection with a write open holds the whole database, so the lock's own table, nextly_schema_lock, is the one named, and SQLite names no holder. The command waits through the same tries. A Schema Builder save, or any other request, makes one try and then answers with this error, so the request is not held open.
Fix
- Nothing changed: run the command again once the holding session ends, or end that session (on PostgreSQL
pg_terminate_backend, on MySQLKILL, once you are sure it can go), or give the change longer with--lock-timeout(one try, in seconds) and--lock-timeout-total(every try together), orNEXTLY_LOCK_TIMEOUTandNEXTLY_LOCK_TIMEOUT_TOTAL. - Stopped without trying again, the rest undone with its transaction: nothing of the file stayed but what the named statement keeps itself (for a
setval, the sequence's position). Check that, then run the command again once the holding session ends; the file applies from its start. Ifnextly migraterefuses the file for an unresolved attempt, clear it first withnextly migrate:resolve --failed-cleanup <file>. - Stopped part-way, or without trying again outside a transaction: resolve the file as for any migration that stopped part-way. Finish its remaining statements by hand and mark it applied with
nextly migrate:resolve --applied, or reverse what stayed and runnextly migrate:resolve --failed-cleanup. Then runnextly migrateagain. - A
nextly migrate:downthat stopped: the file is still recorded applied, so recovery runs the other way round, and the error's Next line says so. If its DOWN was undone whole, runnextly migrate:downagain once the holding session ends. If it stopped part-way, finish its remaining DOWN statements by hand and record the file rolled back withnextly migrate:resolve --rolled-back <file>, or reverse what stayed so its tables stand as applied and runnextly migrate:downagain. Never mark it applied, and never clear its attempt with--failed-cleanup: either would record the file the opposite way from its tables.
Example
✗ `20261020_120000_add_posts.sql` stopped: table busy, nothing changed.
Why: It waited for table "dc_posts" through 7 tries over 90 s, held by session 4242 (user app, from 10.0.0.5, application "worker", transaction open 3 min).
Applied before it in this run: `20261019_090000_add_tags.sql`.
Next: Run it again once the holder ends, end the holding session, or raise `--lock-timeout` / `--lock-timeout-total` (or `NEXTLY_LOCK_TIMEOUT` / `NEXTLY_LOCK_TIMEOUT_TOTAL`).
Docs: https://nextlyhq.com/docs/cli/errors/table-busy (TABLE_BUSY)SYNC_CONFIRMATION_REQUIRED
`db:sync --promote` or `--demote` has a confirmation to ask, no terminal is attached to ask it, and `--yes` was not given, so nothing was changed.
TRANSLATIONS_UNRECORDED
`nextly migrate:create` was run in a project with translations whose latest snapshot predates the record of translated fields.