特定文档上的CouchDB错误:";函数“HTTP请求中的U子句错误”;
我有一个CouchDB数据库,其中存储了带有PDF和PNG附件的文档。在特定文档上保存附件后,尝试在浏览器中查看该文档时,“显示”功能失败。浏览器中的消息是:特定文档上的CouchDB错误:";函数“HTTP请求中的U子句错误”;,couchdb,attachment,Couchdb,Attachment,我有一个CouchDB数据库,其中存储了带有PDF和PNG附件的文档。在特定文档上保存附件后,尝试在浏览器中查看该文档时,“显示”功能失败。浏览器中的消息是: {"error":"unknown_error","reason":"function_clause"} coach.log中的错误为 [Wed, 08 Jun 2011 21:29:58 GMT] [error] [<0.106.0>] function_clause error in HTTP request [Wed
{"error":"unknown_error","reason":"function_clause"}
coach.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
是否有任何方法可以删除仅知道_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}],
[]]}}
我并没有粘贴所有相对简单的助手函数(例如getCheckboxValues),这些函数可以在coach中存储的内容和屏幕上显示的内容之间进行转换,但如果您认为它们有益的话,我可以粘贴
我终于能够访问一个较旧的视图并获得文档的修订版。但是,使用cURL发出DELETE命令会导致与前面相同的“case_子句”错误。任何将新文档放入或发布到数据库中的尝试都将无限期挂起,从那时起数据库将变得不可访问。(幸运的是,我有一个备份副本,其中仍然有一个损坏的文件,但至少可以访问。)正如上面的评论中提到的@jasonmith,这有时可能是由Javascript中的错误引起的。我无意中将视图的name属性直接设置为函数,而不是设置为包含其map和可选reduce函数的对象,从而偶然发现了相同的错误消息。阿卡 坏的: 好:
您正在使用哪个版本的CouchDB?
function\u子句
和case\u子句
有时可能意味着您的Javascript中有一个bug。(错误报告很糟糕,但基本上Javascript返回或抛出了一个错误,然后Erlang随后抛出了一个错误。请粘贴您的_show(可能还有_更新)函数?您正在使用的任何Javascript代码。可能有线索。最后一个非答案建议:在Cloudant或Iris Coach创建一个托管coach。如果您可以重现错误,您将有一个公司支持系统来帮助您找到错误(无论是在CouchDB中还是在您的代码中)。厚颜无耻但很有效。@Dominic:我正在使用Windows.FWIW的1.0.1发行版,如果您提交一个空的附件对象:{“_attachments”:{“image”:{}}请在提交之前清除这些内容。
[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}],
[]]}}
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);
}
"views": {
"test_view": "function (doc) { ... }"
}
"views": {
"test_view": {
"map": "function (doc) { ... }"
}
}