Skip to content

multiple schema changes on same request don't work on SQL over http api #86332

@maryliag

Description

@maryliag

When sending a request with multiple schema changes on the SQL over HTTP api, it doesn't actually make all the changes.

To test: create table CREATE TABLE t1 (k INT, i INT, f FLOAT, s STRING);
If I make a request with a single query, such as CREATE INDEX ON t1 (i) STORING (k);, it works.

If I instead create a index (on cli or the api) CREATE INDEX ON t1 (i); (which creates the idx t1_i_idx), and then I make a call to the api passing two statements:
CREATE INDEX IF NOT EXISTS t1_i__idx ON t1 (i) STORING (k);
DROP INDEX t1@t1_i_idx;
the api return no errors, but checking the table I can see that the t1_i_idx was deleted, but t1_i__idx was not created. If I then try to run the same statement CREATE INDEX IF NOT EXISTS t1_i__idx ON t1 (i) STORING (k); directly on cli, it doesn't return any errors, but also doesn't create the index.

Trying to drop t1 just hangs after that.

> select crdb_internal.pb_to_json('desc', descriptor) from system.descriptor where id = 't1'::regclass;

{"table": {"columns": [{"id": 1, "name": "k", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "i", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "f", "nullable": true, "type": {"family": "FloatFamily", "oid": 701, "width": 64}}, {"id": 4, "name": "s", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"defaultExpr": "unique_rowid()", "hidden": true, "id": 5, "name": "rowid", "type": {"family": "IntFamily", "oid": 20, "width": 64}}], "createAsOfTime": {"wallTime": "1660766203622664000"}, "families": [{"columnIds": [1, 2, 3, 4, 5], "columnNames": ["k", "i", "f", "s", "rowid"], "name": "primary"}], "formatVersion": 3, "id": 112, "modificationTime": {}, "mutationJobs": [{"jobId": "788713496337022977", "mutationId": 2}, {"jobId": "788713496363499521", "mutationId": 3}], "mutations": [{"direction": "ADD", "index": {"createdAtNanos": "1660766657425427000", "createdExplicitly": true, "foreignKey": {}, "geoConfig": {}, "id": 4, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [2], "keyColumnNames": ["i"], "keySuffixColumnIds": [5], "name": "t1_i__idx", "partitioning": {}, "sharded": {}, "storeColumnIds": [1], "storeColumnNames": ["k"], "version": 3}, "mutationId": 2, "state": "BACKFILLING"}, {"direction": "ADD", "index": {"createdAtNanos": "1660766657425427000", "createdExplicitly": true, "foreignKey": {}, "geoConfig": {}, "id": 5, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [2], "keyColumnNames": ["i"], "keySuffixColumnIds": [5], "name": "t1_i_crdb_internal_dpe_idx", "partitioning": {}, "sharded": {}, "storeColumnIds": [1], "storeColumnNames": ["k"], "useDeletePreservingEncoding": true, "version": 3}, "mutationId": 2, "state": "DELETE_ONLY"}, {"direction": "DROP", "index": {"createdAtNanos": "1660766232871093000", "createdExplicitly": true, "foreignKey": {}, "geoConfig": {}, "id": 2, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [2], "keyColumnNames": ["i"], "keySuffixColumnIds": [5], "name": "t1_i_idx", "partitioning": {}, "sharded": {}, "version": 3}, "mutationId": 3, "state": "DELETE_AND_WRITE_ONLY"}], "name": "t1", "nextColumnId": 6, "nextConstraintId": 2, "nextFamilyId": 1, "nextIndexId": 6, "nextMutationId": 4, "parentId": 104, "primaryIndex": {"constraintId": 1, "createdAtNanos": "1660766203622649000", "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [5], "keyColumnNames": ["rowid"], "name": "t1_pkey", "partitioning": {}, "sharded": {}, "storeColumnIds": [1, 2, 3, 4], "storeColumnNames": ["k", "i", "f", "s"], "unique": true, "version": 4}, "privileges": {"ownerProto": "root", "users": [{"privileges": 2, "userProto": "admin", "withGrantOption": 2}, {"privileges": 2, "userProto": "root", "withGrantOption": 2}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 105, "version": "9"}}

Jira issue: CRDB-18702

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions