tarantool / vshard

The new generation of sharding based on virtual buckets
Other
99 stars 30 forks source link

Hot reload is broken if name is key #464

Closed DifferentialOrange closed 10 months ago

DifferentialOrange commented 11 months ago

Tarantool Enterprise 3.0.0-0-gf58f7d82a-r23-gc64 vshard 0.1.25

Code hot reload fails in case identification_mode = 'name_as_key' is used.

Reproducer (no UUID):

-- init.lua

-- Setup cluster.
local vshard = require('vshard')

local replicaset_name = 'rs-1'
local replica_name = 'r-1'

local listen = 'localhost:3301'

box.cfg({
    replicaset_name = replicaset_name,
    instance_name = replica_name,
})

local cfg = {
    bucket_count = 3000,
    sharding = {
        [replicaset_name] = {
            replicas = {
                [replica_name] = {
                    uri = 'guest@' .. listen,
                    master = true,
                },
            },
        },
    },
    identification_mode = 'name_as_key',
}
vshard.storage.cfg(cfg, replica_name)
vshard.router.cfg(cfg)
vshard.router.bootstrap()

-- Reload code.
package.loaded['vshard.storage'] = nil
package.loaded['vshard'] = nil

require('vshard')
tarantool init.lua
main utils.c:679 E> LuajitError: .rocks/share/tarantool/vshard/storage/init.lua:3733: .rocks/share/tarantool/vshard/storage/init.lua:3582: Usage: cfg(configuration, this_replica_id)

Reproducer (with UUID):

-- init.lua

-- Setup cluster.
local vshard = require('vshard')

local replicaset_name = 'rs-1'
local replica_name = 'r-1'

local uuid = 'fcbb2a69-7cab-4307-94cd-dc85699f941b'

local listen = 'localhost:3301'

box.cfg({
    replicaset_name = replicaset_name,
    instance_name = replica_name,
    instance_uuid = uuid,
})

local cfg = {
    bucket_count = 3000,
    sharding = {
        [replicaset_name] = {
            replicas = {
                [replica_name] = {
                    uri = 'guest@' .. listen,
                    uuid = uuid,
                    master = true,
                },
            },
        },
    },
    identification_mode = 'name_as_key',
}
vshard.storage.cfg(cfg, replica_name)
vshard.router.cfg(cfg)
vshard.router.bootstrap()

-- Reload code.
package.loaded['vshard.storage'] = nil
package.loaded['vshard'] = nil

require('vshard')
tarantool init.lua
main utils.c:679 E> LuajitError: .rocks/share/tarantool/vshard/storage/init.lua:3733: .rocks/share/tarantool/vshard/storage/init.lua:3595: Local replica fcbb2a69-7cab-4307-94cd-dc85699f941b wasn't found in config

The reason is likely to be this line of code https://github.com/tarantool/vshard/blob/bc84c65d06a7bc6633588250e12f59b5cc0c8c65/vshard/storage/init.lua#L4039 which always uses uuid as key.