【问题标题】:Why does ets delete my tables rudely?为什么 ets 粗鲁地删除我的表?
【发布时间】:2012-10-16 12:51:45
【问题描述】:

在ets中查找一个不存在的表(t3)后,所有用户创建的表(t1和t2)将被删除。这是一个错误还是只是 ets 的一个奇怪的功能?

这是 Eshell 中的代码。


Eshell V5.9.1  (abort with ^G)

1> ets:new(t1, [named_table]).

t1

2> ets:new(t2, [named_table]).

t2

3> ets:all().

[t2,t1,8207,4110,13,file_io_servers,inet_hosts_file_byaddr,
 inet_hosts_file_byname,inet_hosts_byaddr,inet_hosts_byname,
 inet_cache,inet_db,global_pid_ids,global_pid_names,
 global_names_ext,global_names,global_locks,ac_tab]

4> ets:insert(t1, {1,2}).

true

5> ets:lookup(t1, 1).

[{1,2}]

6> ets:lookup(t2, 1).

[]

7> ets:all().        

[t2,t1,8207,4110,13,file_io_servers,inet_hosts_file_byaddr,
 inet_hosts_file_byname,inet_hosts_byaddr,inet_hosts_byname,
 inet_cache,inet_db,global_pid_ids,global_pid_names,
 global_names_ext,global_names,global_locks,ac_tab]

8> ets:lookup(t3, 1).

** exception error: bad argument
     in function  ets:lookup/2
        called as ets:lookup(t3,1)

9> ets:all().        

[8207,4110,13,file_io_servers,inet_hosts_file_byaddr,
 inet_hosts_file_byname,inet_hosts_byaddr,inet_hosts_byname,
 inet_cache,inet_db,global_pid_ids,global_pid_names,
 global_names_ext,global_names,global_locks,ac_tab]

10> 

谁能告诉我这里有什么问题?

【问题讨论】:

标签: erlang ets


【解决方案1】:

你在一个不存在的表中查找,所以你得到一个“崩溃”你的 shell 的错误。一个新的 shell 正在启动,它看起来是透明的,只是属于第一个 shell 的 ets 被删除了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-17
    • 2013-04-25
    • 1970-01-01
    • 2013-03-15
    • 1970-01-01
    • 2012-02-06
    • 2021-04-20
    • 2015-07-23
    相关资源
    最近更新 更多