我使用localhost:27019,27020,27021作为mongodb服务器 当我第一次用5个线程连接它时,每个进程读取一个data.it将抛出异常。如果我使用3个或更少的线程,那就没问题了。
但是当我通过3个线程成功连接它时,如果我通过100个进程使用相同的连接,它将不再抛出异常,除非我重新连接mongoserver。
=ERROR REPORT==== 3-Aug-2013::11:28:37 ===
** Generic server <0.164.0> terminating
** Last message in was {modify,#Fun<mvar.2.15158540>}
** When Server state == {{dict,3,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
[]},
{{[],[],[],
[[{"192.168.17.100",27019}|{}]],
[],
[[{"192.168.17.100",27021}|{}]],
[],[],[],[],[],[],
[[{"192.168.17.100",27020}|{}]],
[],[],[]}}},
#Fun<mvar.1.22957847>}
** Reason for termination ==
** {badarg,[{dict,fetch,
[{"localhost",27021},
{dict,3,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],
[[{"192.168.17.100",27019}|{}]],
[],
[[{"192.168.17.100",27021}|{}]],
[],[],[],[],[],[],
[[{"192.168.17.100",27020}|{}]],
[],[],[]}}}]},
{mongo_replset,remove_host,2},
{sets,fold_bucket,3},
{sets,fold_seg,4},
{sets,fold_segs,4},
{mongo_replset,'-fetch_member_info/1-fun-3-',3},
{mvar,'-modify_/2-fun-0-',2},
{mvar,handle_call,3}]}
Pid {<0.88.0>,
{badarg,[{dict,fetch,
[{"localhost",27021},
{dict,3,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],
[[{"192.168.17.100",27019}|{}]],
[],
[[{"192.168.17.100",27021}|{}]],
[],[],[],[],[],[],
[[{"192.168.17.100",27020}|{}]],
[],[],[]}}}]},
{mongo_replset,remove_host,2},
{sets,fold_bucket,3},
{sets,fold_seg,4},
{sets,fold_segs,4},
{mongo_replset,'-fetch_member_info/1-fun-3-',3},
{mvar,'-modify_/2-fun-0-',2},
{mvar,handle_call,3}]}} Exit!!!!!
答案 0 :(得分:1)
您可以在错误日志中看到连接存储在进程字典中{"192.168.17.100",27019}
...
当程序查找{"localhost",27021}
形式的元组时程序失败。显然,您的本地主机地址必须是192.168.17.100
,并且在您正在进行的不同测试之间,您直接或不直接调用具有不同形式的localhost的dict:fetch/2
函数(“localhost”和“192.168.17.100”) )。