0

我有带有分片模块和空间配置的 Tarantool,如下所示:

local h_box = box.schema.create_space('hotbox')
h_box:create_index('one', {type = 'hash', parts = {1, 'string'}})
h_box:create_index('two', {type = 'tree', parts = {2, 'string'}})
h_box:create_index('three', {type = 'tree', parts = {3, 'unsigned'}})
h_box:create_index('four', {type = 'tree', parts = {4, 'boolean'}})
h_box:create_index('five', {type = 'tree', parts = {5, 'unsigned'}})
h_box:create_index('six', {type = 'tree', parts = {6, 'boolean'}})

Tarantool 分片模块文档说:

没有主键的 shard.T:select{} 请求将搜索所有分片。

但是当我尝试调用它时看到错误。

shard.h_box:select{}
---
- error: 'builtin/digest.lua:138: Usage digest.crc32(string)'
...

另外,当我调用shard.h_box:secondary_select{2, {limit = 10}, 'foo'}Tarantool 时,会抛出一个错误:

---
- error: '/usr/share/tarantool/shard/init.lua:1015: attempt to index field ''conn''
    (a nil value)'
...

如何从所有分片中获取所有数据并将选择调用到二级索引?

4

1 回答 1

1

shard.T:select()不能在没有主键的情况下执行。我向文档团队提交了#574 。

关于secondary_select

  1. 似乎与至少一个存储的连接已断开。值得看一下前端 tarantool 的日志文件(这里使用了 shard 模块)。

  2. 以防万一,值得检查您是否可以连接到存储并使用 net.box 从指定用户的空间中进行选择。

  3. 使用括号而不是大括号(该函数接受多个参数,而不是单个表)。

  4. 您正在使用 e75d2c7a 版本的分片模块,但尝试使用更新版本的 API。例如,对 e75d2c7a 的正确请求是shard.space_name:secondary_select(index_no_or_name, index_key, opts). 或者尝试更新到最近的分片版本。

  5. 索引从零开始计数,因此您尝试使用带有“字符串”键的“无符号”索引“三”(顺便说一下,secondary_select允许使用索引名称)。

  6. redundacy设置为 2,但存储计数是奇数。最后一个不会被使用。

希望能帮助到你。

于 2018-06-19T13:10:40.360 回答