Skip to content

net.box reloads scheme incorrectly #6169

@unera

Description

@unera

Hi!

Tarantool protocol was designed for transparent schema reload.
However, net.box doesn't follow the workflow protocol properly.

net.box should send its schema_version for each request. But it always sends zero.
So it reloads the scheme with one-request delay.

There wasn't such bug 7 years ago. This bug appeared when the net.box was refactored. After that there was added the :reload_schema method to solve the problems caused by this bug manually.

The net.box algorithm should be the following:

  1. Init
  2. Send schema_version for each request
  3. Delay all requests if schema error occurs until the schema is reloaded
  4. Reload schema
  5. Resend the request that caused schema error
  6. Send all delayed requests (including the other schema-error requests)
  7. ...

Reproduce test config:

console = require 'console'
nb = require 'net.box'

box.cfg{listen = 3301, work_dir = 'tnb'}
box.schema.user.grant('guest', 'read,write,execute', 'universe')
ts = box.schema.space.create(
    'ts',
    {   
        format={
            {name='key', type='string'},
            {name='vl', type='string'},
        }
    }
)

ts:create_index('pk')

ts:insert{'hello', 'world'}

remote = nb.connect('localhost:3301')

console.start() os.exit()

Reproduce script:

tarantool> remote.schema_version
---
- 80  -- !!!! have to be 81 !!!!!
...

tarantool> remote.space.ts:get('hello')['value']
---
- null
...

tarantool> remote.space.ts:get('hello')['vl']
---
- world
...

tarantool> ts:format{'key', 'value'}
---
...

tarantool> remote.schema_version
---
- 80  -- !!!! have to be 81 !!!!!
...

tarantool> remote.space.ts:get('hello')['value']
---
- null  -- !!!! have to be 'world' !!!!
...

tarantool> remote.space.ts:get('hello')['value']
---
- world
...

tarantool> remote.schema_version
---
- 81
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions