cockroachdb / cockroachdb/cockroach

Unable to do simple addition of columns to table in Alembic migration

Open
#172,617 3 comments 0 reactions 0 assignees View on GitHub
C-bug
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

I'm using cockroach cloud and I'm attempting to do a simple migration where I add columns using alembic but I'm seeing this error:

sqlalchemy.exc.DBAPIError: (sqlalchemy.dialects.postgresql.asyncpg.Error) : this schema change is disallowed because table "my_table" is locked and this operation cannot automatically unlock the table
DETAIL: To unlock the table, execute `ALTER TABLE my_table SET (schema_locked = false);`
After the schema change completes, we recommend setting it back to true with `ALTER TABLE my_table SET (schema_locked = true);`

The cluster settings already have schema.auto_unlock set to true

all this does is add a few columns with null default

I opened up cockroach cloud, went to the SQL Console and typed in the command to unlock it explicitly and got this error:

ERROR: executing stmt 1: run-query-via-api: "schema_locked" can only be set/reset on its own without other parameters in a single-statement implicit transaction.
SQLSTATE: 22023

I am guessing the cloud cluster upgraded between now and the last time I attempted to modify a schema on a table because this historically has never been an issue. I don't reproduce this issue running the migration against a test cockroachdb instance which is v24.1.2

Jira issue: CRDB-65863

Contributor guide

Open the contributing guide

Research direction

No repository file or test entry point is named. Start by reproducing the Alembic migration on Cockroach Cloud and on the reported v24.1.2 test instance, then compare the schema_locked behavior with CRDB-65863 and the SQL Console error. Done means the nullable-column migration has a documented or verified resolution without the current table-lock failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, sql, sqlalchemy
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.