特定文档上的CouchDB错误:HTTP请求中的&;函数_子句错误&; [英] CouchDB error on specific document: "function_clause error in HTTP request"
本文介绍了特定文档上的CouchDB错误:HTTP请求中的&;函数_子句错误&;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个CouchDB数据库,我在其中存储带有PDF和PNG附件的文档。在特定文档上保存附件后,当尝试在浏览器中查看该文档时,显示功能会失败。浏览器中的消息为:
{"error":"unknown_error","reason":"function_clause"}
Couch.log中的错误为
[Wed, 08 Jun 2011 21:29:58 GMT] [error] [<0.106.0>] function_clause error in HTTP request
[Wed, 08 Jun 2011 21:29:58 GMT] [info] [<0.106.0>] Stacktrace: [{couch_httpd,doc_etag,
[{'EXIT',
{{case_clause,
{[{<<"author">>,
[<<"Brian St. Claire-King">>,
<<"Eloy LaSanta">>]},
{<<"book_type">>,[<<"Roleplaying Game">>]},
{<<"date_added">>,[2011,6,7]},
{<<"date_published">>,2008},
{<<"genre">>,
[<<"Futuristic">>,<<"Post-Apocalyptic">>]},
{<<"language">>,<<"English">>},
{<<"license">>,
[{[{<<"url">>,<<"http://www.lulu.com">>},
{<<"id">>,<<"4880508">>}]}]},
{<<"page_count">>,276},
{<<"publisher">>,<<"Vajra Enterprises">>},
{<<"subtitle">>,<<"The Role Playing Game">>},
{<<"system">>,[<<"Organic Rule Components">>]},
{<<"title">>,<<"KidWorld">>},
{<<"last_modified">>,
<<"2011-06-08T01:58:44.697Z">>},
{<<"publisher_url">>,
<<"http://www.vajraenterprises.com/">>}]}},
[{couch_btree,lookup,3},
{couch_btree,lookup_kpnode,5},
{couch_btree,lookup,2},
{couch_db,get_full_doc_info,2},
{couch_db,open_doc_int,3},
{couch_db,open_doc,3},
{couch_httpd_db,couch_doc_open,4},
{couch_httpd_show,maybe_open_doc,2}]}}]},
{couch_httpd_show,show_etag,4},
{couch_httpd_show,handle_doc_show,6},
{couch_httpd_db,do_db_req,2},
{couch_httpd,handle_request_int,5},
{mochiweb_http,headers,5},
{proc_lib,init_p_do_apply,3}]
[Wed, 08 Jun 2011 21:29:58 GMT] [info] [<0.106.0>] 127.0.0.1 - - 'GET' /bookshelf/_design/bookshelf_loader/_show/book/4ddbbd8f3fd780c65e03c0a5e901fd57 500
我只能猜测其中一个附件已损坏。我已经尝试在Futon测试套件中运行适用于附件的测试;"Attachments"测试运行了12个多小时,但没有完成。
我只会删除该文档,但我没有修订号,任何访问该文档的尝试都会失败。我尝试使用cURL查询_all_docs视图,但中途中断,出现错误:{"id":"40af854814db1b4890c37c669a11de28","key":"40af854814db1b4890c37c669a11de28","value":{"rev":"4-ff85b5dbb2e4800ab4bfee81f32f0866"}}
curl: (56) Received problem 2 in the chunky parser
有没有办法删除有问题的文档(或其附件),只知道_id而不知道_rev?
编辑:我翻回日志,发现最初的崩溃,如下所示:
[Wed, 08 Jun 2011 02:00:05 GMT] [error] [<0.679.0>] ** Generic server <0.679.0> terminating
** Last message in was {update_docs,<0.4902.0>,
[[{doc,<<"4ddbbd8f3fd780c65e03c0a5e901fd57">>,
{4,
[<<81,240,217,60,28,224,204,196,19,243,27,
111,230,88,90,205>>,
<<171,3,185,48,48,23,182,2,95,122,48,132,
184,105,254,242>>,
<<69,27,210,166,21,121,125,192,47,237,187,
37,74,195,109,22>>,
<<145,31,9,71,4,24,15,90,97,154,177,102,
151,156,111,34>>]},
{[{<<"author">>,
[<<"Brian St. Claire-King">>,
<<"Eloy LaSanta">>]},
{<<"book_type">>,[<<"Roleplaying Game">>]},
{<<"date_added">>,[2011,6,7]},
{<<"date_published">>,2008},
{<<"genre">>,
[<<"Futuristic">>,<<"Post-Apocalyptic">>]},
{<<"language">>,<<"English">>},
{<<"license">>,
[{[{<<"url">>,<<"http://www.lulu.com">>},
{<<"id">>,<<"4880508">>}]}]},
{<<"page_count">>,276},
{<<"publisher">>,<<"Vajra Enterprises">>},
{<<"subtitle">>,
<<"The Role Playing Game">>},
{<<"system">>,
[<<"Organic Rule Components">>]},
{<<"title">>,<<"KidWorld">>},
{<<"last_modified">>,
<<"2011-06-08T01:58:44.697Z">>},
{<<"publisher_url">>,
<<"http://www.vajraenterprises.com/">>}]},
[{att,<<"KidWorld_2010_for_pdf.pdf">>,
<<"application/pdf">>,76729048,76729048,
<<143,119,231,165,202,3,166,134,23,195,
94,84,227,25,87,193>>,
4,
{<0.676.0>,[4280434790]},
identity},
{att,<<"kidworld copy.png">>,
<<"image/png">>,21674,21674,
<<237,107,129,30,82,36,136,61,29,17,202,
217,209,88,187,125>>,
3,
{<0.676.0>,[4280406118]},
identity}],
false,[]}]],
[],false,false}
** When Server state == {db,<0.678.0>,<0.679.0>,nil,<<"1307486659185780">>,
<0.676.0>,<0.680.0>,
{db_header,5,2454,0,
{4280430351,{508,9}},
{4280431672,517},
nil,0,nil,nil,1000},
2454,
{btree,<0.676.0>,
{4280430351,{508,9}},
#Fun<couch_db_updater.7.69395062>,
#Fun<couch_db_updater.8.86519079>,
#Fun<couch_btree.5.124754102>,
#Fun<couch_db_updater.9.24674233>},
{btree,<0.676.0>,
{4280431672,517},
#Fun<couch_db_updater.10.90337910>,
#Fun<couch_db_updater.11.13595824>,
#Fun<couch_btree.5.124754102>,
#Fun<couch_db_updater.12.34906778>},
{btree,<0.676.0>,nil,
#Fun<couch_btree.0.83553141>,
#Fun<couch_btree.1.30790806>,
#Fun<couch_btree.2.124754102>,nil},
2454,<<"bookshelf">>,
"../var/lib/couchdb/bookshelf.couch",[],[],nil,
{user_ctx,null,[],undefined},
nil,1000,
[before_header,after_header,on_file_open],
false}
** Reason for termination ==
** {{case_clause,{[{<<"author">>,
[<<"Brian St. Claire-King">>,<<"Eloy LaSanta">>]},
{<<"book_type">>,[<<"Roleplaying Game">>]},
{<<"date_added">>,[2011,6,7]},
{<<"date_published">>,2008},
{<<"genre">>,[<<"Futuristic">>,<<"Post-Apocalyptic">>]},
{<<"language">>,<<"English">>},
{<<"license">>,
[{[{<<"url">>,<<"http://www.lulu.com">>},
{<<"id">>,<<"4880508">>}]}]},
{<<"page_count">>,276},
{<<"publisher">>,<<"Vajra Enterprises">>},
{<<"subtitle">>,<<"The Role Playing Game">>},
{<<"system">>,[<<"Organic Rule Components">>]},
{<<"title">>,<<"KidWorld">>},
{<<"last_modified">>,<<"2011-06-08T01:58:44.697Z">>},
{<<"publisher_url">>,
<<"http://www.vajraenterprises.com/">>}]}},
[{couch_btree,modify_node,4},
{couch_btree,modify_kpnode,6},
{couch_btree,modify_node,4},
{couch_btree,query_modify,4},
{couch_btree,add_remove,3},
{couch_db_updater,update_docs_int,5},
{couch_db_updater,handle_info,2},
{gen_server,handle_msg,5}]}
[Wed, 08 Jun 2011 02:00:06 GMT] [error] [<0.679.0>] {error_report,<0.33.0>,
{<0.679.0>,crash_report,
[[{initial_call,{couch_db_updater,init,['Argument__1']}},
{pid,<0.679.0>},
{registered_name,[]},
{error_info,
{exit,
{{case_clause,
{[{<<"author">>,
[<<"Brian St. Claire-King">>,<<"Eloy LaSanta">>]},
{<<"book_type">>,[<<"Roleplaying Game">>]},
{<<"date_added">>,[2011,6,7]},
{<<"date_published">>,2008},
{<<"genre">>,[<<"Futuristic">>,<<"Post-Apocalyptic">>]},
{<<"language">>,<<"English">>},
{<<"license">>,
[{[{<<"url">>,<<"http://www.lulu.com">>},
{<<"id">>,<<"4880508">>}]}]},
{<<"page_count">>,276},
{<<"publisher">>,<<"Vajra Enterprises">>},
{<<"subtitle">>,<<"The Role Playing Game">>},
{<<"system">>,[<<"Organic Rule Components">>]},
{<<"title">>,<<"KidWorld">>},
{<<"last_modified">>,<<"2011-06-08T01:58:44.697Z">>},
{<<"publisher_url">>,
<<"http://www.vajraenterprises.com/">>}]}},
[{couch_btree,modify_node,4},
{couch_btree,modify_kpnode,6},
{couch_btree,modify_node,4},
{couch_btree,query_modify,4},
{couch_btree,add_remove,3},
{couch_db_updater,update_docs_int,5},
{couch_db_updater,handle_info,2},
{gen_server,handle_msg,5}]},
[{gen_server,terminate,6},{proc_lib,init_p_do_apply,3}]}},
{ancestors,[<0.678.0>,<0.675.0>]},
{messages,[]},
{links,[<0.678.0>]},
{dictionary,[]},
{trap_exit,true},
{status,running},
{heap_size,6765},
{stack_size,24},
{reductions,65012}],
[]]}}
这是my_show函数。我没有任何_UPDATE函数。
function(doc, req) {
var ddoc = this;
var Mustache = require("lib/mustache");
var path = require("vendor/couchapp/lib/path").init(req);
var indexPath = path.list('index','recent-books',{descending:true, limit:25});
var data = {
header : {
index : indexPath,
headerTitle : "Bookshelf"
},
scripts : {
assets : path.asset()
},
index : indexPath,
pageTitle : doc ? "Edit: " + doc.title : "Create a new book",
assets : path.asset(),
db : req.path[0]
};
if (doc) {
data.doc = JSON.stringify(doc);
data.author = doc.author;
data.book_types = getCheckboxValues(bookTypeArray, doc.book_type);
data.book_type_other = getOthers(bookTypeArray, doc.book_type);
data.cover_image = getAttachmentName(doc._attachments, "image/png");
data.date_added = getDateString(doc.date_added);
data.date_published = doc.date_published;
data.edition = doc.edition;
data.issue_number = doc.issue_number;
data.file_name = getAttachmentName(doc._attachments, "application/pdf");
data.genres = getCheckboxValues(genreArray, doc.genre);
data.genre_other = getOthers(genreArray, doc.genre);
data._id = doc._id;
data.languages = getDropdownValues(languageArray, doc.language);
data.licenses = getLicenses(doc.license);
data.page_count = doc.page_count;
data.publishers = getDropdownValues(publisherArray, doc.publisher);
data.publisher_other = getOther(publisherArray, doc.publisher);
data.publisher_url = doc.publisher_url;
data._rev = doc._rev;
data.subtitle = doc.subtitle;
data.systems = getCheckboxValues(systemArray, doc.system);
data.system_other = getOthers(systemArray, doc.system);
data.tags = doc.tags;
data.title = doc.title;
data.version = doc.version;
} else {
data.doc = JSON.stringify({});
data.date_added = getDateString();
data.book_types = getCheckboxValues(bookTypeArray);
data.languages = getDropdownValues(languageArray, "English");
data.licenses = "http://www.drivethrurpg.com,";
data.publishers = getDropdownValues(publisherArray);
data.genres = getCheckboxValues(genreArray);
data.systems = getCheckboxValues(systemArray);
}
return Mustache.to_html(ddoc.templates.edit, data, ddoc.templates.partials);
}
我没有粘贴所有相对简单的助手函数(例如,getCheckboxValues),这些函数可以在Couch中存储的内容和屏幕上显示的内容之间进行转换,但如果您认为它们有用的话,我可以粘贴。
我终于能够访问较旧的视图并获得文档的_rev。但是,发出带有cURL的DELETE命令会导致与前面相同的"CASE_CLOMENT"错误。任何将新文档放入或发布到数据库的尝试都将无限期地挂起,并且从那时起数据库将变得不可访问。(幸运的是,我有一个备份副本,其中仍然有一个损坏的文件,但至少可以访问。)
推荐答案
正如@jasonsmith在上面的评论中提到的,这有时可能是由您的Java脚本中的错误引起的。我无意中将View的名称属性直接设置为函数,而不是设置为包含其map和可选Reduce函数的对象,从而偶然发现了同样的错误消息。又名
错误:
"views": {
"test_view": "function (doc) { ... }"
}
好:
"views": {
"test_view": {
"map": "function (doc) { ... }"
}
}
这篇关于特定文档上的CouchDB错误:HTTP请求中的&;函数_子句错误&;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文