我正在为Mac Lion 10.8.2上的一个项目做原型,上面有Couchbase2.0,node.js 0.8.19,Couchbase module 0.0.11和libcouchbase 2.0.3。
如果Couchbase存储桶为空(这两个文档不存在),下面的代码将使用以下代码使节点进程崩溃。我使用debug构建了节点,并使用gdb进行回溯。
node_g(96149,0x7fff75619180) malloc: *** error for object 0x10300fb7f: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal SIGABRT, Aborted.
0x00007fff8bbf7212 in __pthread_kill ()
(gdb) backtrace
#0 0x00007fff8bbf7212 in __pthread_kill ()
#1 0x00007fff8cd6eaf4 in pthread_kill ()
#2 0x00007fff8cdb2dce in abort ()
#3 0x00007fff8cd86959 in free ()
#4 0x0000000101e91c33 in lcb_server_purge_implicit_responses ()
#5 0x0000000101e89f09 in lcb_server_event_handler ()
#6 0x0000000101adebab in maybe_callout [inlined] () at :34
#7 0x0000000101adebab in async_cb (handle=<value temporarily unavailable, due to optimizations>, status=0) at ../io/common.c:68
#8 0x00000001000442ea in uv__async_io (loop=<value temporarily unavailable, due to optimizations>, handle=0x1c042a000000000, events=1060378680) at ../deps/uv/src/unix/async.c:117
#9 0x0000000100049c24 in ev_invoke_pending (loop=0x10082bd68) at ../deps/uv/src/unix/ev/ev.c:2145
#10 0x00000001000445e8 in uv__run (loop=0x10082b420) at ../deps/uv/src/unix/core.c:248
#11 0x0000000100044517 in uv_run (loop=0x10082b420) at ../deps/uv/src/unix/core.c:265
#12 0x0000000100008d9b in node::Start (argc=<value temporarily unavailable, due to optimizations>, argv=0x7fff5fbffb98) at ../src/node.cc:2974
#13 0x0000000100000cb4 in start ()
如果这两个文档已经存在,则此方法有效。只有当文档不存在时,它才会崩溃。如果我不使用多个get(而是一个视图)来检查文档是否存在,那么它是有效的。如果你问为什么我显式地检查是否存在,而不依赖于CAS -大多数文档都已经存在了,所以我无论如何都必须在更新之前拉出它们。
同样的代码在(亚马逊托管的)带有相同版本node.js和库的CentOS 6镜像上运行良好。
是我做错了什么,还是在Mac上有问题?这是一个简单的例子来说明这个问题。完整的代码将现有数据与新文档合并,并执行CAS检查,所有这些都在这里省略。
我找不到在哪里报告Couchbase的错误。JIRA没有打开,forum也有点差劲。
var async = require("async");
var couchBase = require("couchbase");
var json = {
"id1": {
"id": "id1",
"name": "Name 1"
},
"id2": {
"id": "id2",
"name": "Name 2"
}
};
var config = {
"host": "localhost",
"port": 8091,
"username": "Administrator",
"password": "password",
"bucket": "requests"
};
couchBase.connect(config, function(err, bucket) {
if (err) {
console.log("Unable to connect to Couchbase bucket [" + config.bucket + "]", err);
process.exit(1);
}
console.log("Connected to Couchbase");
var ids = [];
var jsonDocs = [];
for (var key in json) {
if (json.hasOwnProperty(key)) {
var jsonDoc = json[key];
var id = jsonDoc.id;
jsonDocs.push(jsonDoc);
ids.push(id);
}
}
bucket.get(ids, null, function(err, docs, metas) {
if (err) {
for (var j = 0; j < err.length; j++) {
if (err[j].code != 13) {
console.log({ err: err }, "Unable to get existing entries using multiple get. Error in element [" + j + "]");
process.exit(1);
}
}
}
console.log("Checked all docs for existance");
async.map(jsonDocs, function(doc, callback) {
bucket.set(doc.id, doc, {}, function(err) {
callback(err);
});
}, function(err, results) {
if (err) {
console.log("Unable to save all entries", err);
process.exit(1);
}
console.log("Saved all entries");
process.exit(0);
});
});
});
发布于 2013-02-12 22:43:02
我在我的应用程序和您的示例代码中也遇到了同样的问题。我将记录一个bug,并将其放入下一版本SDK的修复列表中。
JIRA是:http://www.couchbase.com/issues/browse/JSCBC-16
你不能记录一个bug吗?
我也在关注论坛,刚才也回答了你的问题。
https://stackoverflow.com/questions/14829946
复制相似问题