前言
最近遇到一个奇怪的问题,mnesia数据有时能查出来有时查不出来,细查发现是mnesia:delect_object删除时,只删除了索引,没有删除具体的数据
问题重现
- 表结构:
1 | -record(gordon_test, { |
- 初使化代码:
1 | mnesia:create_table(gordon_test, [ |
- 插入数据:
1 | mnesia:dirty_write(gordon_test, {gordon_test, {1, 1}, 1, 1, "", "", os:timestamp()}). |
3.查询:
1 | Id = 3, |
- 执行删除:
1 | mnesia:dirty_delete_object(X#gordon_test{locale = aaaa}). |
- 两次查询,dirty_index_read查不到数据:
1 | % 数据查询为空 |
问题定位
查文档:
1 | If a table is of type bag, it can sometimes be needed to delete only some of the records with a certain key. |
深层研究
待继续 @todo