aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia
diff options
context:
space:
mode:
authorBartlomiej Puzon <[email protected]>2012-06-18 15:58:08 -0700
committerBartlomiej Puzon <[email protected]>2012-06-18 15:58:08 -0700
commit8490cb6328da880119dbc1eb92d3b439a2c5f34a (patch)
treee21c51ee85c7dea5b0db4c3d77592b3661bb4dfc /lib/mnesia
parent628d51fd2171cb6e8275f9a16d85300e42e83594 (diff)
downloadotp-8490cb6328da880119dbc1eb92d3b439a2c5f34a.tar.gz
otp-8490cb6328da880119dbc1eb92d3b439a2c5f34a.tar.bz2
otp-8490cb6328da880119dbc1eb92d3b439a2c5f34a.zip
Add tests showing that trying to delete non-existing object may corrupt the table index
In case of bag tables, trying to delete a non-existing object leads to the index becoming corrupt. This happens if the non-existing object we try to delete happens to share its key and index field value with a single existing object in the table. Result: The index entry corresponding to the existing object is removed.
Diffstat (limited to 'lib/mnesia')
-rw-r--r--lib/mnesia/test/mnesia_dirty_access_test.erl3
-rw-r--r--lib/mnesia/test/mnesia_trans_access_test.erl4
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/mnesia/test/mnesia_dirty_access_test.erl b/lib/mnesia/test/mnesia_dirty_access_test.erl
index abbdab48c0..a57adefbac 100644
--- a/lib/mnesia/test/mnesia_dirty_access_test.erl
+++ b/lib/mnesia/test/mnesia_dirty_access_test.erl
@@ -527,6 +527,9 @@ dirty_index_update_bag(Config, Storage) ->
?match(ok, mnesia:dirty_write(Rec1)),
?match([Rec1], mnesia:dirty_index_read(Tab, 2, ValPos)),
+ ?match(ok, mnesia:dirty_delete_object(Rec5)),
+ ?match([Rec1], mnesia:dirty_index_read(Tab, 2, ValPos)),
+
?match({atomic, ok}, mnesia:transaction(fun() -> mnesia:write(Rec2) end)),
R1 = mnesia:dirty_index_read(Tab, 2, ValPos),
?match([Rec1, Rec2], lists:sort(R1)),
diff --git a/lib/mnesia/test/mnesia_trans_access_test.erl b/lib/mnesia/test/mnesia_trans_access_test.erl
index c040d0ca3f..73c3fe0362 100644
--- a/lib/mnesia/test/mnesia_trans_access_test.erl
+++ b/lib/mnesia/test/mnesia_trans_access_test.erl
@@ -896,6 +896,10 @@ index_update_bag(Config)when is_list(Config) ->
?match({atomic, [Rec1]},
mnesia:transaction(fun() -> mnesia:index_read(Tab, 2, ValPos) end)),
+ ?match({atomic, ok}, mnesia:transaction(fun() -> mnesia:delete_object(Rec5) end)),
+ ?match({atomic, [Rec1]},
+ mnesia:transaction(fun() -> mnesia:index_read(Tab, 2, ValPos) end)),
+
?match({atomic, ok},
mnesia:transaction(fun() -> mnesia:write(Rec2) end)),
{atomic, R1} = mnesia:transaction(fun() -> mnesia:index_read(Tab, 2, ValPos) end),