CouchDB/Couchest错误号::ECONNREFUSED连接被拒绝-连接(2)错误



在工作中,我们有大约1500个测试用例,我们使用DB.recreate手动清理数据库!方法。当使用bundle exec rake spec运行所有测试时,所有测试都很少通过。有许多测试在套件末尾失败,并出现"Errno::ECONNREFUSED Connection Rejected-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

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

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

这绝对解决了我的问题。

需要注意的是,它使我们的测试持续时间增加了一倍。这是另一个需要解决的问题,但就目前而言,我对所有通过测试的人都很满意。

最新更新