Skip to content

Forbid DDL before box.schema.upgrade is called #7149

@sergepetrenko

Description

@sergepetrenko

We already track which schema version is needed for correct Tarantool operation.
The user sees the following message after upgrading the database:

2022-05-18 12:54:07.790 [9379] main/103/interactive load_cfg.lua:857 W> Your schema version is 1.10.2 while Tarantool 2.11.0-entrypoint-49-g9ce8798d1 requires a more recent schema version. Please, consider using box.schema.upgrade().

Having said that, Tarantool still allows the user to run ddl on a cluster with non-upgraded schema.
This leads to various unpredictable errrors (because the ddl code assumes the schema is already upgraded).

Example (trying to create a space on 2.11 Tarantool with 1.10 schema):

tarantool> box.schema.space.create('test')
---
- error: 'Tuple field 1 (id) type does not match one required by operation: expected
    unsigned, got nil'
...

Example (trying to drop a space on 2.8 Tarantool with 1.10 schema):

- error: 'builtin/box/schema.lua:515: attempt to index field ''space_id'' (a nil value)'

First of all, DDL on an old schema might return an unclear error. Like in the example above.
Secondly, DDL might complete without errors but produce erroneous results.
Lastly, when DDL fails on a non-upgraded schema, it might leave the schema in an incorrect state. DDL is not transactional currently (#600), and if the error is generated on some intermediate DDL step, the schema will be left in a partially changed state. And all further attempts to perform DDL will fail.

Let's forbid DDL altogether unless the user has the most recent schema version.

Metadata

Metadata

Assignees

Labels

3.0Target is 3.0 and all newer release/master branchesboxThe database and relevant APIsddlfeatureA new functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions