Skip to content

Latest commit

 

History

History
27 lines (23 loc) · 1.92 KB

SpaceNotFound.md

File metadata and controls

27 lines (23 loc) · 1.92 KB

Main page

How to set schema and do not get "space not found" error?

About problem

If you create spaces only on storages inside a storage role like this or any other way, and you want to get data using router. You will receive an error message like "space not found".
This happens because router does not have information about this space.
If you work directly with a storage you won't get this kind of error if spaces was created properly.
But if you want to use CRUD to retrieve data from the router, there are some solutions.

Migrations

We recommend to set the scheme using migrations, they will be applied not only to storages, but also to routers.
This way the router will be aware of the current scheme and such errors will not occur. Migrations will create spaces on both storages and routers.
Tarantool CE supports migrations only since 2.2.x. Tarantool Enterprise Edition supports migrations since 1.10.x and 2.2.x. More information about migrations tarantool/migrations.

Proxying ddl.get_schema

If you want to create spaces only in storages, there is another solution. Set up proxying ddl.get_schema from storage to routers. You should add this function to router role:

local function get_schema()
for _, instance_uri in pairs(cartridge_rpc.get_candidates('app.roles.api_storage', { leader_only = true })) do
return cartridge_rpc.call('app.roles.api_storage', 'get_schema', nil, { uri = instance_uri })
end
end
And make it global.
rawset(_G, 'ddl', { get_schema = get_schema })
Or you can just remove word local from line 10. Effect will be the same. Now then cartridge-java tries to get schema from router