Joan, Thanks a lot for your response. Which process should I check for the limit? Here is the output of `ps -ef | grep [c]ouchdb`:
501 958 1 0 21Jun16 ?? 0:04.49 /usr/local/bin/../lib/couchdb/erts-7.2.1/bin/epmd -daemon 501 50547 1 0 5:35AM ?? 3:03.32 /usr/local/bin/../lib/couchdb/erts-7.2.1/bin/beam.smp -K true -A 16 -Bd -- -root /usr/local/bin/../lib/couchdb -progname couchdb -- -home /Users/ybian -- -boot /usr/local/bin/../lib/couchdb/releases/2.0.0a/couchdb -name couchdb@localhost -setcookie monster -kernel error_logger silent -sasl sasl_error_logger false -noshell -noinput 501 50559 50547 0 5:35AM ?? 0:00.00 /usr/local/bin/../lib/couchdb/lib/os_mon-2.4/priv/bin/cpu_sup 501 51060 50547 0 5:46AM ?? 0:00.02 /usr/local/lib/couchdb/bin/couchjs /usr/local/lib/couchdb/share/server/main.js 501 51061 50547 0 5:46AM ?? 0:00.03 /usr/local/lib/couchdb/bin/couchjs /usr/local/lib/couchdb/share/server/main.js I used `lsof -p <pid> | wc -l` for each value of 958, 50547, 50559, 51060, 51061 and the maximum number returned is 148: $ lsof -p 50547 | wc -l 148 This is far less than the limit I think. But it does not prove anything as the problem does not occur at this specific time. I will check what the value is when I meet the problem again. Another question, how did you know that the error is EMFILE? I did not see this even by skimming through the code. Thanks again. -Ying > On Jun 30, 2016, at 2:52 PM, Joan Touzet <[email protected]> wrote: > > Ying, > > Looks like your error is EMFILE, meaning too many open files as returned > by the operating system. > > On OSX it appears you can up the limit: > > http://stackoverflow.com/questions/5377450/maximum-number-of-open-filehandles-per-process-on-osx-and-how-to-increase > > Try the command(s) listed there and see if this fixes your problem. > > Good luck, > Joan > > ----- Original Message ----- >> From: "Ying Bian" <[email protected]> >> To: [email protected] >> Sent: Wednesday, June 29, 2016 6:09:11 PM >> Subject: Need help on this "badmatch" error of couchdb 2.0 >> >> Hi, >> >> I'm developing a web application using couchdb 2.0 dev build (version >> is '9d28c57' at this time) as the database. Sometimes when I do a >> simple query against a simple view using pouchdb api, I got the >> following error emitted by couchdb (I've tried to prettify the >> output by replacing '\n' with hard newline). When the error happens, >> if I wait for a few minutes and try again, it may work again. But >> this is definitely something that I need to worry about as it looks >> like something fundamental with couchdb. >> >> This happens in my local Mac machine. The only special thing about my >> setup is that there are about 70+ small databases created, but my >> query is against only one of those. Let me know if you have any >> idea. I can upgrade to the latest build if you think that may help, >> but I doubt that as I upgraded several times before but things did >> not change. >> >> The error stack: >> >> {"status":500,"name":"badmatch","message":"Database encountered an >> unknown >> error","reason":"{error,{badmatch,{error,{{badmatch,{error,emfile}}, >> [{couch_file,init,1, >> [{file,\"src/couch_file.erl\"},{line,336}]}, >> {gen_server,init_it,6, >> [{file,\"gen_server.erl\"},{line,328}]}, >> {proc_lib,init_p_do_apply,3, >> [{file,\"proc_lib.erl\"},{line,240}]}]}}, >> [{couch_index_server,get_index,4, >> [{file,\"src/couch_index_server.erl\"}, >> {line,97}]}, >> {couch_mrview_util,get_view,4, >> [{file,\"src/couch_mrview_util.erl\"}, >> {line,47}]}, >> {couch_mrview,query_view,6, >> [{file,\"src/couch_mrview.erl\"},{line,244}]}, >> {rexi_server,init_p,3, >> [{file,\"src/rexi_server.erl\"},{line,139}]}]}}"} >> >> -Ying
