Permalink
Browse files

JIRA : ARAKOON-229 tlog compression of large values

  • Loading branch information...
1 parent fd967eb commit 7784f049e251a835f4e74333fabcbadac4b79a54 Romain Slootmaekers committed Aug 1, 2011
Showing with 34 additions and 1 deletion.
  1. +1 −1 src/tlog/compression.ml
  2. +33 −0 src/tlog/tlc2_test.ml
View
@@ -45,7 +45,7 @@ let compress_tlog tlog_name archive_name =
Tlogcommon.entry_to buffer i u;
let (last_i':Sn.t) = if i > last_i then i else last_i
in
- if Buffer.length buffer < limit
+ if Buffer.length buffer < limit || counter = 0
then fill_buffer (buffer:Buffer.t) last_i' (counter+1)
else Lwt.return (last_i',counter)
)
View
@@ -20,6 +20,7 @@ GNU Affero General Public License along with this program (file "COPYING").
If not, see <http://www.gnu.org/licenses/>.
*)
+open Unix
open OUnit
open Lwt
open Update
@@ -177,6 +178,37 @@ let test_iterate6 (dn,factory) =
OUnit.assert_equal ~printer:string_of_int 19 !sum;
Lwt.return ()
+let test_compression_bug (dn, factory) =
+ let () = Tlogcommon.tlogEntriesPerFile := 10 in
+ let v = String.create (1024 * 1024) in
+ factory dn >>= fun tlc ->
+ let n = 12 in
+ let rec loop i =
+ if i = n then Lwt.return ()
+ else
+ let key = Printf.sprintf "test_compression_bug_%i" i in
+ let update = Update.Set(key, v) in
+ let sni = Sn.of_int i in
+ tlc # log_update sni update >>= fun () ->
+ loop (i+1)
+ in
+ tlc # log_update 0L (Update.Set("xxx","XXX")) >>= fun () ->
+ loop 1 >>= fun () ->
+ tlc # close () >>= fun () ->
+ Lwt_unix.sleep 20.0 >>= fun () ->
+ File_system.stat (dn ^ "/000.tlf") >>= fun stat ->
+ OUnit.assert_bool "file should have size >0" (stat.st_size > 0);
+ let entries = ref [] in
+ factory dn >>= fun tlc2 ->
+ tlc2 # iterate 0L (Sn.of_int n)
+ (fun (i,u) -> entries := i :: !entries;
+ Lwt_log.debug_f "ENTRY: i=%Li" i)
+ >>= fun () ->
+ OUnit.assert_equal
+ ~printer:string_of_int
+ ~msg:"tlc has a hole" n (List.length !entries);
+ Lwt.return ()
+
let suite = "tlc2" >:::[
"regexp" >:: wrap_tlc Tlogcollection_test.test_regexp;
"empty_collection" >:: wrap_tlc Tlogcollection_test.test_empty_collection;
@@ -194,4 +226,5 @@ let suite = "tlc2" >:::[
"test_rollover_1002" >:: wrap_tlc Tlogcollection_test.test_rollover_1002;
"test_rollover_boundary" >:: wrap_tlc test_validate_at_rollover_boundary;
"test_interrupted_rollover" >:: wrap_tlc test_interrupted_rollover;
+ "test_compression_bug" >:: wrap_tlc test_compression_bug;
]

0 comments on commit 7784f04

Please sign in to comment.