【问题标题】:How to debug Cassandra validation errors如何调试 Cassandra 验证错误
【发布时间】:2016-04-06 08:40:15
【问题描述】:

我试图理解为什么我的一些 Cassandra 查询在从 NodeJS 调用时不起作用。

TL;DR - 有没有办法在服务器端推理验证失败的原因上打开调试?

我的具体问题是撞墙问题。 Cassandra 2.2.4,驱动程序 2.2.2。给定下表定义:

create table messages (id varchar,enterprise_id uuid,primary key(id, enterprise_id)

我传入以下查询:

cassandra.execute("select id from messages where id = ? and enterprise_id = ?",
  [local,domain],{},...);

local 是 string 类型,domain 是 Uuid 类型(由 Cassandra 从之前的查询中返回)。这会产生 8704 的错误:字符串未验证。。我确保将第一个 arg 转换为字符串,第二个转换为 Uuid 或字符串,错误不会改变。 Client._innerExecute发出的对象我已经打印出来了,看起来还可以:

cassandra request:{"streamId":null,"query":"select id from messages where id = ? and enterprise_id = ?",
"params":["fef86640-b0fb-11e5-8518-5b5a19241119","32d2a682-af07-4108-a15a-de6f8a75e811"],
"options":{"consistency":1,"fetchSize":5000,"prepare":false,"retryOnTimeout":true,
"prepared":true,"routingKey":null},"consistency":1,"hints":[]}

最后,服务器的调试(或任何其他)日志中绝对没有输出,表明存在任何类型的错误。考虑到很难让 J/S 打印出对象“类型”,目前还不清楚发送的是什么,以及服务器的期望是什么。

当然,直接在 cqlsh 中运行就可以了:

cassandra@cqlsh:a> SELECT * from messages WHERE 
    ... id = '92ec8eb0-b0f9-11e5-8518-5b5a19241119' and
    ... enterprise_id = 32d2a682-af07-4108-a15a-de6f8a75e811 ;
 id | enterprise_id
----+---------------
(0 rows)

所以,我正在寻找一种方法来阐明执行过程中发生了什么。

附:顺便说一句,当我在处理 Cassandra 驱动程序代码时,我意识到我使用了prepared 而不是prepare,进行了未准备的查询。我不知道实际的区别是什么,但是一旦我做好了准备,在这种特殊情况下事情就开始起作用了。但是我仍然很想知道如何调试这些问题,我应该再次遇到它们。

【问题讨论】:

    标签: node.js cassandra cql


    【解决方案1】:

    uuid 参数的预期 JavaScript 类型是 Uuid

    在你的情况下,应该是:

    const cassandra = require('cassandra-driver');
    const query = 'select id from messages where id = ? and enterprise_id = ?';
    client.execute(query, [ id, cassandra.types.Uuid.fromString(eid) ], callback);
    

    访问documentationUuid API docs 了解更多信息。

    【讨论】:

    • 建议的解决方案不起作用(至少在我的情况下),我并没有要求放下什么代码以使其工作,而是如何调试正在发生的事情,而你的回答并没有完全回答这个问题。
    猜你喜欢
    • 1970-01-01
    • 2014-07-11
    • 2011-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多