diff options
author | Hans Bolinder <[email protected]> | 2010-10-19 16:13:19 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2010-10-21 08:56:31 +0200 |
commit | 74af6abf8fe889f04f9fcfc70d5a5facf0aa7053 (patch) | |
tree | e7dd745a096538cf26229187d92f283eb58bf521 /lib/stdlib/test | |
parent | dc7d2319691fa599717c066460cce53ce97b6b18 (diff) | |
download | otp-74af6abf8fe889f04f9fcfc70d5a5facf0aa7053.tar.gz otp-74af6abf8fe889f04f9fcfc70d5a5facf0aa7053.tar.bz2 otp-74af6abf8fe889f04f9fcfc70d5a5facf0aa7053.zip |
Fix a bug concerning truncated Dets files
When several clients accessed a Dets table simultaneously, inserted or
updated objects were sometimes lost due to the Dets file being
truncated.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r-- | lib/stdlib/test/dets_SUITE.erl | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/stdlib/test/dets_SUITE.erl b/lib/stdlib/test/dets_SUITE.erl index 760e610e00..82684000bb 100644 --- a/lib/stdlib/test/dets_SUITE.erl +++ b/lib/stdlib/test/dets_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -50,7 +50,7 @@ otp_4208/1, otp_4989/1, many_clients/1, otp_4906/1, otp_5402/1, simultaneous_open/1, insert_new/1, repair_continuation/1, otp_5487/1, otp_6206/1, otp_6359/1, otp_4738/1, otp_7146/1, - otp_8070/1]). + otp_8070/1, otp_8898/1]). -export([dets_dirty_loop/0]). @@ -108,7 +108,7 @@ all(suite) -> cache_duplicate_bags_v9, otp_4208, otp_4989, many_clients, otp_4906, otp_5402, simultaneous_open, insert_new, repair_continuation, otp_5487, otp_6206, otp_6359, otp_4738, - otp_7146, otp_8070]} + otp_7146, otp_8070, otp_8898]} end. not_run(suite) -> []; @@ -2935,6 +2935,29 @@ ets_init(Tab, N) -> ets:insert(Tab, {N,N}), ets_init(Tab, N - 1). +otp_8898(doc) -> + ["OTP-8898. Truncated Dets file."]; +otp_8898(suite) -> + []; +otp_8898(Config) when is_list(Config) -> + Tab = otp_8898, + ?line FName = filename(Tab, Config), + + Server = self(), + + ?line file:delete(FName), + ?line {ok, _} = dets:open_file(Tab,[{file, FName}]), + ?line [P1,P2,P3] = new_clients(3, Tab), + + Seq = [{P1,[sync]},{P2,[{lookup,1,[]}]},{P3,[{insert,{1,b}}]}], + ?line atomic_requests(Server, Tab, [[]], Seq), + ?line true = get_replies([{P1,ok},{P2,ok},{P3,ok}]), + ?line ok = dets:close(Tab), + ?line {ok, _} = dets:open_file(Tab,[{file, FName}]), + ?line file:delete(FName), + + ok. + many_clients(doc) -> ["Several clients accessing a table simultaneously."]; many_clients(suite) -> |