我有三个具体的观点,经过两年的顺利工作后突然崩溃了。对同一数据库的其他观点也没问题。这是蒲团的错误:
Error: os_process_error
OS process timed out.
Couchdb版本是1.2.0。
以下是崩溃报告日志:
[Sat, 22 Dec 2012 18:28:53 GMT] [error] [<0.1434.0>] OS Process Error <0.1331.0> :: {os_process_error,
"OS process timed out."}
[Sat, 22 Dec 2012 18:28:53 GMT] [error] [emulator] Error in process <0.1434.0> with exit value: {{nocatch,{os_process_error,"OS process timed out."}},[{couch_os_process,prompt,2,[{file,"/usr/src/build-couchdb/dependencies/couchdb/src/couchdb/couch_os_process.erl"},{line,57}]},{couch_query_servers,map_doc_raw...
[Sat, 22 Dec 2012 18:28:53 GMT] [error] [<0.1427.0>] ** Generic server <0.1427.0> terminating
** Last message in was {'EXIT',<0.1431.0>,
{{nocatch,
{os_process_error,"OS process timed out."}},
[{couch_os_process,prompt,2,
[{file,
"/usr/src/build-couchdb/dependencies/couchdb/src/couchdb/couch_os_process.erl"},
{line,57}]},
{couch_query_servers,map_doc_raw,2,
[{file,
"/usr/src/build-couchdb/dependencies/couchdb/src/couchdb/couch_query_servers.erl"},
{line,88}]},
{couch_view_updater,'-do_maps/3-fun-0-',3,
[{file,
"/usr/src/build-couchdb/dependencies/couchdb/src/couchdb/couch_view_updater.erl"},
{line,174}]},
{couch_view_updater,do_maps,3,
[{file,
"/usr/src/build-couchdb/dependencies/couchdb/src/couchdb/couch_view_updater.erl"},
{line,169}]}]}}
** When Server state == {group_state,undefined,<<"anypy_suggest">>,
{"/usr/src/build-couchdb/build/var/lib/couchdb",
<<"anypy_suggest">>,
{group,
<<179,2,154,154,243,188,196,230,224,228,72,35,138,
126,255,36>>,
nil,<<"_design/message">>,<<"javascript">>,[],
[{view,0,0,0,[],
<<"function(doc) {\n\t\n\t// test if messages shoud be emitted\n\tvar emit_all = function(messages) {\n\t\tfor(var i in messages) {\n\t\t\tvar d = messages[i].when.split(\"-\");\n\t\t\tvar day = d[2].split(\"T\");\n\t\t\temit([d[0]+'-'+d[1]+'-'+day[0], messages[i].group, messages[i].who], 1);\n\t\t}\n\t};\n\n\n\t// vacation plan level messages\n\tif(doc.doc_type == 'PlanRoute') {\n\n\t\t// route level messages\n\t\tif(doc.messages) \n\t\t\temit_all(doc.messages);\n\n\t\t// destination level messages\n\t\tif(doc.destinations) {\n\t\t\tfor(var i in doc.destinations) {\n\t\t\t\tif(doc.destinations[i].messages) {\n\t\t\t\t\temit_all(doc.destinations[i].messages);\n\t\t\t\t}\n\t\t\t\t// service level messages\n\t\t\t\tif(doc.destinations[i].services) {\n\t\t\t\t\tfor(var ii in doc.destinations[i].services) {\n\t\t\t\t\t\tif(doc.destinations[i].services[ii].messages) {\n\t\t\t\t\t\t\temit_all(doc.destinations[i].services[ii].messages);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}">>,
nil,
[{<<"by_date">>,
<<"function(keys, values) {\n\treturn sum(values)\n}">>}],
[]},
{view,1,0,0,
[<<"sent_by">>],
<<"function(doc) {\n\t\n\tvar key;\n\n\t// test if messages shoud be emitted\n\tvar emit_all = function(level, key, doc, messages) {\n\t\tfor(var i in messages) {\n\t\t\tdo_emit(level, key, doc, messages, i);\n\t\t}\n\t};\n\n\tvar do_emit = function(level, key, doc, msgs, idx) {\n\t\tmsg = msgs[idx];\n\t\tvar context = [];\n\t\tfor(i=0; i < idx; i++)\n\t\tcontext.push({who:msgs[i].who, message:msgs[i].message});\n\t\tvar ndoc = {\n\t\tmessage:msg.message,\n\t\twhen:msg.when,\n\t\twho:msg.who,\n\t\tgroup:msg.group,\n\t\tviewed_by:msg.viewed_by,\n\t\tlevel: level,\n\t\tdoc_id: doc._id,\n\t\tdoc_type: doc.doc_type,\n\t\tdoc_title: doc.name,\n\t\tcontext: context,\n\t\t};\n\n\t\tkeys = [msg.who, msg.when];\n\t\temit(keys, ndoc);\n\t};\n\n\t// vacation plan level messages\n\tif(doc.doc_type == 'PlanRoute') {\n\t\tkey = doc.staff_id;\n\n\t\t// route level messages\n\t\tif(doc.messages) \n\t\t\temit_all('', key, doc, doc.messages);\n\n\t\t// destination level messages\n\t\tif(doc.destinations) {\n\t\t\tfor(var i in doc.destinations) {\n\t\t\t\tif(doc.destinations[i].messages) {\n\t\t\t\t\tvar level = 'Destination ('+doc.destinations[i].destination_id+') on VP leg #' + doc.destinations[i].leg;\n\t\t\t\t\temit_all(level, key, doc, doc.destinations[i].messages);\n\t\t\t\t}\n\t\t\t\t// service level messages\n\t\t\t\tif(doc.destinations[i].services && doc.destinations[i].services.length > 0) {\n\t\t\t\t\tfor(var ii in doc.destinations[i].services) {\n\t\t\t\t\t\tif(doc.destinations[i].services[ii].messages) {\n\t\t\t\t\t\t\tvar level = doc.destinations[i].services[ii].desc;\n\t\t\t\t\t\t\temit_all(level, key, doc, doc.destinations[i].services[ii].messages, ii);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}">>,
nil,[],[]},
{view,2,0,0,
[<<"unviewed_by">>],
<<"function(doc) {\n\t\n\tvar key;\n\n\t// test if messages shoud be emitted\n\tvar test_and_emit = function(level, group_not, key, doc, messages) {\n\t\tfor(var i in messages) {\n\t\t\tif(messages[i].group != group_not && messages[i].viewed_by.indexOf(key) == -1) {\n\t\t\t\t// key not in the list, emit this message and doc details\n\t\t\t\tdo_emit(level, key, doc, messages, i);\n\t\t\t}\n\t\t}\n\t};\n\n\tvar do_emit = function(level, key, doc, msgs, idx) {\n\t\tmsg = msgs[idx];\n\t\tvar context = [];\n\t\tfor(i=0; i < idx; i++)\n\t\tcontext.push({who:msgs[i].who, message:msgs[i].message});\n\t\tvar ndoc = {\n\t\tmessage:msg.message,\n\t\twhen:msg.when,\n\t\twho:msg.who,\n\t\tgroup:msg.group,\n\t\tviewed_by:msg.viewed_by,\n\t\tlevel: level,\n\t\tdoc_id: doc._id,\n\t\tdoc_type: doc.doc_type,\n\t\tdoc_title: doc.name,\n\t\tcontext: context,\n\t\t};\n\t\temit(key, ndoc);\n\t};\n\n\t// suggest level messages\n\tif(doc.doc_type == 'ReserveSuggest') {\n\t\tkey = doc.staff_id;\n\t\t\n\t\t// doc level messages\n\t\tif(doc.messages) \n\t\t\ttest_and_emit('','staff', key, doc, doc.messages);\n\t\n\t\t// suggest level messages\n\t\tif(doc.suggests) {\n\t\t\tfor(var i in doc.suggests) {\n\t\t\t\tif(doc.suggests[i].messages) {\n\t\t\t\t\tvar level = doc.suggests[i].desc;\n\t\t\t\t\ttest_and_emit(level, 'staff', key, doc, doc.suggests[i].messages, ii);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// vacation plan level messages\n\tif(doc.doc_type == 'PlanRoute') {\n\t\tkey = doc.staff_id;\n\n\t\t// route level messages\n\t\tif(doc.messages) \n\t\t\ttest_and_emit('','staff', key, doc, doc.messages);\n\n\t\t// destination level messages\n\t\tif(doc.destinations) {\n\t\t\tfor(var i in doc.destinations) {\n\t\t\t\tif(doc.destinations[i].messages) {\n\t\t\t\t\tvar level = 'Destination ('+doc.destinations[i].destination_id+') on VP leg #' + doc.destinations[i].leg;\n\t\t\t\t\ttest_and_emit(level, 'staff', key, doc, doc.destinations[i].messages);\n\t\t\t\t}\n\t\t\t\t// service level messages\n\t\t\t\tif(doc.destinations[i].services && doc.destinations[i].services.length > 0) {\n\t\t\t\t\tfor(var ii in doc.destinations[i].services) {\n\t\t\t\t\t\tif(doc.destinations[i].services[ii].messages) {\n\t\t\t\t\t\t\tvar level = 'Service (' + doc.destinations[i].services[ii].type + ')';\n\t\t\t\t\t\t\ttest_and_emit(level, 'staff', key, doc, doc.destinations[i].services[ii].messages, ii);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}">>,
nil,[],[]}],
{[]},
nil,0,0,nil,nil}},
{group,
<<179,2,154,154,243,188,196,230,224,228,72,35,138,
126,255,36>>,
<0.1428.0>,<<"_design/message">>,<<"javascript">>,
[],
[{view,0,503333,0,[],
<<"function(doc) {\n\t\n\t// test if messages shoud be emitted\n\tvar emit_all = function(messages) {\n\t\tfor(var i in messages) {\n\t\t\tvar d = messages[i].when.split(\"-\");\n\t\t\tvar day = d[2].split(\"T\");\n\t\t\temit([d[0]+'-'+d[1]+'-'+day[0], messages[i].group, messages[i].who], 1);\n\t\t}\n\t};\n\n\n\t// vacation plan level messages\n\tif(doc.doc_type == 'PlanRoute') {\n\n\t\t// route level messages\n\t\tif(doc.messages) \n\t\t\temit_all(doc.messages);\n\n\t\t// destination level messages\n\t\tif(doc.destinations) {\n\t\t\tfor(var i in doc.destinations) {\n\t\t\t\tif(doc.destinations[i].messages) {\n\t\t\t\t\temit_all(doc.destinations[i].messages);\n\t\t\t\t}\n\t\t\t\t// service level messages\n\t\t\t\tif(doc.destinations[i].services) {\n\t\t\t\t\tfor(var ii in doc.destinations[i].services) {\n\t\t\t\t\t\tif(doc.destinations[i].services[ii].messages) {\n\t\t\t\t\t\t\temit_all(doc.destinations[i].services[ii].messages);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}">>,
{btree,<0.1428.0>,
{829460268,{128035,[128035]},6593177},
#Fun<couch_btree.3.62781489>,
#Fun<couch_btree.4.62781489>,
#Fun<couch_view.less_json_ids.2>,
#Fun<couch_view_group.10.74547581>,snappy},
[{<<"by_date">>,
<<"function(keys, values) {\n\treturn sum(values)\n}">>}],
[]},
{view,1,503333,0,
[<<"sent_by">>],
<<"function(doc) {\n\t\n\tvar key;\n\n\t// test if messages shoud be emitted\n\tvar emit_all = function(level, key, doc, messages) {\n\t\tfor(var i in messages) {\n\t\t\tdo_emit(level, key, doc, messages, i);\n\t\t}\n\t};\n\n\tvar do_emit = function(level, key, doc, msgs, idx) {\n\t\tmsg = msgs[idx];\n\t\tvar context = [];\n\t\tfor(i=0; i < idx; i++)\n\t\tcontext.push({who:msgs[i].who, message:msgs[i].message});\n\t\tvar ndoc = {\n\t\tmessage:msg.message,\n\t\twhen:msg.when,\n\t\twho:msg.who,\n\t\tgroup:msg.group,\n\t\tviewed_by:msg.viewed_by,\n\t\tlevel: level,\n\t\tdoc_id: doc._id,\n\t\tdoc_type: doc.doc_type,\n\t\tdoc_title: doc.name,\n\t\tcontext: context,\n\t\t};\n\n\t\tkeys = [msg.who, msg.when];\n\t\temit(keys, ndoc);\n\t};\n\n\t// vacation plan level messages\n\tif(doc.doc_type == 'PlanRoute') {\n\t\tkey = doc.staff_id;\n\n\t\t// route level messages\n\t\tif(doc.messages) \n\t\t\temit_all('', key, doc, doc.messages);\n\n\t\t// destination level messages\n\t\tif(doc.destinations) {\n\t\t\tfor(var i in doc.destinations) {\n\t\t\t\tif(doc.destinations[i].messages) {\n\t\t\t\t\tvar level = 'Destination ('+doc.destinations[i].destination_id+') on VP leg #' + doc.destinations[i].leg;\n\t\t\t\t\temit_all(level, key, doc, doc.destinations[i].messages);\n\t\t\t\t}\n\t\t\t\t// service level messages\n\t\t\t\tif(doc.destinations[i].services && doc.destinations[i].services.length > 0) {\n\t\t\t\t\tfor(var ii in doc.destinations[i].services) {\n\t\t\t\t\t\tif(doc.destinations[i].services[ii].messages) {\n\t\t\t\t\t\t\tvar level = doc.destinations[i].services[ii].desc;\n\t\t\t\t\t\t\temit_all(level, key, doc, doc.destinations[i].services[ii].messages, ii);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}">>,
{btree,<0.1428.0>,
{829552398,{108630,[]},204390994},
#Fun<couch_btree.3.62781489>,
#Fun<couch_btree.4.62781489>,
#Fun<couch_view.less_json_ids.2>,
#Fun<couch_view_group.10.74547581>,snappy},
[],[]},
{view,2,503333,0,
[<<"unviewed_by">>],
<<"function(doc) {\n\t\n\tvar key;\n\n\t// test if messages shoud be emitted\n\tvar test_and_emit = function(level, group_not, key, doc, messages) {\n\t\tfor(var i in messages) {\n\t\t\tif(messages[i].group != group_not && messages[i].viewed_by.indexOf(key) == -1) {\n\t\t\t\t// key not in the list, emit this message and doc details\n\t\t\t\tdo_emit(level, key, doc, messages, i);\n\t\t\t}\n\t\t}\n\t};\n\n\tvar do_emit = function(level, key, doc, msgs, idx) {\n\t\tmsg = msgs[idx];\n\t\tvar context = [];\n\t\tfor(i=0; i < idx; i++)\n\t\tcontext.push({who:msgs[i].who, message:msgs[i].message});\n\t\tvar ndoc = {\n\t\tmessage:msg.message,\n\t\twhen:msg.when,\n\t\twho:msg.who,\n\t\tgroup:msg.group,\n\t\tviewed_by:msg.viewed_by,\n\t\tlevel: level,\n\t\tdoc_id: doc._id,\n\t\tdoc_type: doc.doc_type,\n\t\tdoc_title: doc.name,\n\t\tcontext: context,\n\t\t};\n\t\temit(key, ndoc);\n\t};\n\n\t// suggest level messages\n\tif(doc.doc_type == 'ReserveSuggest') {\n\t\tkey = doc.staff_id;\n\t\t\n\t\t// doc level messages\n\t\tif(doc.messages) \n\t\t\ttest_and_emit('','staff', key, doc, doc.messages);\n\t\n\t\t// suggest level messages\n\t\tif(doc.suggests) {\n\t\t\tfor(var i in doc.suggests) {\n\t\t\t\tif(doc.suggests[i].messages) {\n\t\t\t\t\tvar level = doc.suggests[i].desc;\n\t\t\t\t\ttest_and_emit(level, 'staff', key, doc, doc.suggests[i].messages, ii);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// vacation plan level messages\n\tif(doc.doc_type == 'PlanRoute') {\n\t\tkey = doc.staff_id;\n\n\t\t// route level messages\n\t\tif(doc.messages) \n\t\t\ttest_and_emit('','staff', key, doc, doc.messages);\n\n\t\t// destination level messages\n\t\tif(doc.destinations) {\n\t\t\tfor(var i in doc.destinations) {\n\t\t\t\tif(doc.destinations[i].messages) {\n\t\t\t\t\tvar level = 'Destination ('+doc.destinations[i].destination_id+') on VP leg #' + doc.destinations[i].leg;\n\t\t\t\t\ttest_and_emit(level, 'staff', key, doc, doc.destinations[i].messages);\n\t\t\t\t}\n\t\t\t\t// service level messages\n\t\t\t\tif(doc.destinations[i].services && doc.destinations[i].services.length > 0) {\n\t\t\t\t\tfor(var ii in doc.destinations[i].services) {\n\t\t\t\t\t\tif(doc.destinations[i].services[ii].messages) {\n\t\t\t\t\t\t\tvar level = 'Service (' + doc.destinations[i].services[ii].type + ')';\n\t\t\t\t\t\t\ttest_and_emit(level, 'staff', key, doc, doc.destinations[i].services[ii].messages, ii);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}">>,
{btree,<0.1428.0>,
{829591489,{139,[]},306902},
#Fun<couch_btree.3.62781489>,
#Fun<couch_btree.4.62781489>,
#Fun<couch_view.less_json_ids.2>,
#Fun<couch_view_group.10.74547581>,snappy},
[],[]}],
{[]},
{btree,<0.1428.0>,
{829452501,[],6016985},
#Fun<couch_btree.3.62781489>,
#Fun<couch_btree.4.62781489>,
#Fun<couch_btree.5.62781489>,nil,snappy},
503333,0,nil,nil},
<0.1431.0>,nil,false,
[{{<0.130.0>,#Ref<0.0.0.41069>},509735}],
<0.1430.0>,false}
** Reason for termination ==
** {os_process_error,"OS process timed out."}
[Sat, 22 Dec 2012 18:28:53 GMT] [error] [<0.1427.0>] {error_report,<0.31.0>,
{<0.1427.0>,crash_report,
[[{initial_call,
{couch_view_group,init,['Argument__1']}},
{pid,<0.1427.0>},
{registered_name,[]},
{error_info,
{exit,
{os_process_error,"OS process timed out."},
[{gen_server,terminate,6,
[{file,"gen_server.erl"},{line,737}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]}},
{ancestors,[<0.1426.0>]},
{messages,[]},
{links,[<0.1428.0>,<0.122.0>]},
{dictionary,[]},
{trap_exit,true},
{status,running},
{heap_size,2584},
{stack_size,24},
{reductions,545}],
[]]}}
[Sat, 22 Dec 2012 18:28:53 GMT] [error] [<0.130.0>] Uncaught server error: {os_process_error,
<<"OS process timed out.">>}
[Sat, 22 Dec 2012 18:28:53 GMT] [error] [<0.1428.0>] ** Generic server <0.1428.0> terminating
** Last message in was {'EXIT',<0.1427.0>,
{os_process_error,"OS process timed out."}}
** When Server state == {file,{file_descriptor,prim_file,{#Port<0.2941>,101}},
829595830}
** Reason for termination ==
** {os_process_error,"OS process timed out."}
[Sat, 22 Dec 2012 18:28:53 GMT] [error] [<0.1428.0>] {error_report,<0.31.0>,
{<0.1428.0>,crash_report,
[[{initial_call,{couch_file,init,['Argument__1']}},
{pid,<0.1428.0>},
{registered_name,[]},
{error_info,
{exit,
{os_process_error,"OS process timed out."},
[{gen_server,terminate,6,
[{file,"gen_server.erl"},{line,737}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]}},
{ancestors,[<0.1427.0>,<0.1426.0>]},
{messages,[{'EXIT',<0.1430.0>,shutdown}]},
{links,[]},
{dictionary,[]},
{trap_exit,true},
{status,running},
{heap_size,377},
{stack_size,24},
{reductions,1125}],
[]]}}
此外,我经常在日志中看到此错误,即使关联的请求正常返回:
[Sat, 22 Dec 2012 19:20:28 GMT] [info] [<0.3849.0>] checkpointing view update at seq 232409 for xxxx _design/all_types
[Sat, 22 Dec 2012 19:20:28 GMT] [error] [<0.124.0>] {error_report,<0.31.0>,
{<0.124.0>,crash_report,
[[{initial_call,
{mochiweb_socket_server,init,['Argument__1']}},
{pid,<0.124.0>},
{registered_name,[]},
{error_info,
{exit,eaddrinuse,
[{gen_server,init_it,6,
[{file,"gen_server.erl"},{line,313}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]}},
{ancestors,
[couch_secondary_services,couch_server_sup,<0.32.0>]},
{messages,[]},
{links,[<0.93.0>]},
{dictionary,[]},
{trap_exit,true},
{status,running},
{heap_size,987},
{stack_size,24},
{reductions,466}],
[]]}}
答案 0 :(得分:4)
在视图索引更新期间,CouchDB为指定的设计文档运行更新视图。这也意味着超时错误适用于整个组,而不适用于特定的视图功能。对于您的情况,此错误意味着您的视图组现在不能像以前那样快速运行某些文档(单个文档适用于整个组) - 可能,他们现在有一些大的东西。
但是,这个错误并不是致命的,它只是限制让查询服务器运行时间过长并激励您编写快速优化的函数(快速处理 - >快速响应)。我在你的视图中看到“for”循环 - 可能有可能降低大消息列表的复杂性?无论如何,您总是可以通过更新CouchDB配置来延长OS进程超时:
curl -X PUT http://localhost:5984/_config/couchdb/os_process_timeout -d '"35000"'
将3500替换为您喜欢的号码。此值定义查询服务器在由于超时而终止之前可以处理CouchDB命令(查看索引,设计文档函数执行,验证,过滤器等)的毫秒数。响应curl请求,您将获得旧的配置值。
修改:将query_servers_config/os_process_limit
替换为couchdb/os_process_timeout
。这是两个不同的选项:第一个控制可以为单个ddoc语言运行的查询服务器进程数量,而第二个指定实际执行时间限制。