CouchDB / Couchrest Errno :: ECONNREFUSED连接被拒绝 - 连接(2)错误

时间:2013-08-20 19:06:16

标签: ruby-on-rails rspec couchdb

在工作中,我们有大约1500个测试用例,我们使用DB.recreate手动清理数据库!每次测试前的方法。使用bundle exec rake spec运行所有测试时,所有测试都很少通过。通过“Errno :: ECONNREFUSED Connection Refused - connect(2)error”错误,有许多测试无法通过套件结束。

非常感谢任何帮助!

我正在使用CouchDB 1.3.1,Ubuntu 12.04 LTS,Ruby 1.9.3和Rails 3.2.12。

谢谢,

修改

我仔细查看了日志文件,并与开始失败的时间测试和在couchdb日志中生成的错误消息相匹配。

[Fri, 16 Aug 2013 19:39:46 GMT] [error] [<0.23790.0>] ** Generic server <0.23790.0> terminating 
** Last message in was {'EXIT',<0.23789.0>,killed}
** When Server state == {file,{file_descriptor,prim_file,{#Port<0.14445>,20}},
                              79}
** Reason for termination == 
** killed

[Fri, 16 Aug 2013 19:39:46 GMT] [error] [<0.23790.0>] {error_report,<0.31.0>,
                          {<0.23790.0>,crash_report,
                           [[{initial_call,{couch_file,init,['Argument__1']}},
                             {pid,<0.23790.0>},
                             {registered_name,[]},
                             {error_info,
                                 {exit,killed,
                                     [{gen_server,terminate,6},
                                      {proc_lib,init_p_do_apply,3}]}},
                             {ancestors,[<0.23789.0>]},
                             {messages,[]},
                             {links,[]},
                             {dictionary,[]},
                             {trap_exit,true},
                             {status,running},
                             {heap_size,377},
                             {stack_size,24},
                             {reductions,916}],
                            []]}}
[Fri, 16 Aug 2013 19:39:46 GMT] [error] [<0.23808.0>] {error_report,<0.31.0>,
                       {<0.23808.0>,crash_report,
                        [[{initial_call,
                           {couch_ref_counter,init,['Argument__1']}},
                          {pid,<0.23808.0>},
                          {registered_name,[]},
                          {error_info,
                           {exit,
                            {noproc,
                             [{erlang,link,[<0.23790.0>]},
                              {couch_ref_counter,'-init/1-lc$^0/1-0-',1},
                              {couch_ref_counter,init,1},
                              {gen_server,init_it,6},
                              {proc_lib,init_p_do_apply,3}]},
                            [{gen_server,init_it,6},
                             {proc_lib,init_p_do_apply,3}]}},
                          {ancestors,[<0.23793.0>,<0.23792.0>,<0.23789.0>]},
                          {messages,[]},
                          {links,[]},
                          {dictionary,[]},
                          {trap_exit,false},
                          {status,running},
                          {heap_size,377},
                          {stack_size,24},
                          {reductions,114}],
                         []]}}
[Fri, 16 Aug 2013 19:39:46 GMT] [error] [<0.103.0>] ** Generic server <0.103.0> terminating 
** Last message in was {'EXIT',<0.88.0>,killed}
** When Server state == {db,<0.103.0>,<0.104.0>,nil,<<"1376681645837889">>,
                            <0.106.0>,<0.102.0>,<0.107.0>,
                            {db_header,6,1,0,
                                {1856,{1,0,1777},95},
                                {1951,1,83},
                                nil,0,nil,nil,1000},
                            1,
                            {btree,<0.102.0>,
                                {1856,{1,0,1777},95},
                                #Fun<couch_db_updater.10.55895019>,
                                #Fun<couch_db_updater.11.100913286>,
                                #Fun<couch_btree.5.25288484>,
                                #Fun<couch_db_updater.12.39068440>,snappy},
                            {btree,<0.102.0>,
                                {1951,1,83},
                                #Fun<couch_db_updater.13.114276184>,
                                #Fun<couch_db_updater.14.2340873>,
                                #Fun<couch_btree.5.25288484>,
                                #Fun<couch_db_updater.15.23651859>,snappy},
                            {btree,<0.102.0>,nil,
                                #Fun<couch_btree.3.20686015>,
                                #Fun<couch_btree.4.73514747>,
                                #Fun<couch_btree.5.25288484>,nil,snappy},
                            1,<<"_users">>,"/var/lib/couchdb/_users.couch",
                            [#Fun<couch_doc.8.106888048>],
                            [],nil,
                            {user_ctx,null,[],undefined},
                            nil,1000,
                            [before_header,after_header,on_file_open],
                            [create,
                             {before_doc_update,
                                 #Fun<couch_users_db.before_doc_update.2>},
                             {after_doc_read,
                                 #Fun<couch_users_db.after_doc_read.2>},
                             sys_db,
                             {user_ctx,
                                 {user_ctx,null,[<<"_admin">>],undefined}},
                             nologifmissing,sys_db],
                            snappy,#Fun<couch_users_db.before_doc_update.2>,
                            #Fun<couch_users_db.after_doc_read.2>}
** Reason for termination == 
** killed

1 个答案:

答案 0 :(得分:2)

啊......社区的力量。我从CouchDB邮件列表中的某个人那里得到了以下答案。

简而言之,解决方案是将delayed_commit值更改为false。默认情况下它设置为true,并且在每个测试用例开始时快速重新创建多个数据库都会创建竞争条件(删除不存在的数据库等)。

这绝对解决了我的问题。

有一点需要注意的是,它的测试时间增加了一倍。这是另一个需要解决的问题,但就目前而言,我对所有通过测试感到满意。