Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Clears spaces except the first one in the scheme when I call the package.reload() or when I call again $ make run #13

Closed
nodermann opened this issue Jun 18, 2020 · 2 comments

Comments

@nodermann
Copy link

Related issue: moonlibs/tarantoolapp#15

automigrate = true

local spacer = require 'spacer'.get()

spacer:space({
    name = 'object3',
    format = {
        { name = 'id', type = 'unsigned' },
    },
    indexes = {
        { name = 'primary', type = 'tree', unique = true, parts = { 'id' } }
    }
})

spacer:space({
    name = 'object1',
    format = {
        { name = 'id', type = 'unsigned' },
    },
    indexes = {
        { name = 'primary', type = 'tree', unique = true, parts = { 'id' } }
    }
})

spacer:space({
    name = 'object2',
    format = {
        { name = 'id', type = 'unsigned' },
    },
    indexes = {
        { name = 'primary', type = 'tree', unique = true, parts = { 'id' } }
    }
})
tarantool> box.space
---
- object2:
    is_local: false
    temporary: false
    engine: memtx
  object3:
    is_local: false
    temporary: false
    engine: memtx
  object1:
    is_local: false
    temporary: false
    engine: memtx
...

tarantool> box.space.object1:select()
---
- []
...

tarantool> box.space.object2:select()
---
- []
...

tarantool> box.space.object3:select()
---
- []
...

tarantool> box.space.object1:insert({1})
---
- [1]
...

tarantool> box.space.object2:insert({2})
---
- [2]
...

tarantool> box.space.object3:insert({3})
---
- [3]
...

tarantool> box.space.object1:select()
---
- - [1]
...

tarantool> box.space.object2:select()
---
- - [2]
...

tarantool> box.space.object3:select()
---
- - [3]
...

tarantool> package.reload()
2020-06-18 12:29:25.526 [50034] main/102/ttt I> 2nd load. Unloading {spacer, schema, app, spacer.version, spacer.transformations, spacer.migration, spacer.util, spacer.stmt, spacer.ops, spacer.inspect, config, inspect, spacer.compat, mod1, spacer.fileio}
2020-06-18 12:29:25.526 [50034] main/102/ttt I> package.reload:cleanup...
2020-06-18 12:29:25.529 [50034] main/102/ttt I> app "ttt" destroy
2020-06-18 12:29:25.529 [50034] main/102/ttt I> package.reload:cleanup finished
config	table: 0x010522e6b0	loading config 	./conf.lua
2020-06-18 12:29:25.535 [50034] main/102/ttt I> app "ttt" init
2020-06-18 12:29:25.550 [50034] main/117/lua reload.lua:160 E> Cleanup 1, running
---
...

tarantool> box.space.object3:select()
---
- - [3]
...

tarantool> box.space.object2:select()
---
- []
...

tarantool> box.space.object1:select()
---
- []
...

@igorcoding
Copy link
Owner

As a quick fix add this option to spacer config - keep_obsolete_spaces = true. But keep in mind that you shouldn't use automigrate when preparing for a production use.
I'll think on a better solution later.

igorcoding added a commit that referenced this issue Nov 16, 2020
* Removed automigrate option in spacer. Replaced with a separate method that should be called
  when all necessary `spacer:space()` calls are finished. (addresses #13)
@igorcoding
Copy link
Owner

Hi! I ditched automigrate option from the spacer and replaced with an :automigrate() method which should be called after all spacer:space() calls (check the readme for details).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants