rethinkdb踩坑记录

来源:互联网 发布:mac口红持久吗 编辑:程序博客网 时间:2024/06/14 17:39

奇葩的错误日志

Rethinkdb自带的错误日志真的很奇葩, 会在日志里自带一堆反斜杠. 另外, 有的东西表述也不准确. 比如这个:

The server(s) hosting table abc.in are currently unreachable. The secondary index was not created. If youdo not expect the server(s) to recover, you can use emergency_repair to restore availability of the table.

我的操作是要在abc数据库中的t表内建立名为in的索引. 但给出的错误日志却是很奇怪的abc.in, 直接跳过了t表. 看这个错误日志以为是我尝试建立了一个abc数据库里in表中的索引, 但反复检查代码发现并非如此. 因此, 我查了一下源代码, 想确定一下是不是这个数据库日志有问题.

首先在源代码目录里找到这段日志的源头, 位于src/clustering/administration/admin_op_exc.hpp:

#define CATCH_OP_ERRORS(db, name, error_out, no_msg, maybe_msg)                       \    catch (const failed_table_op_exc_t &) {                                           \        *(error_out) = admin_err_t{                                                   \            strprintf("The server(s) hosting table `%s.%s` are currently "            \                      "unreachable. " no_msg " If you do not expect the server(s) "   \                      "to recover, you can use `emergency_repair` to restore "        \                      "availability of the table. "                                   \                      "<http://rethinkdb.com/api/javascript/reconfigure/"             \                      "#emergency-repair-mode>", (db).c_str(), (name).c_str()),       \            query_state_t::FAILED};                                                   \        return false;                                                                 \    } 

可以看到, 这个日志的数据库名和表名是由CATCH_OP_ERRORS这个宏定义代入的. 再回到宏定义引用的位置, src/clustering/administration/real_reql_cluster_interface.cc:

CATCH_OP_ERRORS(db->name, name, error_out,"The secondary index was not created.","The secondary index may or may not have been created.")

可以看到, 第二个传参是由函数传参代入的, 函数原型为:

bool real_reql_cluster_interface_t::sindex_create(        auth::user_context_t const &user_context,        counted_t<const ql::db_t> db,        const name_string_t &table,        const std::string &name,        const sindex_config_t &config,        signal_t *interruptor_on_caller,        admin_err_t *error_out)

sindex_create由三个参数, db, table, name, 分别是数据库名, 表的名字, 索引的名字. 因此, 实际上这里生成日志的时候, 跳过了表的名字而直接使用了索引的名字, 看起来让人费解, 这也就证明了我的猜想是正确的.

原创粉丝点击