tikv的scan接口无法获取全部数据

请教一下~
测试过程中遇到两个疑问(juicefs配合tikv使用的测试)
1.tikv的事务接口文档没找到,只看到了raw API;
2.juicefs会像tikv写数据,监控也看到数据有变化了,但是我通过scan接口没查到数据,(只有最初的几条设置时写的元数据,展示出来还是乱码),有点没理解

image

代码如下,麻烦帮忙看下~
(startKeyStr, endKeyStr 都传null)

@RequestMapping(value = "/scan", method = RequestMethod.GET)
public Map<String, String> scan(
        @RequestParam(value = "startKeyStr", required = false) String startKeyStr,
        @RequestParam(value = "endKeyStr", required = false) String endKeyStr
) throws Exception {
    System.out.println("scan/all api");
    TiConfiguration conf = TiConfiguration.createRawDefault("xx.xx.xx.xxx:2379");
    TiSession session = TiSession.create(conf);
    RawKVClient client = session.createRawClient();

    ByteString startKey = null;
    ByteString endKey = null;
    if(startKeyStr != null){
        startKey = ByteString.copyFromUtf8(startKeyStr);
    }
    if(endKeyStr != null){
        endKey = ByteString.copyFromUtf8(endKeyStr);
    }
    Map<String, String> res = new HashMap<>();

    int limit = 4;
    while(true) {
        List<Kvrpcpb.KvPair> list = client.scan(startKey, endKey, limit);
        Key maxKey = Key.MIN;
        for (Kvrpcpb.KvPair pair : list) {
            System.out.println(pair);
            res.put(pair.getKey().toStringUtf8(), pair.getValue().toStringUtf8());
            Key currentKey = Key.toRawKey(pair.getKey());
            if(currentKey.compareTo(maxKey) > 0) {
                maxKey = currentKey;
            }
        }

        if(list.size() < limit) {
            break;
        }
        startKey = maxKey.next().toByteString();
    }

    return res;
}

结果返回如下:
只有几条创建fs的记录;(通过rawAPI写入的数据也可以查到…通过juicefs写入的数据就拿不出来,监控显示确实有读写)

1 个赞

JucieFS 用的 Txn 接口。Txn 和 Raw 的数据互相不兼容

1 个赞

好的,thx~
请问下目前有办法可以通过字符串的prefix查Txn接口写入的数据嘛,测试过程中数据太多,scan接口捞不出来所有的数据。(由于java-client不支持txn接口,改成了go的client)

可以用 iterator 从某一个 prefix 开始扫描

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。